I have spent an hour trying to get this to work, but I’m well and truly stuck. I am trying to use the info from two sensors when triggered. The trigger is any sensor.foobar_sone_x_tittel or _artist, and when triggered I want to send the state of that sensor (it’s a Scrape sensor) as a REST command.
alias: Sende beskjed om hva Foobar spiller i alle soner
description: ""
triggers:
- trigger: state
entity_id:
- sensor.foobar_sone_1_tittel
- sensor.foobar_sone_1_artist
- sensor.foobar_sone_2_tittel
- sensor.foobar_sone_2_artist
- sensor.foobar_sone_3_tittel
- sensor.foobar_sone_3_artist
- sensor.foobar_sone_4_tittel
- sensor.foobar_sone_4_artist
- sensor.foobar_sone_5_tittel
- sensor.foobar_sone_5_artist
- sensor.foobar_sone_6_tittel
- sensor.foobar_sone_6_artist
- sensor.foobar_sone_7_tittel
- sensor.foobar_sone_7_artist
- sensor.foobar_sone_8_tittel
- sensor.foobar_sone_8_artist
- sensor.foobar_sone_9_tittel
- sensor.foobar_sone_9_artist
conditions: []
actions:
- variables:
sone: |
{{ trigger.entity_id | replace('sensor.foobar_sone_','') |
replace('_tittel','') | replace('_artist','') }}
artist: |
{{ states('sensor.foobar_sone_{{ sone }}_artist') }}
tittel: |
{{ states('sensor.foobar_sone_{{ sone }}_tittel') }}
- alias: Send til Girder
data:
kommandoklasse: Avspillingsinfo
kommando: |
{{ states('sensor.foobar_sone_ {{ sone }} _artist') }} {{ artist }} med {{ tittel }}
sone: |
{{ sone }}
action: rest_command.girder
Seting the variable sone works, because I get the correct sone in the receiving end of the REST command. I have one extra entry for artist because I have tried both versions, setting it in the variable and setting it in the action. None of them work, I get three times “uknown” in the receiving end. I’m guessing it’s another one of those format errors, so can somebody please enlighten me?