Light switch is unavailable if made from switch template
See original GitHub issueThe 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
[SOLVED]Template switch that can be on/off/unavailable?
Hey guys, I ve been trying to create a template switch that would also show me if the actual switch is unavailable apart...
Read more >Light Switch Not Working in 2023? Here's How to Troubleshoot It
So the first thing to check is the breaker in your home's electrical panel. If that's not the case, you have other issues....
Read more >Troubleshoot Switch Port and Interface Problems - Cisco
If the link light for the port does not come on, you can consider these ... For example, you have a switch that...
Read more >Wemo Smart Light Switch 3-Way, WLS0403 Frequently Asked ...
What are the wires of the Wemo Light Switch made of? ... It may be dangerous or illegal to install if the neutral...
Read more >Problems with Download Codes (Software, DLC, and Themes)
Applies to: Nintendo Switch Family, Nintendo Switch, Nintendo Switch Lite, Nintendo Switch ... A game or theme download code from a retailer, prepaid...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
Yes, this is still actual.