{"id":48788476,"url":"https://github.com/die-bauerei/smartplug-energy-controller","last_synced_at":"2026-04-13T18:28:32.772Z","repository":{"id":237667556,"uuid":"795004084","full_name":"die-bauerei/smartplug-energy-controller","owner":"die-bauerei","description":"Turning smartplugs on/off depending on current electricity consumption","archived":false,"fork":false,"pushed_at":"2025-08-29T15:36:14.000Z","size":329,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T20:16:07.467Z","etag":null,"topics":["electricity-meter","habapp","home-automation","openhab","python","smartplug","sustainability","tapo-devices","webservice"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/die-bauerei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-02T11:52:20.000Z","updated_at":"2025-08-29T15:33:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc0ba282-27b8-418a-9ff7-b5514df2cb20","html_url":"https://github.com/die-bauerei/smartplug-energy-controller","commit_stats":null,"previous_names":["die-bauerei/smartplug-energy-controller"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/die-bauerei/smartplug-energy-controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/die-bauerei%2Fsmartplug-energy-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/die-bauerei%2Fsmartplug-energy-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/die-bauerei%2Fsmartplug-energy-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/die-bauerei%2Fsmartplug-energy-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/die-bauerei","download_url":"https://codeload.github.com/die-bauerei/smartplug-energy-controller/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/die-bauerei%2Fsmartplug-energy-controller/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31765946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electricity-meter","habapp","home-automation","openhab","python","smartplug","sustainability","tapo-devices","webservice"],"created_at":"2026-04-13T18:28:31.976Z","updated_at":"2026-04-13T18:28:32.761Z","avatar_url":"https://github.com/die-bauerei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# smartplug-energy-controller\n\nA microservice to turn a smartplug on/off depending on current electricity consumption.\nThe intention of this service is to use all energy you produced, e.g with a balcony power plant, by e.g. loading a portable battery.\nThis can be achieved by plug in your battery into a smartplug. The smartplug is turned on/off dynamically, depending on your current electricity consumption. \n\nThe service is especially useful when your electricity meter supports OBIS 1.8.x only (no OBIS 2.8.x).\nIn such a scenario you can give this service your current electricity meter value (obtained watt from provider) and your current watt production (e.g. from a balcony power plant) and it calculates a reasonable point when to turn your smartplugs on/off.\n\n## Installation ##\nThe python package can be installed from PyPi (https://pypi.org/project/smartplug-energy-controller/)\n\n1. Navigate to the folder where the virtual environment shall be created (e.g. your home dir):\n```bash\ncd ~\n```\n2. Create virtual environment (this will create a new folder *smart_meter_py_env*):\n```bash\npython3 -m venv smart_meter_py_env\n```\n3. Activate the virtual environment\n```bash\nsource smart_meter_py_env/bin/activate\n```\n4. Upgrade pip and setuptools\n```bash\npython3 -m pip install --upgrade pip setuptools\n```\n5. Install smartplug-energy-controller\n```bash\npip install smartplug-energy-controller\n```\n6. Provide environment variables (e.g. in your ~/.profile).\n```bash\nCONFIG_PATH=full/path/to/config.yml\nSMARTPLUG_ENERGY_CONTROLLER_PORT=8000\n```\n\n## Configuration ##\nEverything is configured in the respective config.yml file. See https://github.com/die-bauerei/smartplug-energy-controller/blob/main/tests/data/config.example.yml \n\n## Autostart after reboot and on failure ##\nCreate a systemd service by opening the file */etc/systemd/system/smartplug_energy_controller.service* and copy paste the following contents. Replace User/Group/ExecStart accordingly. \n```bash\n[Unit]\nDescription=smartplug_energy_controller\nDocumentation=https://github.com/die-bauerei/smartplug-energy-controller\nAfter=network-online.target\n\n[Service]\nType=simple\nUser=ubuntu\nGroup=ubuntu\nUMask=002\nRestart=on-failure\nRestartSec=5s\nEnvironment=\"CONFIG_PATH=full/path/to/config.yml\"\nEnvironment=\"SMARTPLUG_ENERGY_CONTROLLER_PORT=8000\"\nExecStart=/usr/bin/bash -lc \"/home/ubuntu/smart_meter_py_env/bin/smartplug_energy_controller\"\n\n[Install]\nWantedBy=multi-user.target\n```\n\nNow execute the following commands to enable autostart:\n```bash\nsudo systemctl --system daemon-reload\nsudo systemctl enable smartplug_energy_controller.service\n```\n\nIt is now possible to start, stop, restart and check the status of smartplug-energy-controller with:\n```bash\nsudo systemctl start smartplug_energy_controller.service\nsudo systemctl stop smartplug_energy_controller.service\nsudo systemctl restart smartplug_energy_controller.service\nsudo systemctl status smartplug_energy_controller.service\n```\n\n## Usage of Tapo Smart Plugs ##\n\nThe service can control Tapo Smart Plugs via the plugp100 library (https://pypi.org/project/plugp100/).\nHave a look at the example config at https://github.com/die-bauerei/smartplug-energy-controller/blob/main/tests/data/config.example\n\n## Usage in conjunction with openHAB ##\n\nTo use this service you need to get the consumption values from your smart-meter. There are of course lots of different ways to achieve this.\nA possible setup could include:\n- Read data from your smart-meter and push them to openHAB:\n    - https://github.com/die-bauerei/smart-meter-to-openhab\n    - https://tibber.com/de/store/produkt/pulse-ir\n    - ...\n- Let openHAB send the requests to this service. \n\nThis project includes a service that performs this requests by using HABApp (https://github.com/spacemanspiff2007/HABApp)\n\nNOTE: Make sure to first start smartplug_energy_controller as this will setup the configuration for HABApp. \n\n*The service expects the smartplug_energy_controller API on http://localhost:$SMARTPLUG_ENERGY_CONTROLLER_PORT*\n\nCreate a systemd service */etc/systemd/system/oh_to_smartplug_energy_controller.service* to setup autostart for this service as well:\n```bash\n[Unit]\nDescription=Post smart meter values from openHAB to smartplug-energy-controller\nDocumentation=https://github.com/die-bauerei/smartplug-energy-controller\nAfter=smartplug_energy_controller.service\n\n[Service]\nType=simple\nUser=ubuntu\nGroup=ubuntu\nUMask=002\nRestart=on-failure\nRestartSec=5s\n#Provide environment variable (e.g. in your ~/.profile). Assignment example see above\nEnvironment=\"SMARTPLUG_ENERGY_CONTROLLER_PORT=8000\"\nExecStart=/usr/bin/bash -lc \"source /home/heiko/smart_meter_py_env/bin/activate \u0026\u0026 /home/ubuntu/smart_meter_py_env/bin/oh_to_smartplug_energy_controller\"\n\n[Install]\nWantedBy=multi-user.target\n```\n\nBy setting up a connection to your openHAB instance you can additionally use any Smart Plug you have configured inside your openHAB instance. \nHave a look at the example config at https://github.com/die-bauerei/smartplug-energy-controller/blob/main/tests/data/config.example \n\n## Troubleshooting ##\n\n- Have a look at the log-file you have given in your config.yml\n- Have a look at the HABApp log-file located in smart_meter_py_env/lib/python3.xx/site-packages/oh_to_smartplug_energy_controller/log/HABApp.log. \n\n## Development ##\nDevelopment is done in wsl2 on ubuntu 22.04.\nSetting up the development environment on Windows is not supported. But in principal it could be setup as well since no OS specific functionalities are used.\n\n### Setup ###\nThe project is using [poetry](https://python-poetry.org/) for managing packaging and resolve dependencies.\nTo install poetry call *install-poetry.sh*. This will install poetry itself as well as python and the required packages as a virtual environment in *.venv*.\nExample settings for development in VS Code are provided in *vscode-settings*. (Copy them to *.vscode* folder)\nFollow these [instructions](https://docs.pydantic.dev/latest/integrations/visual_studio_code/) to enable proper linting and type checking. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdie-bauerei%2Fsmartplug-energy-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdie-bauerei%2Fsmartplug-energy-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdie-bauerei%2Fsmartplug-energy-controller/lists"}