core: Light switch is unavailable if made from switch template
The problem
After HA restart, a light switch made from a switch template remains unavailable until the switch changed its state. This bug is introduced in 0.117, earlier it worked as expected.
Environment
- Home Assistant Core release with the issue: 0.117.5
- Last working Home Assistant Core release (if known): 0.116
- Operating environment (OS/Container/Supervised/Core): Virtualenv on Raspberry Pi
- Integration causing this issue: Light Switch
- Link to integration documentation on our website: https://www.home-assistant.io/integrations/light.switch/
Problem-relevant configuration.yaml
switch:
- platform: template
switches:
readinglamp_wrapper:
value_template: "{{ states.switch.readinglamp.state == 'on' }}"
availability_template: "{{ states.switch.readinglamp != None and states.switch.readinglamp.state != 'unavailable' and states.binary_sensor.power.state == 'on' }}"
turn_on:
service: switch.turn_on
entity_id: switch.readinglamp
turn_off:
service: switch.turn_off
entity_id: switch.readinglamp
light:
- platform: switch
name: readinglamp
entity_id: switch.readinglamp_wrapper
switch.readinglamp
comes from Xiaomi Gateway (Aqara) UI integration.
Traceback/Error logs
2020-11-08 20:58:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.readinglamp_wrapper, old_state=None, new_state=<state switch.readinglamp_wrapper=off; friendly_name=readinglamp wrapper @ 2020-11-08T20:58:15.768398+02:00>>
...
2020-11-08 20:58:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.readinglamp, old_state=None, new_state=<state light.readinglamp=unavailable; friendly_name=readinglamp, supported_features=0 @ 2020-11-08T20:58:15.790523+02:00>>
...
2020-11-08 20:58:20 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.readinglamp, old_state=None, new_state=<state switch.readinglamp=off; in_use=0, load_power=0.0, power_consumed=537.0, voltage=3.6, battery_level=100.0, friendly_name=readinglamp, icon=mdi:power-plug @ 2020-11-08T20:58:20.816473+02:00>>
Additional information
N/A
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 28 (14 by maintainers)
Maybe a weird question (and probably a bit off-topic as well). But… euhm… why are you using a switch template and use the light switch to convert it into a light? Why not use a light template directly?