Skip to content

Commit

Permalink
feat(device): add SNSZB-01 support for ZHA
Browse files Browse the repository at this point in the history
related to #170
  • Loading branch information
xaviml committed Nov 27, 2020
1 parent 7ee071c commit 2177c55
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/controllerx/controllerx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
from cx_devices.osram import *
from cx_devices.phillips import *
from cx_devices.smartthings import *
from cx_devices.sonoff import *
from cx_devices.trust import *
15 changes: 15 additions & 0 deletions apps/controllerx/cx_devices/sonoff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from cx_const import Light, TypeActionsMapping
from cx_core import LightController
from cx_core.integration import EventData


class SNZB01LightController(LightController):
def get_zha_actions_mapping(self) -> TypeActionsMapping:
return {
"toggle": Light.TOGGLE, # single click
"on": Light.ON_FULL_BRIGHTNESS, # double click
"off": Light.ON_MIN_BRIGHTNESS, # hold
}

def get_zha_action(self, data: EventData) -> str:
return data["command"]
17 changes: 17 additions & 0 deletions docs/_data/controllers/SNZB-01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: SNZB-01 (Sonoff)
device_support:
- type: Light
domain: light
controller: SNZB01LightController
delay: 350
mapping:
- "1 click → Toggle"
- "2 clicks → Full brightness"
- "After 2s holding the button → Minimum brightness"
integrations:
- name: ZHA
codename: zha
actions:
- "toggle → 1 click"
- "on → 2 clicks"
- "off → After 2s holding the button"
Binary file added docs/assets/img/SNZB-01.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/controllers/SNZB-01.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: controller
title: SNZB-01 (Sonoff)
device: SNZB-01
---

0 comments on commit 2177c55

Please sign in to comment.