DOH! Double DOH!
In configuration.yaml I have:
sensor:
- platform: mqtt
name: zone1sensor
state_topic: "/os/12614780/1/1"
In automation the defined trigger in HMI displays as a “Numeric state” in yaml with:
above: '0'
below: '500000'
entity_id: sensor.zone1sensor
platform: numeric_state
The defined action as a “call service” is:
alias: ''
data:
message: |
'{{ trigger.payload }}'
service: logbook.log
So, no problem with the script.py reporting “trigger not defined”.
I am getting the following in logbook:
9:46 PM zone1sensor changed to 300000
But, as you might understand, I would get that without setting the action or automation. So, the payload is not being sent to logbook. And to confirm, same problem with the notify.notify as “Call service”.
So, even if the payload is sitting in trigger.payload, it doesn’t seem to be used?
And, while that is tantalisingly close. If I want to send the same payload twice, the sensor state only reports on change. So, it seems I might look at a custom component. I might have more luck with straight python.
If it helps, pseudo-code for the automation that I actually want to get to is:
- trigger> on mqtt topic
- action>turn ESPHome based relay on
- action> wait for delay passed as payload on mqtt topic
- action>turn ESPHome based relay off
ESPHome stuff works a treat, it’s just trying to use the mqtt payloads as millisecond based delays has me drinking heavily … hic.