core icon indicating copy to clipboard operation
core copied to clipboard

Light switch is unavailable if made from switch template

Open OleksandrBerchenko opened this issue 5 years ago • 34 comments

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

OleksandrBerchenko avatar Nov 08 '20 20:11 OleksandrBerchenko

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?

frenck avatar Nov 08 '20 22:11 frenck

light documentation light source (message by IssueLinks)

@frenck To have a clean code :) Please note, I have a lot of similar switch templates (which handle a power outage) and not of them are used for lights. Until this bug is fixed, I have already converted all of them into light templates.

Thanks!

OleksandrBerchenko avatar Nov 09 '20 07:11 OleksandrBerchenko

I think this is the same issue as https://github.com/home-assistant/core/issues/43457

dgomes avatar Nov 23 '20 12:11 dgomes

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Feb 21 '21 13:02 github-actions[bot]

Yes, this is still actual.

OleksandrBerchenko avatar Feb 21 '21 13:02 OleksandrBerchenko

Same problem here, some lights are unavailable but the original switch is.

RolandvanOers avatar Mar 22 '21 06:03 RolandvanOers

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jun 20 '21 07:06 github-actions[bot]

Yes, this is still actual.

OleksandrBerchenko avatar Jun 20 '21 07:06 OleksandrBerchenko

The same issue occurs for me when just turning a switch into a light using the Light Switch platform. In other words, this occurs even when not using switch templates, it seems to affect any kind of switch that is turned into a Light Switch. A restart of HA resets the light switches so that they are shown as available again.

jprintz avatar Jun 20 '21 12:06 jprintz

Problem is still the same indeed, anything turned into a light switch is unavailable after 1 or 2 uses

RolandvanOers avatar Jun 20 '21 12:06 RolandvanOers

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 18 '21 13:09 github-actions[bot]

Yes, this is still actual.

OleksandrBerchenko avatar Sep 18 '21 13:09 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 17 '21 14:12 github-actions[bot]

Yes, this is still actual.

OleksandrBerchenko avatar Dec 17 '21 14:12 OleksandrBerchenko

Can those having problems post the template light configuration in YAML?

Also, the light entities that are used within the template light or light switch, which integration/component ultimately supports those light entities?

ronytomen avatar Jan 25 '22 10:01 ronytomen

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 15 '22 16:07 github-actions[bot]

Yes, this is still actual.

OleksandrBerchenko avatar Jul 15 '22 16:07 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yes, this is still actual.

OleksandrBerchenko avatar Jan 16 '23 08:01 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yes, this is still actual.

OleksandrBerchenko avatar Apr 16 '23 10:04 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yes, this is still actual.

OleksandrBerchenko avatar Jul 15 '23 12:07 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yes, this is still actual.

OleksandrBerchenko avatar Oct 13 '23 13:10 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yes, this is still actual.

OleksandrBerchenko avatar Jan 11 '24 15:01 OleksandrBerchenko

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Yes, this is still actual.

OleksandrBerchenko avatar Apr 10 '24 16:04 OleksandrBerchenko