mirror of
https://github.com/basnijholt/adaptive-lighting.git
synced 2026-09-15 00:04:05 +02:00
fixes and now passes tests
This commit is contained in:
parent
d9cd74bef3
commit
251babce9d
1 changed files with 16 additions and 18 deletions
|
|
@ -484,15 +484,15 @@ async def async_setup_entry(
|
||||||
data,
|
data,
|
||||||
)
|
)
|
||||||
switches = _get_switches_from_service_call(hass, service_call)
|
switches = _get_switches_from_service_call(hass, service_call)
|
||||||
these_switches = [] # CONF_WHICH_SWITCH == "main" is default
|
|
||||||
if data[CONF_WHICH_SWITCH] == "sleep":
|
if data[CONF_WHICH_SWITCH] == "sleep":
|
||||||
these_switches = [s.sleep_mode_switch for s in switches]
|
switches = [s.sleep_mode_switch for s in switches]
|
||||||
elif data[CONF_WHICH_SWITCH] == "brightness":
|
elif data[CONF_WHICH_SWITCH] == "brightness":
|
||||||
these_switches = [s.adapt_brightness_switch for s in switches]
|
switches = [s.adapt_brightness_switch for s in switches]
|
||||||
elif data[CONF_WHICH_SWITCH] == "color":
|
elif data[CONF_WHICH_SWITCH] == "color":
|
||||||
these_switches = [s.adapt_color_switch for s in switches]
|
switches = [s.adapt_color_switch for s in switches]
|
||||||
_LOGGER.debug("Turning on switches [%s]", these_switches)
|
|
||||||
for switch in these_switches:
|
_LOGGER.debug("Turning on switches [%s]", switches)
|
||||||
|
for switch in switches:
|
||||||
await switch.async_turn_on()
|
await switch.async_turn_on()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
@ -504,15 +504,14 @@ async def async_setup_entry(
|
||||||
data,
|
data,
|
||||||
)
|
)
|
||||||
switches = _get_switches_from_service_call(hass, service_call)
|
switches = _get_switches_from_service_call(hass, service_call)
|
||||||
these_switches = [] # CONF_WHICH_SWITCH == "main" is default
|
|
||||||
if data[CONF_WHICH_SWITCH] == "sleep":
|
if data[CONF_WHICH_SWITCH] == "sleep":
|
||||||
these_switches = [s.sleep_mode_switch for s in switches]
|
switches = [s.sleep_mode_switch for s in switches]
|
||||||
elif data[CONF_WHICH_SWITCH] == "brightness":
|
elif data[CONF_WHICH_SWITCH] == "brightness":
|
||||||
these_switches = [s.adapt_brightness_switch for s in switches]
|
switches = [s.adapt_brightness_switch for s in switches]
|
||||||
elif data[CONF_WHICH_SWITCH] == "color":
|
elif data[CONF_WHICH_SWITCH] == "color":
|
||||||
these_switches = [s.adapt_color_switch for s in switches]
|
switches = [s.adapt_color_switch for s in switches]
|
||||||
_LOGGER.debug("Turning off switches [%s]", these_switches)
|
_LOGGER.debug("Turning off switches [%s]", switches)
|
||||||
for switch in these_switches:
|
for switch in switches:
|
||||||
await switch.async_turn_off()
|
await switch.async_turn_off()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
|
@ -524,15 +523,14 @@ async def async_setup_entry(
|
||||||
data,
|
data,
|
||||||
)
|
)
|
||||||
switches = _get_switches_from_service_call(hass, service_call)
|
switches = _get_switches_from_service_call(hass, service_call)
|
||||||
these_switches = [] # CONF_WHICH_SWITCH == "main" is default
|
|
||||||
if data[CONF_WHICH_SWITCH] == "sleep":
|
if data[CONF_WHICH_SWITCH] == "sleep":
|
||||||
these_switches = [s.sleep_mode_switch for s in switches]
|
switches = [s.sleep_mode_switch for s in switches]
|
||||||
elif data[CONF_WHICH_SWITCH] == "brightness":
|
elif data[CONF_WHICH_SWITCH] == "brightness":
|
||||||
these_switches = [s.adapt_brightness_switch for s in switches]
|
switches = [s.adapt_brightness_switch for s in switches]
|
||||||
elif data[CONF_WHICH_SWITCH] == "color":
|
elif data[CONF_WHICH_SWITCH] == "color":
|
||||||
these_switches = [s.adapt_color_switch for s in switches]
|
switches = [s.adapt_color_switch for s in switches]
|
||||||
_LOGGER.debug("Toggling switches [%s]", these_switches)
|
_LOGGER.debug("Toggling switches [%s]", switches)
|
||||||
for switch in these_switches:
|
for switch in switches:
|
||||||
if switch.is_on:
|
if switch.is_on:
|
||||||
await switch.async_turn_off()
|
await switch.async_turn_off()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue