Hi there,
i’m new in mqtt…
i want to perform the action ONLY, when the Payload-String starts with “3,”
i have tried it like the example below or with conditions.
Nothing works, because the event fires the whole time when a message is incoming.
Someone any idea?
Thanks a lot
regads
Daniel
alias: tur
description: ""
trigger:
- platform: mqtt
topic: blub/3678556C/Feier
encoding: utf-8
payload: "{3,}"
condition: []
action:
- type: turn_on
device_id: ab9f7542c4a9831b49bb71eef4512c3e
entity_id: a317e96d1cc07313e1bbe5f455be3f92
domain: switch
mode: single
i have also tried this:
condition:
- condition: template
value_template: trigger.payload.startswith("3,")
and this is the mqtt message:
mqtt_packet_received, packet: PUBLISH(Q2, R0, D0, Topic=blub/3678556C/Feier, PacketId=29, Payload=3,0,1357381632,0,0)
francisp
(Francis)
August 22, 2023, 8:51am
2
something like
alias: tur
description: ""
trigger:
- platform: mqtt
topic: blub/3678556C/Feier
encoding: utf-8
condition:
value_template: '{{ trigger.payload is match "3," }}'
action:
- type: turn_on
device_id: ab9f7542c4a9831b49bb71eef4512c3e
entity_id: a317e96d1cc07313e1bbe5f455be3f92
domain: switch
mode: single
your code returns: “Message malformed: Unexpected value for condition: ‘None’. Expected and, device, not, numeric_state, or, state, sun, template, time, trigger, zone @ data[‘condition’][0]”
francisp
(Francis)
August 22, 2023, 9:37am
4
Yes, forgot template
alias: tur
description: ""
trigger:
- platform: mqtt
topic: blub/3678556C/Feier
encoding: utf-8
condition: template
value_template: '{{ trigger.payload is match "3," }}'
action:
- type: turn_on
device_id: ab9f7542c4a9831b49bb71eef4512c3e
entity_id: a317e96d1cc07313e1bbe5f455be3f92
domain: switch
mode: single
lakatusch
(Daniel)
August 22, 2023, 10:05am
5
now other return code:
Message malformed: required key not provided @ data['condition'][0]['value_template']
lakatusch
(Daniel)
August 22, 2023, 11:05am
7
a litte bit crazy but when it is escaped, it works:
condition:
- condition: template
value_template: "{{ trigger.payload is match \"3,\" }}"