Script sequence

Hello,
any idea, why this script is not working properly? It only switch wall plug.

tv_on:
  alias: TV On
  sequence:
    - service: switch.turn_on
      entity_id: switch.fibaro_plug_1_switch
    - wait_template: "{{ states.device_tracker.androidtv == 'home' }}"
    - service: mqtt.publish
      data:
        qos: 1
        topic: sony 
        payload: tv on

Thank you and Merry Christmas!

Doesn’t the switch turn on? If so, did you try calling the switch directly through the services page?

It’s available via
http://[HOME_ASSISTANT_IP]:8123/dev-service

If that is not the problem, please give a bit more details. What did you expect to happen, but didn’t?

I haven’t played much with mqtt yet, but don’t the topics normally have like slashes in?

As above, going to need to know what’s not working.

Script in this format works fine:

  tv_on:
    alias: TV On
    sequence:
      service: mqtt.publish
      data:
        qos: 1
        topic: sony 
        payload: tv on

I am expecting, that after device status is changed to ‘home’, mqtt message is send. I can see that device status is changed but nothing happend afterwards. Its the same via direct /dev-service call.
btw, I added data to my original script to turn on wall plug properly:

  tv_on:
    alias: TV On
    sequence:
      - service: switch.turn_on
        data:              
          entity_id: switch.fibaro_plug_1_switch
      - wait_template: "{{ states.device_tracker.androidtv == 'home' }}"
      - service: mqtt.publish
        data:
          qos: 1
          topic: sony 
          payload: tv on

Thanks.

wait_template: "{{ is_state ('device_tracker.androidtv' ,  'home' ) }}"

?

1 Like

Here is about wait template:

Yeah, I know about wait templates, have you tried the one I’ve suggested?

Oh sorry… I did’t notice your change.
It seems like its working now!

Thank you very much!

1 Like

You’re very welcome. Merry Xmas :+1:

1 Like