{"id":17592943,"url":"https://github.com/bieniu/ha-shellies-discovery-gen2","last_synced_at":"2026-06-09T19:00:30.787Z","repository":{"id":37986613,"uuid":"448031517","full_name":"bieniu/ha-shellies-discovery-gen2","owner":"bieniu","description":"Script that adds MQTT discovery support for Shellies Gen2+ devices","archived":false,"fork":false,"pushed_at":"2026-06-03T20:49:41.000Z","size":883,"stargazers_count":179,"open_issues_count":2,"forks_count":30,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-06-03T22:13:57.764Z","etag":null,"topics":["discovery","hacktoberfest","home-assistant","mqtt","python","python-script","shelly"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bieniu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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":"AGENTS.md","dco":null,"cla":null},"funding":{"custom":["https://www.paypal.me/bieniu79","https://www.buymeacoffee.com/QnLdxeaqO","https://revolut.me/maciejbieniek"]}},"created_at":"2022-01-14T16:20:38.000Z","updated_at":"2026-06-03T20:49:38.000Z","dependencies_parsed_at":"2026-02-19T22:03:46.840Z","dependency_job_id":null,"html_url":"https://github.com/bieniu/ha-shellies-discovery-gen2","commit_stats":null,"previous_names":[],"tags_count":128,"template":false,"template_full_name":null,"purl":"pkg:github/bieniu/ha-shellies-discovery-gen2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bieniu%2Fha-shellies-discovery-gen2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bieniu%2Fha-shellies-discovery-gen2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bieniu%2Fha-shellies-discovery-gen2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bieniu%2Fha-shellies-discovery-gen2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bieniu","download_url":"https://codeload.github.com/bieniu/ha-shellies-discovery-gen2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bieniu%2Fha-shellies-discovery-gen2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34121022,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["discovery","hacktoberfest","home-assistant","mqtt","python","python-script","shelly"],"created_at":"2024-10-22T05:44:19.602Z","updated_at":"2026-06-09T19:00:30.773Z","avatar_url":"https://github.com/bieniu.png","language":"Python","funding_links":["https://www.paypal.me/bieniu79","https://www.buymeacoffee.com/QnLdxeaqO","https://revolut.me/maciejbieniek"],"categories":[],"sub_categories":[],"readme":"[![CI](https://img.shields.io/github/actions/workflow/status/bieniu/ha-shellies-discovery-gen2/ci.yml?branch=master\u0026label=CI\u0026logo=github\u0026style=popout)](https://github.com/bieniu/ha-shellies-discovery-gen2/actions/workflows/ci.yml?query=branch%3Amaster)\n[![codecov](https://codecov.io/gh/bieniu/ha-shellies-discovery-gen2/graph/badge.svg?token=EWE6F3THLU)](https://codecov.io/gh/bieniu/ha-shellies-discovery-gen2)\n[![GitHub Release][releases-shield]][releases]\n[![GitHub All Releases][downloads-total-shield]][releases]\n[![Community Forum][forum-shield]][forum]\n[![Buy me a coffee][buy-me-a-coffee-shield]][buy-me-a-coffee]\n[![PayPal_Me][paypal-me-shield]][paypal-me]\n[![Revolut.Me][revolut-me-shield]][revolut-me]\n\n# Shellies Discovery Gen2\n\nThis script adds MQTT discovery support for Shelly Gen2, Gen3 and Gen4 devices in the [Home Assistant](https://home-assistant.io/).\n\n![image](https://user-images.githubusercontent.com/478555/151659020-a6181434-ae19-42bb-9dbe-fed8002ee730.png)\n\n## Prerequisites\n\nThis script needs Home Assistant `python_script` component so, if you never used it, I strongly suggest you to follow the [official instruction](https://www.home-assistant.io/integrations/python_script#writing-your-first-script) and check that `python_script` is properly configured and it's working.\n\nFor the device to work with the script, it must have MQTT configured and options **Enable \"MQTT Control\"**, **RPC status notifications over MQTT** and **Generic status update over MQTT** enabled.\n\nMQTT integration must be configured in Home Assistant.\n\n## Installation\n\nYou can download `shellies_discovery_gen2.py` file and save it in `\u003cconfig\u003e/python_scripts` folder or install the script via [HACS](https://hacs.xyz/).\nYou won't find **Shellies Discovery Gen2** in the HACS **Integrations** section, nor add it as a custom repository. You must have a properly configured `python_script` component to be able to install the script from the HACS **Automations** section.\n\nShellies Discovery Gen2 will automatically install/update the script on your Shelly device. Due to `python_scripts` integration limitations, updating the device script requires the `announce` automation to run twice.\n\nYou need to manually add the `shellies_announce_gen2`, `shellies_discovery_gen2` automations and the `shellies_components_gen2` script to your `automations.yaml` and `scripts.yaml` files.\n\n\u003e [!IMPORTANT]\n\u003e You cannot manually run the **Shellies Discovery** automation. You can only manually run the **Shellies Announce** automation to begin the device configuration process.\n\n## Supported devices\n\n### Gen2\n\n- Shelly BLU Gateway\n- Shelly Plus 0-10V Dimmer\n- Shelly Plus 1\n- Shelly Plus 1 Mini\n- Shelly Plus 1PM\n- Shelly Plus 1PM Mini\n- Shelly Plus 2PM\n- Shelly Plus Add-on\n- Shelly Plus H\u0026T\n- Shelly Plus i4\n- Shelly Plus Plug IT\n- Shelly Plus Plug S\n- Shelly Plus Plug UK\n- Shelly Plus Plug US\n- Shelly Plus PM Mini\n- Shelly Plus RGBW PM (RGBW profile is not supported)\n- Shelly Plus Smoke\n- Shelly Plus Uni\n- Shelly Plus Wall Dimmer\n- Shelly Pro 1\n- Shelly Pro 1PM\n- Shelly Pro 2\n- Shelly Pro 2PM\n- Shelly Pro 3\n- Shelly Pro 3EM\n- Shelly Pro 3EM Switch Add-on\n- Shelly Pro 3EM-3CT63\n- Shelly Pro 3EM-400\n- Shelly Pro 4PM\n- Shelly Pro Dimmer 2\n- Shelly Pro Dual Cover PM\n- Shelly Pro EM\n- Shelly Wall Display\n- Shelly Wall Display X1i\n- Shelly Wall Display X2\n\n### Gen3\n\n- Shelly 1 Gen3\n- Shelly 1L Gen3\n- Shelly 1 Mini Gen3\n- Shelly 1PM Gen3\n- Shelly 1PM Mini Gen3\n- Shelly 2L Gen3\n- Shelly 2PM Gen3\n- Shelly 3EM-63 Gen3\n- Shelly AZ Plug\n- Shelly BLU Gateway Gen3\n- Shelly DALI Dimmer Gen3\n- Shelly Dimmer 0/1-10V PM Gen3\n- Shelly Dimmer Gen3\n- Shelly Duo Bulb Gen3\n- Shelly EM Gen3\n- Shelly H\u0026T Gen3\n- Shelly i4 Gen3\n- Shelly Outdoor Plug S Gen3\n- Shelly Plug M Gen3\n- Shelly Plug PM Gen3\n- Shelly Plug S Gen3\n- Shelly PM Mini Gen3\n- Shelly X MOD1\n\n### Gen4\n\n- Shelly 1 Gen4\n- Shelly 1 Mini Gen4\n- Shelly 1PM Gen4\n- Shelly 1PM Mini Gen4\n- Shelly 2PM Gen4\n- Shelly EM Mini Gen4\n- Shelly i4 Gen4\n- Shelly Flood Gen4\n- Shelly Flood S Gen4\n- Shelly Plug US Gen4\n- Shelly Power Strip Gen4\n- Shelly Presence Gen4\n\n### BLU\n\n- Shelly BLU Button1 (via Shelly Pro or Gen3+ device)\n- Shelly BLU H\u0026T (via Shelly Pro or Gen3+ device)\n- Shelly BLU H\u0026T ZB (via Shelly Pro or Gen3+ device)\n- Shelly BLU H\u0026T Display ZB (via Shelly Pro or Gen3+ device)\n- Shelly BLU Motion (via Shelly Pro or Gen3+ device)\n- Shelly BLU RC Button 4 (via Shelly Pro or Gen3+ device)\n- Shelly BLU RC Button 4 ZB (via Shelly Pro or Gen3+ device)\n- Shelly BLU TRV (via Shelly BLU Gateway Gen3)\n- Shelly BLU Wall Switch 4 (via Shelly Pro or Gen3+ device)\n\n### Powered by Shelly\n\n- FrankEver Smart Water Valve\n- LinkedGo Smart Thermostat ST1820\n- LinkedGo Smart Thermostat ST802-B\n- Ogemray 25A Smart Switch\n- TopAC EVE01-11R\n\n## Battery powered devices\n\nBattery powered devices like Plus H\u0026T are put to sleep most of the time. For this reason, adding/updating entities configuration for a device should be done as follows:\n\n- enter the device into setup mode (press the button on the device)\n- manually run `Shellies Announce Gen2` automation\n\n## Virtual components\n\nShellies Discovery supports the following virtual Shelly components:\n\n- `boolean` with mode `label`\n- `boolean` with mode `toggle`\n- `button`\n- `enum` with mode `dropdown`\n- `enum` with mode `label`\n- `number` with mode `label`\n- `number` with mode `slider`\n- `text` with mode `label`\n\n## How to debug\n\nTo debug the script add this to your `logger` configuration:\n\n```yaml\n# configuration.yaml file\nlogger:\n  default: error\n  logs:\n    homeassistant.components.python_script: debug\n    homeassistant.components.automation: info\n    homeassistant.components.mqtt.discovery: info\n```\n\n## Supported platforms\n\n- binary sensor\n- button\n- climate\n- cover\n- device trigger\n- event\n- fan\n- light\n- number\n- sensor\n- switch\n- update\n\n## Supported features\n\n- the device name is taken from the device configuration\n- the relay name is taken from the device configuration\n- the relay consumption type is taken from the device configuration (consumption type must contain `light` or `fan` to configure light or fan platform)\n- if the input type is set to button, device automation triggers are available\n- custom MQTT prefixes are supported\n\n## Script arguments\n\nkey | optional | type | default | description\n-- | -- | -- | -- | --\n`discovery_prefix` | True | string | `homeassistant` | MQTT discovery prefix\n`script_prefix` | True | string | | MQTT prefix to install the script in the device\n`qos` | True | integer | `0` | MQTT QoS, you can use `0`, `1` or `2`\n\n## Configuration\n\n```yaml\n# configuration.yaml file\npython_script:\n\n# automations.yaml file\n- id: shellies_announce_gen2\n  alias: \"Shellies Announce Gen2\"\n  triggers:\n    - trigger: homeassistant\n      event: start\n  variables:\n    get_config_payload: \"{{ {'id': 1, 'src': 'shellies_discovery', 'method': 'Shelly.GetConfig'} | to_json }}\"\n    device_ids:  # enter the list of device IDs (MQTT prefixes) here\n      - shellyplus2pm-485519a1ff8c\n      - custom-prefix/shelly-kitchen\n  actions:\n    - repeat:\n        for_each: \"{{ device_ids }}\"\n        sequence:\n          - action: mqtt.publish\n            data:\n              topic: \"{{ repeat.item }}/rpc\"\n              payload: \"{{ get_config_payload }}\"\n          - action: script.shellies_components_gen2\n            data:\n              device_topic: \"{{ repeat.item }}\"\n\n- id: shellies_discovery_gen2\n  alias: \"Shellies Discovery Gen2\"\n  mode: queued\n  max: 50\n  triggers:\n    - trigger: mqtt\n      topic: shellies_discovery/rpc\n  actions:\n    - condition: template\n      value_template: \"{{ 'components' not in (trigger.payload_json.result | default({})) }}\"\n    - action: python_script.shellies_discovery_gen2\n      data:\n        id: \"{{ trigger.payload_json.src }}\"\n        device_config: \"{{ trigger.payload_json.result }}\"\n    - condition: template\n      value_template: \"{{ 'mqtt' in trigger.payload_json.result }}\"\n    - action: mqtt.publish\n      data:\n        topic: \"{{ trigger.payload_json.result.mqtt.topic_prefix }}/command\"\n        payload: \"status_update\"\n\n# scripts.yaml file\nshellies_components_gen2:\n  alias: Shellies Components Gen2\n  mode: queued\n  max: 50\n  fields:\n    device_topic:\n      description: MQTT topic prefix for the device, e.g. shellies/shelly-1-gen4-abc123\n      required: true\n    discovery_prefix:\n      description: MQTT discovery prefix\n      default: homeassistant\n  sequence:\n    - variables:\n        device_name: \"{{ device_topic.split('/') | last }}\"\n        src: shellies_discovery/{{ device_topic.split('/') | last }}\n        response_topic: shellies_discovery/{{ device_topic.split('/') | last }}/rpc\n        all_pages: []\n        offset: 0\n        total: 1\n        device_id: \"{{ device_topic.split('/') | last }}\"\n    - repeat:\n        while:\n          - condition: template\n            value_template: \"{{ offset \u003c total }}\"\n        sequence:\n          - action: mqtt.publish\n            data:\n              topic: \"{{ device_topic }}/rpc\"\n              payload: \"{{ {'id': 1, 'src': src, 'method': 'Shelly.GetComponents', 'params': {'include': ['config'], 'offset': offset}} | to_json }}\"\n          - wait_for_trigger:\n              - trigger: mqtt\n                topic: \"{{ response_topic }}\"\n            timeout: \"00:00:30\"\n          - if:\n              - condition: template\n                value_template: \"{{ wait.trigger is none }}\"\n            then:\n              - stop: Timeout waiting for Shelly.GetComponents from {{ device_topic }}\n          - variables:\n              page: \"{{ wait.trigger.payload_json.result }}\"\n              device_id: \"{{ wait.trigger.payload_json.src }}\"\n          - variables:\n              all_pages: \"{{ all_pages + [page] }}\"\n              offset: \"{{ page.offset + (page.components | length) }}\"\n              total: \"{{ page.total }}\"\n    - action: python_script.shellies_discovery_gen2\n      data:\n        id: \"{{ device_id }}\"\n        device_config:\n          components: \"{{ all_pages }}\"\n        discovery_prefix: \"{{ discovery_prefix }}\"\n    - variables:\n        all_components: \"{{ all_pages | map(attribute='components') | list | flatten }}\"\n    - variables:\n        mqtt_comp: \"{{ all_components | selectattr('key', 'equalto', 'mqtt') | list | first | default(none) }}\"\n    - condition: template\n      value_template: \"{{ mqtt_comp is not none }}\"\n    - action: mqtt.publish\n      data:\n        topic: \"{{ mqtt_comp.config.topic_prefix }}/command\"\n        payload: status_update\n```\n\n[releases]: https://github.com/bieniu/ha-shellies-discovery-gen2/releases\n[releases-shield]: https://img.shields.io/github/release/bieniu/ha-shellies-discovery-gen2.svg?style=popout\n[downloads-total-shield]: https://img.shields.io/github/downloads/bieniu/ha-shellies-discovery-gen2/total\n[forum]: https://community.home-assistant.io/t/shellies-discovery-gen2-script/384479\n[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg?style=popout\n[buy-me-a-coffee-shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=Buy%20me%20a%20coffee\u0026color=6f4e37\u0026logo=buy%20me%20a%20coffee\u0026logoColor=white\n[buy-me-a-coffee]: https://www.buymeacoffee.com/QnLdxeaqO\n[paypal-me-shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=PayPal.Me\u0026logo=paypal\n[paypal-me]: https://www.paypal.me/bieniu79\n[revolut-me-shield]: https://img.shields.io/static/v1.svg?label=%20\u0026message=Revolut\u0026logo=revolut\n[revolut-me]: https://revolut.me/maciejbieniek\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbieniu%2Fha-shellies-discovery-gen2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbieniu%2Fha-shellies-discovery-gen2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbieniu%2Fha-shellies-discovery-gen2/lists"}