Refactor mysensors light

* Add a light entity class per V_LIGHT, V_DIMMER, V_RGB and V_RGBW.
    Make these classes inherit each other up to MySensorsLight class.
* Map the entity classes to their S_TYPE in a dict.
* Check if an entity class map or just an entity class have been passed
    to pf_callback_factory before using the entity_class variable in
    homeassistant/components/mysensors.py.
* Add rgb_hex_to_list function in homeassistant/util/color.py.
This commit is contained in:
MartinHjelmare committed 2016-02-18 02:04:06 +01:00
1 parent bb37708716
commit 03423cc3a9
3 files changed
+244 -102

No files matched your search

+5 -1
View File
@@ -146,7 +146,11 @@ def pf_callback_factory(map_sv_types, devices, add_devices, entity_class):
continue
name = '{} {}.{}'.format(
gateway.sensors[node_id].sketch_name, node_id, child.id)
devices[key] = entity_class(
if isinstance(entity_class, dict):
device_class = entity_class[child.type]
else:
device_class = entity_class
devices[key] = device_class(
gateway, node_id, child.id, name, value_type)
_LOGGER.info('Adding new devices: %s', devices[key])