-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a file for zwave workarounds. (#5798)
* Create a file for zwave workarounds. Add sensor->binary_sensor for fgfs101 (#2) * Don't use default None
- Loading branch information
1 parent
b8a0792
commit 1b54218
Showing
3 changed files
with
91 additions
and
36 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
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,67 @@ | ||
"""Zwave workarounds.""" | ||
from . import const | ||
|
||
# Manufacturers | ||
FIBARO = 0x010f | ||
PHILIO = 0x013c | ||
WENZHOU = 0x0118 | ||
|
||
# Product IDs | ||
PHILIO_SLIM_SENSOR = 0x0002 | ||
PHILIO_3_IN_1_SENSOR_GEN_4 = 0x000d | ||
|
||
# Product Types | ||
FGFS101_FLOOD_SENSOR_TYPE = 0x0b00 | ||
PHILIO_SENSOR = 0x0002 | ||
|
||
# Mapping devices | ||
PHILIO_SLIM_SENSOR_MOTION = (PHILIO, PHILIO_SENSOR, PHILIO_SLIM_SENSOR, 0) | ||
PHILIO_3_IN_1_SENSOR_GEN_4_MOTION = ( | ||
PHILIO, PHILIO_SENSOR, PHILIO_3_IN_1_SENSOR_GEN_4, 0) | ||
WENZHOU_SLIM_SENSOR_MOTION = (WENZHOU, PHILIO_SENSOR, PHILIO_SLIM_SENSOR, 0) | ||
|
||
# Workarounds | ||
WORKAROUND_NO_OFF_EVENT = 'trigger_no_off_event' | ||
|
||
# List of workarounds by (manufacturer_id, product_type, product_id, index) | ||
DEVICE_MAPPINGS = { | ||
PHILIO_SLIM_SENSOR_MOTION: WORKAROUND_NO_OFF_EVENT, | ||
PHILIO_3_IN_1_SENSOR_GEN_4_MOTION: WORKAROUND_NO_OFF_EVENT, | ||
WENZHOU_SLIM_SENSOR_MOTION: WORKAROUND_NO_OFF_EVENT, | ||
} | ||
|
||
# Component mapping devices | ||
FIBARO_FGFS101_SENSOR_ALARM = ( | ||
FIBARO, FGFS101_FLOOD_SENSOR_TYPE, const.COMMAND_CLASS_SENSOR_ALARM) | ||
|
||
# List of component workarounds by | ||
# (manufacturer_id, product_type, command_class) | ||
DEVICE_COMPONENT_MAPPING = { | ||
FIBARO_FGFS101_SENSOR_ALARM: 'binary_sensor', | ||
} | ||
|
||
|
||
def get_device_component_mapping(value): | ||
"""Get mapping of value to another component.""" | ||
if (value.node.manufacturer_id.strip() and | ||
value.node.product_type.strip()): | ||
manufacturer_id = int(value.node.manufacturer_id, 16) | ||
product_type = int(value.node.product_type, 16) | ||
return DEVICE_COMPONENT_MAPPING.get( | ||
(manufacturer_id, product_type, value.command_class)) | ||
|
||
return None | ||
|
||
|
||
def get_device_mapping(value): | ||
"""Get mapping of value to a workaround.""" | ||
if (value.node.manufacturer_id.strip() and | ||
value.node.product_id.strip() and | ||
value.node.product_type.strip()): | ||
manufacturer_id = int(value.node.manufacturer_id, 16) | ||
product_type = int(value.node.product_type, 16) | ||
product_id = int(value.node.product_id, 16) | ||
return DEVICE_MAPPINGS.get( | ||
(manufacturer_id, product_type, product_id, value.index)) | ||
|
||
return None |