Switch turned on by service switch.turn_off

So today one of my lights (switch) turned on from an automation that calls service switch.turn_off

grafik

The switch is an mqtt switch, homeassistant docker 0.115.2
Is this something for a github issue or how do I debug this? Seems kind of strange that it is even possible.

I am seeing the same issue.
image

The device is an ESPHome switch, Home Assistant 0.116.4 docker

Thanks. I’m “glad” to hear I’m not the only one and that it’s not a problem with my devices/firmware if it happens with ESPHome too.
Maybe I should open an issue on github since on the forum nobody seems to care/notice.

I agree that opening an issue sounds like a good idea. Let me know if you need anymore info from me. I am fairly new to Home Assistant so not sure how much help I can be.

I opened an issue, let’s see what happens: https://github.com/home-assistant/core/issues/42798

@tmaults if you can reproduce the issue, it would be good to get the same information from you too, the automation that triggers it and debug log messages:

@kevinkk525, I was able to recreate the issue by adding the automation shown below and after verifying that the “switch.power_controller_switch” was turned off, trigger the automation by changing the state of “input_boolean.helper_test” the “switch.power_controller_switch” was turned on as shown in the log snippet below.

Let me know if you need any more info.

from automations.yaml

  • id: ‘1604578529672’
    alias: Test service.turn_on/turn_off
    description: ‘’
    trigger:
    • platform: state
      entity_id: input_boolean.helper_test
      condition: []
      action:
    • service: switch.turn_off
      data: {}
      entity_id: switch.power_controller_switch
      mode: single

2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=input_boolean, service=turn_on, service_data=entity_id=input_boolean.helper_test>
2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=input_boolean.helper_test, old_state=<state input_boolean.helper_test=off; editable=True, friendly_name=helper_test @ 2020-11-05T07:15:48.565933-07:00>, new_state=<state input_boolean.helper_test=on; editable=True, friendly_name=helper_test @ 2020-11-05T07:16:38.348087-07:00>>
2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event automation_triggered[L]: name=Test service.turn_on/turn_off, entity_id=automation.test_service_turn_on_turn_off, source=state of input_boolean.helper_test>
2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.test_service_turn_on_turn_off, old_state=<state automation.test_service_turn_on_turn_off=on; last_triggered=2020-11-05T07:15:48.567523-07:00, mode=single, current=0, id=1604578529672, friendly_name=Test service.turn_on/turn_off @ 2020-11-05T07:12:56.710931-07:00>, new_state=<state automation.test_service_turn_on_turn_off=on; last_triggered=2020-11-05T07:16:38.349349-07:00, mode=single, current=1, id=1604578529672, friendly_name=Test service.turn_on/turn_off @ 2020-11-05T07:12:56.710931-07:00>>
2020-11-05 07:16:38 INFO (MainThread) [homeassistant.components.automation.test_service_turn_on_turn_off] Test service.turn_on/turn_off: Running automation actions
2020-11-05 07:16:38 INFO (MainThread) [homeassistant.components.automation.test_service_turn_on_turn_off] Test service.turn_on/turn_off: Executing step call service
2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service=turn_off, service_data=entity_id=[‘switch.power_controller_switch’]>
2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.test_service_turn_on_turn_off, old_state=<state automation.test_service_turn_on_turn_off=on; last_triggered=2020-11-05T07:16:38.349349-07:00, mode=single, current=1, id=1604578529672, friendly_name=Test service.turn_on/turn_off @ 2020-11-05T07:12:56.710931-07:00>, new_state=<state automation.test_service_turn_on_turn_off=on; last_triggered=2020-11-05T07:16:38.349349-07:00, mode=single, current=0, id=1604578529672, friendly_name=Test service.turn_on/turn_off @ 2020-11-05T07:12:56.710931-07:00>>
2020-11-05 07:16:38 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.power_controller_switch, old_state=<state switch.power_controller_switch=off; friendly_name=Pool switch, icon= @ 2020-11-05T07:15:48.640535-07:00>, new_state=<state switch.power_controller_switch=on; friendly_name=Pool switch, icon= @ 2020-11-05T07:16:38.494662-07:00>>

That’s awesome! Thanks!
It didn’t occur in my setup yet…

Do you have a github account? If so, you can post that information to the issue there. If not, I’ll post it there on your behalf.

@tmaults I posted it on github. Just for confirmation: The switch.power_controller_switch is an ESPHome mqtt switch?

@kevinkk525 It is an ESPHome switch but I do not use mqtt.

@kevinkk525

I don’t have a github account. I created an account and responded to emontnemery

thanks. but if it is not an mqtt switch, how does ESPHome send it? RestAPI?

I know it’s a years old thread, but it was a high-up result in Google when I was searching for my issue so i thought i’d post what I found here.

So, my issue was that every day at 11:56PM, my smart plug would turn off. HA listed it in the Logbook just as “Dishwasher turned off triggered by service Switch: Turn off”, but nothing more. After following the advice on the linked GitHub Issue, I enabled debug logging for core and mqtt by adding

logger:
  default: info
  logs:
    homeassistant.core: debug
    homeassistant.components.mqtt: debug

to my configuration.yaml file. Then I waited. Took a while to read the logs, but then I saw

2023-08-30 23:56:46.187 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event alexa_smart_home[L]: request=namespace=Alexa.PowerController, name=TurnOff, entity_id=switch.spare_plug, response=namespace=Alexa, name=Response>

Turns out, I had an old Alexa routine setup to run at 11:56PM and turn off the plugs I used for my Christmas lights. After Christmas, I unplugged those plugs and put them in the draw. 8 months later I took it out to use it for something else and forgot it’s original purpose! Routine is now disabled.

3 Likes