Fix wrapper and S_BINARY and bump req. version

* Wrap existing SerialGateway instance instead of subclassing
	SerialGatewat class.
* Add S_BINARY in switch platform only in version 1.5 of mysenors api.
* Use version 0.4 of pymysensors.
* Show gateway port as state attribute.
This commit is contained in:
MartinHjelmare
2016-01-10 04:10:38 +01:00
parent 4c4e5d5f47
commit 2d8cf7de44
4 changed files with 46 additions and 30 deletions

View File

@@ -36,7 +36,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
gateway.const.Presentation.S_MOTION,
gateway.const.Presentation.S_SMOKE,
gateway.const.Presentation.S_LIGHT,
gateway.const.Presentation.S_BINARY,
gateway.const.Presentation.S_LOCK,
]
v_types = [
@@ -46,6 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
]
if float(gateway.version) >= 1.5:
s_types.extend([
gateway.const.Presentation.S_BINARY,
gateway.const.Presentation.S_SPRINKLER,
gateway.const.Presentation.S_WATER_LEAK,
gateway.const.Presentation.S_SOUND,
@@ -68,14 +68,14 @@ class MySensorsSwitch(SwitchDevice):
"""Setup class attributes on instantiation.
Args:
port (str): Gateway port.
gateway (GatewayWrapper): Gateway object.
node_id (str): Id of node.
child_id (str): Id of child.
name (str): Entity name.
value_type (str): Value type of child. Value is entity state.
Attributes:
port (str): Gateway port.
gateway (GatewayWrapper): Gateway object
node_id (str): Id of node.
child_id (str): Id of child.
_name (str): Entity name.
@@ -112,6 +112,7 @@ class MySensorsSwitch(SwitchDevice):
def state_attributes(self):
"""Return the state attributes."""
data = {
mysensors.ATTR_PORT: self.gateway.port,
mysensors.ATTR_NODE_ID: self.node_id,
mysensors.ATTR_CHILD_ID: self.child_id,
ATTR_BATTERY_LEVEL: self.battery_level,