My guess is, this should work, right? There’s a trigger and I’m going to push the trigger event name to MQTT. But somehow this does not work. Is it a bug? Or am I missing a hidden feature?
Or can I only use mqtt trigger stuff even though the actual trigger was not from MQTT?
- alias: 'Say who at home'
trigger:
- platform: state
entity_id: group.greg
to: 'home'
action:
- service: mqtt.publish
data:
payload_template: 'Hello there {{trigger.event}} welcome to our humble home'
topic: 'homey/say'
I don’t think ‘payload_template’ exists. I could be wrong. But ‘data_template’ definitely exists, so this should work:
- alias: 'Say who at home'
trigger:
- platform: state
entity_id: group.greg
to: 'home'
action:
- service: mqtt.publish
data_template:
payload: 'Hello there {{trigger.event}} welcome to our humble home'
topic: 'homey/say'
Hm… Not everything is a tracker. I’ve got BT tracking on a other device (a pi) and AFAIK it is not possible to transfer the tracker as is to an other HA instance (with mqtt) so it’s a sensor on the other side (where the user group lives).
I did try the data_template as well, also did not work.
Funny, now that I look at it, you aren’t using an event. Your trigger is going to be a from_state and a to_state. You won’t have any event data. You need to actively go out and find who just arrived in order to place that information there. You may want to build this automation off individual devices or hard code the phrase to be ‘greg’.
Hm… I’m nearly there… I didn’t show all of the code… It’s actually 4 triggers (4 persons) so I wanted to know what the trigger was to say “hello $name”.
But you DID help me a lot… It was a combinations of things… First there was also a condition that messed stuff up and second I do need to use data_template.