getting this error message for my location tracking automation:
Message malformed: expected a dictionary for dictionary value @ data[‘variables’]
Here is my code:
alias: notify on zone enter/leave
trigger:
- platform: zone
entity_id:
- device_tracker.life360_person1
- device_tracker.life360_person2
zone: zone.home
event: enter
- platform: zone
entity_id:
- device_tracker.life360_person1
- device_tracker.life360_person2
zone: zone.work
event: leave
variables:
- event: "{{ 'left' if trigger.event == 'leave' else 'arrived at' }}"
- person: "{{ trigger.to_state.attributes.friendly_name }}"
- zone: "{{ trigger.zone.attributes.friendly_name }}"
action:
- service: notify.mobile_app_sm_n975u
data:
message: >
{{ person + ' ' + event ' ' + zone }}
- service: notify.mobile_app_sm_n975u
data:
message: >
{{ person + ' ' + event ' ' + zone }}
Where in the variables am I formatting it wrong?
m0wlheld
(Christoph Dahlen)
January 27, 2022, 5:30am
2
variables:
event: "{{ 'left' if trigger.event == 'leave' else 'arrived at' }}"
person: "{{ trigger.to_state.attributes.friendly_name }}"
zone: "{{ trigger.zone.attributes.friendly_name }}"
Dictionary, not list …
Thank you! that removed the error but I did get another about the action data at 0 needing to be a string so I modified the message to this:
{{states('person + ' ' + event ' ' + zone')}}
FYI in case anyone want to use the code.
thank you again, @m0wlheld
m0wlheld
(Christoph Dahlen)
January 27, 2022, 6:59am
4
Hu? Don‘t think that this will work, I guess you should use:
message: >
{{person}} {{event}} {{zone}}
you’re right that doesn’t work. When I use yours, it doesn’t allow me to save so I don’t think that will work either. I tried what was originally in the code I posted but that gets this error:
Stopped because an error was encountered at January 27, 2022, 6:59:32 AM (runtime: 0.01 seconds)
template value should be a string for dictionary value @ data[‘message’]
not sure what would work. any help is much appreciated
EDIT: @m0wlheld your code did work. I just didnt have the spacing correct. Thanks again