alias: awtrix_bday_kay_countdown
description: ""
mode: single
trigger:
- platform: state
entity_id:
- sensor.anniversary_bday_kay
condition: []
action:
- if:
- condition: numeric_state
entity_id: sensor.anniversary_bday_kay
below: 1
then:
- service: mqtt.publish
data:
qos: 2
retain: true
payload: |-
{
"text": "{{ states.sensor.anniversary_bday_kay.state }} K",
"rainbow": true,
"icon": 14004,
"duration": 10
}
topic: awtrix1/custom/bday_kay
else:
- service: mqtt.publish
data:
qos: 2
retain: true
payload: |-
{
"text": "Happy Birthday!",
"rainbow": true,
"icon": 14004,
"duration": 10
}
topic: awtrix1/custom/bday_kay
You forgot to tell us the problem.
HomeAssistant marks it with a red vertical bar and does not even let me save this. (= Syntax must be wrong at some point)
It’s just YAML hell… OMG!
tab characters must not be used in indentation (15:1)
12 | entity_id: sensor.anniv ...
13 | below: 1
14 | then:
15 | → - service: mqtt.publish
------^
16 | → data:
17 | → qos: 2
1 Like
Check this code:
alias: awtrix_bday_kay_countdown
description: ""
mode: single
trigger:
- platform: state
entity_id:
- sensor.anniversary_bday_kay
condition: []
action:
- if:
- condition: numeric_state
entity_id: sensor.anniversary_bday_kay
below: 1
then:
- service: mqtt.publish
data:
qos: 2
retain: true
payload: |
{
"text": "{{ states.sensor.anniversary_bday_kay.state }} K",
"rainbow": true,
"icon": 14004,
"duration": 10
}
topic: awtrix1/custom/bday_kay
else:
- service: mqtt.publish
data:
qos: 2
retain: true
payload: |
{
"text": "Happy Birthday!",
"rainbow": true,
"icon": 14004,
"duration": 10
}
topic: awtrix1/custom/bday_kay
There still seems to be an error in:
else:
- service: mqtt.publish
data:
qos: 2
retain: false
topic: awtrix1/custom/bday_kay
payload: |-
{
"text": "Happy Birthday!",
"rainbow": true,
"icon": 14004,
"duration": 10
}
- service: mqtt.publish
data:
qos: 2
retain: false
topic: awtrix2/custom/bday_kay
payload: |-
{
"text": "Happy Birthday!",
"rainbow": true,
"icon": 14004,
"duration": 10
}
How could I possibly specify multiple “service: mqtt.publish” blocks here?
What kind of error?
- Is the Automation Editor still reporting that there’s a syntax error?
- Is
mqtt.publish
failing to publish the payload? - Is
mqtt.publish
succeeding to publish the payload but the payload isn’t understood by the subscriber? - Does only one of the two
mqtt.publish
work or do both fail?
Sorry for not being specific. The first service block (awtrix1) works, the second is not published.
It turns out it was a Layer 8 problem… everything works as expected. (but the trace definitely helped to realize that… )
Thanks a lot!
What did “Layer 8” misinterpret?
The if condition I defined. Until kay’s birthday it is perfectly fine if the then-branch is executed.