What is triggering my scripts?

I have a script that toggles the lights on/off. All of a sudden over the last week or so the lights will randomly shut off. I can’t for the life of me figure out what’s causing the script to trigger. This has been working fine for several months, until just recently.

Is there away to see what’s triggering the script?

We are going to need some more information. What type of light switches? Also post relevant correctly formatted code snippets.

What version of HA are you running and if an older version, do you have a password set?

do you know that the script is actually getting triggered? Is it showing as triggered in the logbook or in the entity card when you click on the script?

Maybe it’s caused by something else.

That’s funny.

I was in the process of replying almost those exact words but you beat me to it.:smile:

1 Like

This has spanned multiple version which I am on the latest now. Upgraded trying to fix the problem.


That’s the script that is getting triggered.

Passwords are set. This is a mixture of a sonoff switch and hue bridge.


- alias: "Bedroom Lights - Toggle All Lights"
    - platform: mqtt
      topic: "device/522427/rf/rx"
      payload: "1398067"
    - platform: mqtt
      topic: "device/522427/rf/rx"
      payload: "4543795"
    - platform: mqtt
      topic: "device/522427/rf/rx"
      payload: "5330227"
    - platform: mqtt
      topic: "device/522427/rf/rx"
      payload: "5526835"
    - service: script.turn_on
        entity_id: >-
          {% if is_state('light.bedroom', 'on') %}
          {% else %}
          {% endif %}


  - service: switch.turn_on
    entity_id: switch.monitor_lights

  - service: light.turn_on
    entity_id: light.bedroom
      brightness: 255
      kelvin: 2700
      transition: 1

  - service: switch.turn_off
    entity_id: switch.monitor_lights
  - service: light.turn_off
    entity_id: light.bedroom
      transition: 3

I’ve finally noticed something in the logs… looking into it a bit more now.


So it looks like there are two possible causes right now:

  1. hass is randomly seeing the old mqtt message
  2. the rf receiver is sending the old message randomly.

So do you have retain: true in your MQTT section of config yaml file?