Add mysensors binary sensor

* Add mysensors binary sensor.
* Add discovery platforms to binary_sensor base component.
* Replace device_state_attributes with state_attributes in
	binary_sensor base class.
* Fix docstrings.
* Add discovery of binary sensor to mysensors component.
* Add child.type as argument to mysensors device_class.
* Move binary sensor types from sensor to binary_sensor module.
* Fix binary_sensor attribute tests. Use state_attributes instead of
	device_state_attributes.
This commit is contained in:
MartinHjelmare
2016-02-20 03:59:06 +01:00
parent 2d0721abe8
commit 08aaea5444
7 changed files with 200 additions and 21 deletions

View File

@@ -28,9 +28,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
pres = gateway.const.Presentation
set_req = gateway.const.SetReq
map_sv_types = {
pres.S_DOOR: [set_req.V_TRIPPED],
pres.S_MOTION: [set_req.V_TRIPPED],
pres.S_SMOKE: [set_req.V_TRIPPED],
pres.S_TEMP: [set_req.V_TEMP],
pres.S_HUM: [set_req.V_HUM],
pres.S_BARO: [set_req.V_PRESSURE, set_req.V_FORECAST],
@@ -64,9 +61,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
set_req.V_IMPEDANCE],
pres.S_SPRINKLER: [set_req.V_TRIPPED],
pres.S_WATER_LEAK: [set_req.V_TRIPPED],
pres.S_SOUND: [set_req.V_TRIPPED, set_req.V_LEVEL],
pres.S_VIBRATION: [set_req.V_TRIPPED, set_req.V_LEVEL],
pres.S_MOISTURE: [set_req.V_TRIPPED, set_req.V_LEVEL],
pres.S_SOUND: [set_req.V_LEVEL],
pres.S_VIBRATION: [set_req.V_LEVEL],
pres.S_MOISTURE: [set_req.V_LEVEL],
pres.S_AIR_QUALITY: [set_req.V_LEVEL],
pres.S_DUST: [set_req.V_LEVEL],
})
@@ -82,7 +79,8 @@ class MySensorsSensor(Entity):
# pylint: disable=too-many-arguments
def __init__(self, gateway, node_id, child_id, name, value_type):
def __init__(
self, gateway, node_id, child_id, name, value_type, child_type):
"""Setup class attributes on instantiation.
Args:
@@ -91,6 +89,7 @@ class MySensorsSensor(Entity):
child_id (str): Id of child.
name (str): Entity name.
value_type (str): Value type of child. Value is entity state.
child_type (str): Child type of child.
Attributes:
gateway (GatewayWrapper): Gateway object.