{"id":20498247,"url":"https://github.com/thenoim/offlineshelly","last_synced_at":"2025-08-24T14:32:42.698Z","repository":{"id":81490169,"uuid":"591777041","full_name":"TheNoim/OfflineShelly","owner":"TheNoim","description":" This project provides an ESPHome configuration to maintain control of Zigbee devices using a Shelly or similar device when offline. It ensures the device remains operational, even if Zigbee or WiFi connections are lost, by switching to a relay-based control method.","archived":false,"fork":false,"pushed_at":"2024-08-25T17:51:38.000Z","size":79,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-23T05:18:55.786Z","etag":null,"topics":["esphome","home-assistant","offline-first","shelly","smarthome","zha"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheNoim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-01-21T20:41:24.000Z","updated_at":"2024-10-23T18:43:15.000Z","dependencies_parsed_at":"2023-12-27T14:25:20.468Z","dependency_job_id":"1fcc02ac-d8d4-4661-b89b-b5d70ca5a390","html_url":"https://github.com/TheNoim/OfflineShelly","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TheNoim/OfflineShelly","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNoim%2FOfflineShelly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNoim%2FOfflineShelly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNoim%2FOfflineShelly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNoim%2FOfflineShelly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheNoim","download_url":"https://codeload.github.com/TheNoim/OfflineShelly/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNoim%2FOfflineShelly/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271887613,"owners_count":24839136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"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":["esphome","home-assistant","offline-first","shelly","smarthome","zha"],"created_at":"2024-11-15T18:13:33.936Z","updated_at":"2025-08-24T14:32:42.663Z","avatar_url":"https://github.com/TheNoim.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESPHome: Offline fallback mechanism to control Zigbee device via shelly\n\nIn this project, I provide an [ESPHome](https://esphome.io/)-based configuration to control a Zigbee device via a Shelly or similar device, while ensuring it remains operational offline.\n\n## What you need\n\n1. An ESPHome compatible device which has a switch and a relay\n2. Zigbee Device connected via [ZHA](https://www.home-assistant.io/integrations/zha/) in [Home Assistant](https://www.home-assistant.io/)\n3. Knowledge how to flash ESPHome\n4. The Zigbee device needs to turn on after power loss. Most lamps have this as their default configuration\n\n## How this works\n\nI created a flow diagram to design the fallback process:\n\n![Flow Diagram](assets/Flow%20Diagram.webp)\n\nTo explain it, when one of the following cases is true:\n\n- ESPHome device is no longer connected to Home Assistant\n- ZHA marked the Zigbee device as \"unavailable\"\n- Toggling the Zigbee device fails after 2s\n\nThen, we use the relay on the Shelly instead to control the device. If the device's last known state was on, we simply turn off the relay. If the last known state was off, we toggle the relay off and then back on. This approach ensures the device is in the expected state, even if Zigbee or WiFi stops working.\n\n## How to use\n\n```yaml your-esphome-config.yaml\n# {... Your esphome configuration}\n\npackages:\n    # Optional: Predefined base for a Shelly 1L only\n    Shelly1L:\n        url: https://github.com/TheNoim/OfflineShelly\n        files: [shelly-1l.yaml]\n        ref: \"1.0\" # Release tag you want to use\n        refresh: 1d\n    # Offline mechanism\n    OfflineShelly:\n        url: https://github.com/TheNoim/OfflineShelly\n        files: [offline-shelly.yaml]\n        ref: \"1.0\" # Release tag you want to use\n        refresh: 1d\n        # You can also use it for multiple devices: https://esphome.io/components/packages#packages-as-templates\n        # If you use multiple devices: The prefix needs to be different for each device. The relay can be the same\n        vars:\n            prefix: deckenlampe # Even if you don't want to control multiple device, you need to specify a prefix. It needs to follow the rules for an ESPHome id https://esphome.io/guides/configuration-types.html#config-id \n            zigbee_entity: light.arbeitszimmer_deckenlampe_light # Zigbee entity id in hass\n            relay_id: deviceid # ESPHome relay id. Needs to be a switch\n\nbinary_sensor:\n  - id: !extend switchid1 # ID from switch1\n    on_state:\n      then:\n        # Script name format: ${prefix}_toggle\n        script.execute: deckenlampe_toggle\n        # For multiple devices: just use a list and run script for each prefix\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenoim%2Fofflineshelly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenoim%2Fofflineshelly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenoim%2Fofflineshelly/lists"}