-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(device): add SNSZB-01 support for ZHA
related to #170
- Loading branch information
Showing
5 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
layout: controller | ||
title: SNZB-01 (Sonoff) | ||
device: SNZB-01 | ||
--- |