Fix mysensors switch & light types

* Move S_LIGHT and V_LIGHT from light back to switch platform, to avoid
  double devices showing.
* Remove MySensorsLightPlain class from light platform, since it's not
  needed anymore.
* A light switch with only a switch, ie no dimmer or
  RGB controls, will show as a regular switch device.
This commit is contained in:
MartinHjelmare 2016-02-25 00:48:29 +01:00
parent c2729211ad
commit 9c538d11c2
2 changed files with 2 additions and 22 deletions

View file

@ -31,11 +31,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:
@ -43,7 +41,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,
@ -260,25 +257,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."""

View file

@ -30,6 +30,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:
@ -41,6 +42,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(