Automate on device sate change

Hi Ive just initialled Hassio on a Pi3 and ive various smart switches, google home, rukos around the house . so far I have managed to send a push message to my phone when a shelly switch is turned on and turn other lights on. but what ican get to work is turn another device if the shelly drops off the wifi please see scrip below , I have tried it with and without quotes and tried connected in the from:

description: ‘’
trigger:

  • entity_id: switch.shelly_shsw_1_ba6a91
    from: ‘“on” or “Off”’
    platform: state
    to: ‘“unavailable”’
    condition: []
    action:
  • device_id: 2bce96f8a9f459c8bdc19ef38ef4ec2c
    domain: switch
    entity_id: switch.test_kasa
    type: toggle

First, please format your code correctly as described in the community guidelines, as you have it now, we can’t see whether you have any indentation error or similar.
Second, you can’t put an “or” in the “from:” part.
You can skip the whole “from:” line, as you are not interested what the previous state was, ylu only want to trigger when the new state is “unavailable”.

Something like this:

trigger:
  entity_id: switch.shelly_shsw_1_ba6a91
  platform: state
  to: "unavailable"

And I recommend changing your entity_ids, and give them more meaningful name.

1 Like

Hi thank for the advice I will give that a go some time today and I will read the gudielines