{"id":13495874,"url":"https://github.com/AlexxIT/SonoffLAN","last_synced_at":"2025-03-28T17:34:08.908Z","repository":{"id":37437170,"uuid":"222118751","full_name":"AlexxIT/SonoffLAN","owner":"AlexxIT","description":"Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant","archived":false,"fork":false,"pushed_at":"2024-10-27T04:46:06.000Z","size":4419,"stargazers_count":2695,"open_issues_count":122,"forks_count":414,"subscribers_count":101,"default_branch":"master","last_synced_at":"2024-10-27T05:38:15.459Z","etag":null,"topics":["ewelink","hacs","home-assistant","sonoff"],"latest_commit_sha":null,"homepage":"https://github.com/AlexxIT/Blog","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexxIT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2019-11-16T15:26:43.000Z","updated_at":"2024-10-27T04:46:10.000Z","dependencies_parsed_at":"2023-12-03T10:25:03.585Z","dependency_job_id":"786c9207-b153-4abc-b6c3-542e5acf9af1","html_url":"https://github.com/AlexxIT/SonoffLAN","commit_stats":{"total_commits":736,"total_committers":60,"mean_commits":"12.266666666666667","dds":"0.15353260869565222","last_synced_commit":"14f6db98fea41c7f5f3fbecbc87b91a2a4e1d702"},"previous_names":[],"tags_count":78,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexxIT%2FSonoffLAN","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexxIT%2FSonoffLAN/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexxIT%2FSonoffLAN/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexxIT%2FSonoffLAN/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexxIT","download_url":"https://codeload.github.com/AlexxIT/SonoffLAN/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222059042,"owners_count":16924150,"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","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":["ewelink","hacs","home-assistant","sonoff"],"created_at":"2024-07-31T19:01:39.137Z","updated_at":"2025-03-28T17:34:08.901Z","avatar_url":"https://github.com/AlexxIT.png","language":"Python","funding_links":[],"categories":["Python","Install from Source","Custom Integrations"],"sub_categories":["Smart Home Automation","Alternative Dashboards"],"readme":"# Control Sonoff Devices from Home Assistant\n\n[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/hacs/integration)\n\nHome Assistant custom component for control [Sonoff](https://www.itead.cc/) devices with [eWeLink](https://www.ewelink.cc/en/) (original) firmware over LAN and/or Cloud.\n\n**New features in version 3.0**\n\n- support Integration UI, Devices and Zones\n- support new [eWeLink API](https://coolkit-technologies.github.io/eWeLink-API/#/en/PlatformOverview)\n- support [multiple eWeLink accounts](#configuration) and [homes](#homes)\n- support many sensors for each device (include [RFBridge](#sonoff-rf-bridge-433))\n- support thermostats for [Sonoff TH](#sonoff-th) ans NS Panel\n- support [preventing DB size growth](#preventing-db-size-growth)\n- support many new Hass features\n\n**Features from previous versions**\n\n- can manage **both local and cloud control at the same time**!\n- support old devices wih 2.7 firmware (only cloud connection)\n- support new device types: color lights, sensors, covers\n- support [eWeLink cameras](#sonoff-gk-200mp2-b-camera) with PTZ\n- support unavailable device state for both local and cloud connection\n- support sensors for Sonoff [RF Bridge 433](#sonoff-rf-bridge-433)\n- support ZigBee Bridge and Devices\n- added new [debug mode](#debug-page) for troubleshooting\n\n**Pros**\n\n- work with original eWeLink / Sonoff firmware, no need to flash devices\n- work over Local Network and/or Cloud Server\n- work with devices without DIY-mode\n- work with devices in DIY-mode\n- support single and multi-channel devices\n- support TH and Pow device sensors\n- support Sonoff [RF Bridge 433](#sonoff-rf-bridge-433) for receive and send commands\n- support Sonoff [GK-200MP2-B Camera](#sonoff-gk-200mp2-b-camera)\n- instant device state update with local Multicast or cloud Websocket connection\n- load devices list from eWeLink Servers (with names and encryption keys) and save it locally\n- (optional) change [device type](#custom-device_class) from `switch` to `light`\n\n**Component review from DrZzs**\n\n[![Sonoffs can work with Home Assistant without changing the Firmware!](https://img.youtube.com/vi/DsTqOlrQQ1k/mqdefault.jpg)](https://www.youtube.com/watch?v=DsTqOlrQQ1k)\n\nThere is another great component by [@peterbuga](https://github.com/peterbuga/HASS-sonoff-ewelink), that works with cloud servers.\n\nThanks to [@beveradb](https://github.com/beveradb/sonoff-lan-mode-homeassistant) and [@mattsaxon](https://github.com/mattsaxon/sonoff-lan-mode-homeassistant) for researching the local Sonoff protocol.\nThanks to [@michthom](https://github.com/michthom) and [@EpicLPer](https://github.com/EpicLPer) for researching the local Sonoff Camera protocol.\n\n## Tested Devices\n\nAlmost any single or multi-channel Switch working in the eWeLink application will work with this Integration even if it is not on the list.\n\n**Tested (LAN and Cloud)**\n\nThese devices work both on a local network and through the cloud.\n\n- Sonoff Basic, [BASICR2](https://itead.cc/product/sonoff-basicr2/), [BASICR3](https://itead.cc/product/sonoff-basicr3-wifi-diy-smart-switch/), [RFR2](https://itead.cc/product/sonoff-rf/), [RFR3](https://itead.cc/product/sonoff-rfr3/)\n- [Sonoff Mini/MINIR2](https://itead.cc/product/sonoff-mini/), [MINI R3](https://itead.cc/product/sonoff-minir3-smart-switch/) (no need use DIY-mode)\n- [Sonoff Micro](https://itead.cc/product/sonoff-micro-5v-usb-smart-adaptor/)\n- [Sonoff TH10/TH16](https://itead.cc/product/sonoff-th/) (support Thermostat)\n- Sonoff 4CH, 4CHR2, [4CHR3 \u0026 4CHPROR3](https://itead.cc/product/sonoff-4ch-r3-pro-r3/)\n- Sonoff [POWR2](https://itead.cc/product/sonoff-pow-r2/) (show power consumption)\n- [Sonoff DUALR3/DUALR3 Lite](https://itead.cc/product/sonoff-dualr3/)\n- [Sonoff RF Bridge 433](https://www.itead.cc/sonoff-rf-bridge-433.html) (receive and send commands) fw 3.5.0\n- [Sonoff D1](https://www.itead.cc/sonoff-d1-smart-dimmer-switch.html) (dimmer with brightness control) fw 3.4.0, 3.5.0\n- [Sonoff G1](https://www.itead.cc/sonoff-g1.html) fw 3.5.0\n- [Sonoff Dual](https://www.itead.cc/sonoff-dual.html)\n- Sonoff iFan02, iFan03, [iFan04](https://www.itead.cc/sonoff-ifan03-wifi-ceiling-fan-light-controller.html) (light and fan with speed control) fw 3.4.0\n- Sonoff S20, [S26](https://itead.cc/product/sonoff-s26-wifi-smart-plug/), [S31](https://itead.cc/product/sonoff-s31/), [S40](https://itead.cc/product/sonoff-iplug-series-wi-fi-smart-plug-s40-s40-lite/) fw 1.3, 1.4, [S55](https://itead.cc/product/sonoff-s55/) \n- [Sonoff SV](https://www.itead.cc/sonoff-sv.html) fw 3.0.1\n- Sonoff T1, [TX Series](https://itead.cc/product/sonoff-tx-series-wifi-smart-wall-switches/)\n- [Sonoff T4EU1C](https://www.itead.cc/sonoff-t4eu1c-wi-fi-smart-single-wire-wall-switch.html)\n- [Sonoff IW100/IW101](https://www.itead.cc/sonoff-iw100-iw101.html)\n- [Sonoff Slampher R2](https://www.itead.cc/sonoff-slampher-r2.html)\n- [Sonoff 5V DIY](https://www.aliexpress.com/item/32818293817.html)\n- [Sonoff RE5V1C](https://www.itead.cc/sonoff-re5v1c.html)\n- [Sonoff NSPanel](https://itead.cc/product/sonoff-nspanel-smart-scene-wall-switch/)\n- [MiniTiger Wall Switch](https://www.aliexpress.com/item/33016227381.html) (I have 8 without zero-line) fw 3.3.0\n- [Smart Circuit Breaker](https://www.aliexpress.com/item/4000454408211.html), [link](https://www.aliexpress.com/item/4000351300288.html), [link](https://www.aliexpress.com/item/4000077475264.html)\n- [Smart Timer Switch](https://www.aliexpress.com/item/4000189016383.html)\n- [Eachen WiFi Smart Touch](https://ewelink.eachen.cc/product/eachen-single-live-wall-switch-us-ac-l123ewelink-app/) fw 3.3.0\n\n**Tested (only Cloud)**\n\nThese devices only work through the cloud!\n\n- Sonoff POW (first) fw 2.6.1\n- [Sonoff L1](https://www.itead.cc/sonoff-l1-smart-led-light-strip.html) (color, brightness, effects) fw 2.7.0\n- [Sonoff L2](https://sonoff.tech/product/smart-lighting/l2/) fw 1000.2.1050\n- [Sonoff B1](https://www.itead.cc/sonoff-b1.html) (color, brightness, color temp) fw 2.6.0\n- Sonoff B02, B05-B, B05-BL\n- [Sonoff SC](https://www.itead.cc/sonoff-sc.html) (five sensors) fw 2.7.0\n- [Sonoff DW2](https://www.itead.cc/sonoff-dw2.html)\n- [Sonoff SwitchMan R5](https://itead.cc/product/sonoff-switchman-scene-controller-r5/)\n- [Sonoff S-MATE](https://sonoff.tech/product/diy-smart-switch/s-mate/)\n- [Sonoff S40](https://itead.cc/product/sonoff-iplug-series-wi-fi-smart-plug-s40-s40-lite/) fw 1.1\n- [King Art - King Q4 Cover](https://www.aliexpress.com/item/32956776611.html) (pause, position) fw 2.7.0\n- [KING-M4](https://www.aliexpress.com/item/33013358523.html) (brightness) fw 2.7.0\n- [Eachen WiFi Door/Window Sensor](https://ewelink.eachen.cc/product/eachen-wifi-smart-door-window-sensor-wdw-ewelink/)\n- [Essential Oils Diffuser](https://www.amazon.co.uk/dp/B07WF7MQ17) (fan and color light) fw 2.9.0\n- [Smart USB Mosquito Killer](https://www.aliexpress.com/item/33037963105.html)\n- [Smart Bulb RGB+CCT](https://www.aliexpress.com/item/4000764330397.html)\n\n**Tested ZigBee (only Cloud)**\n\n- [Sonoff ZigBee Bridge](https://www.itead.cc/sonoff-zbbridge.html) - turn on for pairing mode\n- SONOFF SNZB-01 - Zigbee Wireless Switch\n- SONOFF SNZB-02 - ZigBee Temperature and Humidity Sensor\n- SONOFF SNZB-03 - ZigBee Motion Sensor\n- SONOFF SNZB-04 - ZigBee Wireless door/window sensor\n\n**Tested Cameras (only LAN)**\n\nMaybe other eWeLink cameras also work, I don’t know.\n\n- [Camera GK-100CD10B](https://www.gearbest.com/smart-home-controls/pp_009678072743.html) (camera with PTZ)\n- [Sonoff GK-200MP2-B](https://www.itead.cc/sonoff-gk-200mp2-b-wi-fi-wireless-ip-security-camera.html) (camera with PTZ)\n\n## Installation\n\n[HACS](https://hacs.xyz/) \u003e Integrations \u003e Plus \u003e **SonoffLAN**\n\nOr manually copy `sonoff` folder from [latest release](https://github.com/AlexxIT/SonoffLAN/releases/latest) to `custom_components` folder in your config folder.\n\n## Configuration\n\nConfiguration \u003e [Integrations](https://my.home-assistant.io/redirect/integrations/) \u003e Add Integration \u003e [Sonoff](https://my.home-assistant.io/redirect/config_flow_start/?domain=sonoff)\n\n*If the integration is not in the list, you need to clear the browser cache.*\n\nYou can setup multiple integrations with different ewelink accounts.\n\n**Important**. If you use the same account in different smart home systems, you will be constantly unlogged from everywhere. In this case, you need to create a second ewelink account and share your devices or home with it.\n\n- Problems: another Home Assistant, Homebridge, [eWeLink addon](https://www.ewelink.cc/en/2021/06/23/ewelink-home-assistant-add-on-github-archive/), etc.\n- No Problems: latest [eWeLink mobile app v4+](https://www.ewelink.cc/en/)\n\n## Issues\n\nBefore posting new issue:\n\n1. Check the number of online devices on the [System Health page](https://my.home-assistant.io/redirect/system_health)\n2. Check warning and errors on the [Logs page](https://my.home-assistant.io/redirect/logs/)\n3. Check **debug logs** on the [Debug page](#debug-page) (must be enabled in integration options)\n4. Check **open and closed** [issues](https://github.com/AlexxIT/SonoffLAN/issues?q=is%3Aissue)\n5. Share integration [diagnostics](https://www.home-assistant.io/integrations/diagnostics/) (supported from Hass v2022.2):\n\n- All devices: Configuration \u003e [Integrations](https://my.home-assistant.io/redirect/integrations/) \u003e **Sonoff** \u003e 3 dots \u003e Download diagnostics\n- One device: Configuration \u003e [Devices](https://my.home-assistant.io/redirect/devices/) \u003e Device \u003e Download diagnostics\n\n*There is no private data, but you can delete anything you think is private.*\n\n## Configuration UI\n\nConfiguration \u003e [Integrations](https://my.home-assistant.io/redirect/integrations/) \u003e **Sonoff** \u003e Configure\n\n### Mode\n\nIn `auto` mode component using both local and cloud connections to your devcies. If device could be reached via LAN - the local connection will be used. Otherwise the cloud connection will be used.\n\n`local` mode or `cloud` mode will use only this type of connection.\n\nSometimes it can be difficult to get a local connection to work. You need a local network with working Multicast (mDNS/[zeroconf](https://www.home-assistant.io/integrations/zeroconf/)) traffic between the Hass and your devices. Read about [common problems](#common-problems-in-only-lan-mode).\n\nEach time the integration starts, a list of user devices is loaded from cloud and saved locally (`/config/.storage/sonoff/`).\n\n`auto` mode and `local` mode can work without Internet connection. If the integration fails to connect to the cloud - the component will use the previously saved list of devices and continue to work only in `local` mode. `auto` mode will continue trying to connect to the cloud.\n\n`local` mode can't work without ewelink credentials because it needs devices encryption keys.\n\nDevices in DIY mode can be used without ewelink credentials because their protocol unencrypted.\n\nIt is **highly recommended** that you use `mode: auto` and do not use `mode: local` or DIY mode. Because the local protocol is not always stable and you will get a bad experience. Devices may sometimes disappear from the network or fail to respond to local requests. Also some POW and TH devices cannot update their sensors without a cloud connection.\n\n### Debug page\n\nEnable debug page in integration options. Reload integrations page. Open: Integraion \u003e Menu \u003e Known issues.\n\nDebug page shows only integration logs and removes some private data. You can filter log and enable auto refresh (in seconds).\n\n```\nhttp://192.168.1.123:8123/api/sonoff/c8503fee-88fb-4a18-84d9-abb782bf0aa7?q=1000xxxxxx\u0026r=2\n```\n\n### Homes\n\nBy default component loads cloud devices **only for current active Home** in ewelink application. If there is only one Home in the account, it shouldn't be a problem. Otherwise you can select one or multiple Homes to load devices from.\n\n## Configuration YAML\n\nThese settings are made via [YAML](https://www.home-assistant.io/docs/configuration/).\n\n**Important**. DeviceID is always 10 symbols string from entity_id or eWeLink app.\n\n### Custom device_class\n\nYou can convert all switches into light by default:\n\n```yaml\nsonoff:\n  default_class: light  # (optional), default switch\n```\n\nYou can convert specific switches into `light`, `fan` or `binary_sensor`:\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      device_class: light\n      name: Sonoff Basic\n    1000yyyyyy:\n      device_class: fan\n      name: Sonoff Mini\n```\n\nYou can convert multi-channel devices (e.g. Sonoff T1 2C):\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      device_class: [light, fan]\n      name: Sonoff T1 2C\n    1000yyyyyy:\n      device_class: [switch, light]\n      name: MiniTiger 2CH\n```\n\nYou can convert multi-channel device (e.g. Sonoff T1 3C) into single light with brightness control:\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      device_class:\n        - light: [1, 2, 3]\n      name: Sonoff T1 3C\n```\n\nYou can control multiple light zones with single multi-channel device (e.g. Sonoff 4CH):\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      device_class:\n        - switch: 1  # entity 1 (channel 1)\n        - light: [2, 3]  # entity 2 (channels 2 and 3)\n        - fan: 4  # entity 3 (channel 4)\n      name: Sonoff 4CH\n```\n\nYou can change `device_class` for [Binary Sensor](https://www.home-assistant.io/integrations/binary_sensor/):\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      device_class: window\n```\n\nYou can change `device_class` for [Cover](https://www.home-assistant.io/integrations/cover/):\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      device_class: shutter\n```\n\nYou can set the `uiid` when running in DIY mode to enable the device features. More info [here](https://github.com/AlexxIT/SonoffLAN/blob/master/custom_components/sonoff/core/devices.py).\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      extra: { uiid: 136 }  # Sonoff B05-BL\n```\n\n### Custom devices\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      name: Device name from YAML  # optional rewrite device name\n      host: 192.168.1.123  # optional force device IP-address\n      devicekey: xxx  # optional encription key (downloaded automatically from the cloud)\n```\n\n### Custom sensors\n\nIf you want some additional device attributes as sensors:\n\n```yaml\nsonoff:\n  sensors: [staMac, bssid, host]\n```\n\n### Force update\n\nYou can request actual device state and all its sensors manually at any time using `homeassistant.update_entity` service. Use it with any device entity except sensors. Use it with only one entity from each device.\n\nAs example, you can create an automation for forced temperature updates for Sonoff TH:\n\n```yaml\ntrigger:\n  - platform: time_pattern\n    minutes: '3'\naction:\n  - service: homeassistant.update_entity\n    target:\n      entity_id: switch.sonoff_1000xxxxxx\n```\n\n### Preventing DB size growth\n\nPow devices may send a lot of data every second. You can reduce the amount of processed data.\n\nFor multi-channel devices use `power_1`, `current_2`, etc.\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      reporting:\n        power: [30, 3600, 1]  # min seconds, max seconds, min delta value\n        current: [5, 3600, 0.1]\n        voltage: [60, 3600, 5]\n```\n\n- if new value came before `min seconds` - it will be \"delayed\"\n- if new value came between `min` and `max seconds`\n  - if delta lower than `delta value` - it will be \"delayed\"\n  - otherwise - it will be used\n- if new value came after `max seconds` - it will be used\n- any used value will erase \"delayed\" value\n- new \"delayed\" value will overwrite old one\n- \"delayed\" value will be checked for the above conditions every 30 seconds\n\n## Sonoff Pow\n\nSupport `power`, `current` and `voltage` sensors via LAN and Cloud connections. Also support energy (consumption) sensor only with **Cloud** connection.\n\nMany models of Sonoff power devices DON'T send `power`, `current` and `voltage`  by default. You need to ASK these devices to send this data. This can ONLY be done through a cloud-based request. The mobile app does it. And the integration does it (only in the `auto` and `cloud` modes).\n\nBy default `energy` data loads from cloud every hour. You can change interval via YAML and add history data to sensor attributes (max size - 30 days, disable - 0). For multi-channel devices use `energy_1`, `energy_2`.\n\n```yaml\nsonoff:\n  devices:\n    1000xxxxxx:\n      reporting:\n        energy: [3600, 10]  # update interval (seconds), history size (days)\n\ntemplate:\n  - sensor:\n      - name: \"10 days consumpion\"\n        unit_of_measurement: \"kWh\"\n        state: \"{{ (state_attr('sensor.sonoff_1000xxxxxx_energy', 'history') or [])|sum }}\"\n```\n\nYou can also setup a [integration sensor](https://www.home-assistant.io/integrations/integration/#energy), that will collect energy data locally by Hass:\n\n```yaml\nsensor:\n  - platform: integration\n    source: sensor.sonoff_1000xxxxxx_power\n    name: energy_spent\n    unit_prefix: k\n    round: 2\n```\n\n## Sonoff TH\n\nSupport optional [Climate](https://www.home-assistant.io/integrations/climate/) entity that controls Thermostat. You can control low and high temperature values and hvac modes:\n\n- **heat** - lower temp enable switch, higher temp disable switch\n- **cool** - lower temp disable switch, higher temp enable switch\n- **dry** - change control by **humidity** with previous low/high switch settings\n\nIn `dry` mode, the Thermostat controls and displays Humidity. But the units are displayed as temperature (Hass limitation).\n\nThermostat can be controlled only with **Cloud** connection. Main switch and TH sensors support LAN and Cloud connections.\n\n## Sonoff RF Bridge 433\n\nRF Bridge support learning up to 64 signals (16 x 4 buttons).\n\n**Video HOWTO from @KPeyanski**\n\n[![Automatic Calls and Messages from Home Assistant, Sonoff RF Bridge and Smoke Detectors](https://img.youtube.com/vi/QD1K7s01cak/mqdefault.jpg)](https://www.youtube.com/watch?v=QD1K7s01cak?t=284)\n\n**Important**. Integration v3 supports automatic creation of sensors for RF Bridge. All **buttons** will be created as [Button entity](https://www.home-assistant.io/integrations/button/). All **alarms** will be created as [Binary sensor](https://www.home-assistant.io/integrations/binary_sensor/).\n\nBoth button and binary sensor has `last_triggered` attribute with the time of the last signal received. You can use it in automations.\n\nBinary sensor will stay in `on` state during **120 seconds** by default. Each new signal will reset the timer. Binary sensor support restore state between Hass restarts.\n\nIf you has door sensor with two states (for open and for closed state) like [this one](https://www.banggood.com/10Pcs-GS-WDS07-Wireless-Door-Magnetic-Strip-433MHz-for-Security-Alarm-Home-System-p-1597356.html?cur_warehouse=CN), you can config `payload_off` as in the example below. Also disable the timeout if you do not need it in this case (with `timeout: 0` option).\n\nYou can use any `device_class` that is supported in [Binary Sensor](https://www.home-assistant.io/integrations/binary_sensor/). With `device_class: button` you can convert sensor to button.\n\n**PIR Sensor**\n\n```yaml\nsonoff:\n  rfbridge:\n    PIR Sensor 1:  # button/alarm name in eWeLink application\n      device_class: motion\n      timeout: 60  # optional (default 120), timeout in seconds for auto turn off\n```\n\n**Single State Sensor**\n\n```yaml\nsonoff:\n  rfbridge:\n    Door Sensor 1:  # button/alarm name in eWeLink application\n      name: Door Sensor  # optional, you can change sensor name\n      device_class: door  # e.g. door, window\n      timeout: 5\n```\n\n**Dual State Sensor**\n\n```yaml\nsonoff:\n  rfbridge:\n    Sensor1:  # button/alarm name in eWeLink application (open signal)\n      name: Window Sensor  # optional, you can change sensor name\n      device_class: window  # e.g. door, window\n      timeout: 0  # disable auto close timeout\n      payload_off: Sensor2  # button/alarm name in eWeLink application (close signal)\n```\n\nYou can read more about using this bridge in [wiki](https://github.com/AlexxIT/SonoffLAN/wiki/RF-Bridge).\n\n## Sonoff GK-200MP2-B Camera\n\nCurrently only PTZ commands are supported. Camera entity is not created now.\n\nYou can send `left`, `right`, `up`, `down` commands with `sonoff.send_command` service:\n\n```yaml\nscript:\n  left:\n    sequence:\n      - service: sonoff.send_command\n        data:\n          device: '012345'  # use quotes, this is important\n          cmd: left\n```\n\n`device` - this is the number from the camera ID `EWLK-012345-XXXXX`, exactly 6 digits (leading zeros - it is important).\n\n## Common problems in only LAN mode\n\n`auto` mode and `cloud` mode users don't have these problems.\n\n**Devices are not displayed**\n\n- not all devices supports local protocol\n- two routers\n- **docker** with port forwarding\n  - you must use: [--network host](https://docs.docker.com/network/network-tutorial-host/)\n  - hassio users are okay\n- **virtual machine** with port forwarding\n  - you must use bridge virtual network mode (not NAT mode)\n- Oracle VM VirtualBox\n- linux firewall\n- linux network driver\n- incorrect network interface selected in Configuration \u003e [Settings](https://my.home-assistant.io/redirect/general/) \u003e Global \u003e Network\n\nThe devices publish their data through [Multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) (mDNS/[zeroconf](https://www.home-assistant.io/integrations/zeroconf/)), read [more](http://developers.sonoff.tech/sonoff-diy-mode-api-protocol.html#Device-mDNS-Service-Info-Publish-Process).\n\n**Devices unavailable after reboot**\n\nAll devices **unavailable** after each Home Assistant restart. Devices are automatically detected in the local network after each restart. Sometimes devices appear quickly. Sometimes after a few minutes. If this does not happen, there are some problems with the multicast / router.\n\n## Raw commands\n\nThe component adds the service `sonoff.send_command` to send low-level commands.\n\nExample service params to single switch:\n\n```yaml\ndevice: 1000xxxxxx\nswitch: 'on'\n```\n\nExample service params to multi-channel switch:\n\n```yaml\ndevice: 1000xxxxxx\nswitches: [{outlet: 0, switch: 'off'}]\n```\n\nExample service params to dimmer:\n\n```yaml\ndevice: 1000123456\ncmd: dimmable\nswitch: 'on'\nbrightness: 50\nmode: 0\n```\n\n## Getting devicekey manually\n\n*The average user does not need to get the device key manually. The component does everything automatically, using the ewelink account.*\n\n1. Put the device in setup mode\n2. Connect to the Wi-Fi network `ITEAD-10000`, password` 12345678`\n3. Open in browser `http://10.10.7.1/device`\n4. Copy `deviceid` and `apikey` (this is `devicekey`)\n5. Connect to your Wi-Fi network and setup Sonoff via the eWeLink app\n\n## Useful Links\n\n- https://github.com/peterbuga/HASS-sonoff-ewelink\n- https://github.com/beveradb/sonoff-lan-mode-homeassistant\n- https://github.com/mattsaxon/sonoff-lan-mode-homeassistant\n- https://github.com/EpicLPer/Sonoff_GK-200MP2-B_Dump\n- https://github.com/bwp91/homebridge-ewelink\n- https://blog.ipsumdomus.com/sonoff-switch-complete-hack-without-firmware-upgrade-1b2d6632c01\n- https://github.com/itead/Sonoff_Devices_DIY_Tools\n- [SONOFF DIY MODE API PROTOCOL](http://developers.sonoff.tech/sonoff-diy-mode-api-protocol.html)\n- [No Tasmota And EWeLink Cloud To Control The SONOFF Device? YES!](https://sonoff.tech/product-tutorials/diy-mode-to-control-the-sonoff-device)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexxIT%2FSonoffLAN","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlexxIT%2FSonoffLAN","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexxIT%2FSonoffLAN/lists"}