Hey. I have an MQTT payload that I want to filer to contain certain words within that payload.
THe problem is, the conditional logic put in the value template seems to get ignored. All posts to this topic get always fired. How do I filter MQTT payloads to contain keywords?
Example payload:
{"type":"Motion","trigger":"On", "memo": "person:86%"}
In Developer Tools, I can run this template that returns true/false successfully. I am trying to write this template so I can reuse and have potentially mulitple keywords.
{% set memo = (my_test_json.memo | lower) %}
{% set keywords = ['person'] %}
{{ keywords | select('in', memo) | list | length > 0 }}
When I set it up as an action :
alias: AI Person at Gate
description: ""
triggers:
- trigger: mqtt
topic: blue_iris/ai/CCCGate
value_template: >
{% set memo = (trigger.payload_json.memo | lower) %} {% set keywords =
['person'] %} {{ keywords | select('in', memo) | list | length > 0 }}
- trigger: mqtt
topic: blue_iris/ai/CCCPtz
value_template: >
{% set memo = (trigger.payload_json.memo | lower) %} {% set keywords =
['person'] %} {{ keywords | select('in', memo) | list | length > 0 }}
conditions: []
actions:
- action: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.bi_person_at_gate
- delay:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
- action: counter.decrement
metadata: {}
data: {}
target:
entity_id: counter.bi_person_at_gate
mode: parallel
max: 250