Skip to content
Snippets Groups Projects
Commit 621a6e0e authored by Paulus Schoutsen's avatar Paulus Schoutsen
Browse files

Merge pull request #1395 from MartinHjelmare/fix-mysensors-switch-light

Fix mysensors switch & light types
parents caa1b730 9c538d11
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
pres = gateway.const.Presentation
set_req = gateway.const.SetReq
map_sv_types = {
pres.S_LIGHT: [set_req.V_LIGHT],
pres.S_DIMMER: [set_req.V_DIMMER],
}
device_class_map = {
pres.S_LIGHT: MySensorsLightPlain,
pres.S_DIMMER: MySensorsLightDimmer,
}
if float(gateway.version) >= 1.5:
......@@ -45,7 +43,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
map_sv_types.update({
pres.S_RGB_LIGHT: [set_req.V_RGB],
})
map_sv_types[pres.S_LIGHT].append(set_req.V_STATUS)
map_sv_types[pres.S_DIMMER].append(set_req.V_PERCENTAGE)
device_class_map.update({
pres.S_RGB_LIGHT: MySensorsLightRGB,
......@@ -263,25 +260,6 @@ class MySensorsLight(Light):
self._values[value_type] = value
class MySensorsLightPlain(MySensorsLight):
"""Light child class to MySensorsLight."""
def turn_on(self, **kwargs):
"""Turn the device on."""
self._turn_on_light()
def turn_off(self, **kwargs):
"""Turn the device off."""
ret = self._turn_off_light()
self._turn_off_main(value_type=ret[
ATTR_VALUE_TYPE], value=ret[ATTR_VALUE])
def update(self):
"""Update the controller with the latest value from a sensor."""
self._update_main()
self._update_light()
class MySensorsLightDimmer(MySensorsLight):
"""Dimmer child class to MySensorsLight."""
......
......@@ -32,6 +32,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
pres.S_DOOR: [set_req.V_ARMED],
pres.S_MOTION: [set_req.V_ARMED],
pres.S_SMOKE: [set_req.V_ARMED],
pres.S_LIGHT: [set_req.V_LIGHT],
pres.S_LOCK: [set_req.V_LOCK_STATUS],
}
if float(gateway.version) >= 1.5:
......@@ -43,6 +44,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
pres.S_VIBRATION: [set_req.V_ARMED],
pres.S_MOISTURE: [set_req.V_ARMED],
})
map_sv_types[pres.S_LIGHT].append(set_req.V_STATUS)
devices = {}
gateway.platform_callbacks.append(mysensors.pf_callback_factory(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment