Automation trigger on Rest sensor completion

Hi all, I’ve a rest sensor (platform: rest) that gets an access token which is stored as an attribute.

I then have some platform: command line sensors that use this value to access a data source.

At HA startup the command line and rest actions happen at the same time so i have to then wait for the scan_interval on the command line sensors to expire before they output valid data.

My plan was to set an automation so that once the rest sensor completes it would then refresh the command line sensors. The actions on this work fine if i manually trigger them but I don’t seem to be able to figure out the trigger.

What is the best way to trigger this automation and does anyone have an example they could share?

Thanks in advance

You should be able to use a state trigger:

automation:
  trigger:
    - platform: state
      entity_id: sensor.your_sensor
      attribute: token

This will trigger every time the token attribute changes.

1 Like