Hi
I am a hassio beginner and have managed to solve most of my basic system challenges with google and the generous advice given by this amazing community (thanks). I am struggling with a mqtt server message coming from an alarm panel where the payload is a text field of variable length: e.g. one or more Zones (ZXX) in every message e.g.
Topic: alarm/problem_report
Payload: Living room (Z15) low batt,
Fire (Z23) low batt,
Upstairs (Z24) low batt
(Each payload line is separated with \r\n).
I am attempting to either write automations triggered by each zone detected (these messages are always low battery), or create binary (battery) sensors to highlight the low battery status for each zone. I only need to find the zone code e.g. Z23.
I have tried many permutations of regex etc. but just canât seem to get a trigger e.g. (created with the automation tool but copied from automations.yaml).
- id: AlarmPanelTest
alias: Alarm Panel Test
trigger:
- platform: mqtt
topic: alarm/problem_report
condition:
- condition: template
value_template: '{{value|regex_search("Z15",ignorecase=FALSE) }}'
action:
- data:
message: Living Room PIR - Low Battery
notification_id: Alarm Panel Problem Z15
title: Alarm low battery
service: persistent_notification.create
I have tried single quotes and double single quotes surrounding the Z15 but nothing triggers.
I have also tried: value_template: â{{âZ15â in value}}â
The binary sensor looks like this:
- platform: mqtt
name: "Living room PIR"
state_topic: "alarm/problem_report"
device_class: battery
value_template: '{{ value|regex_search(''Z15'', ignorecase=FALSE)}}'
It doesnât change the battery status when the problem report.
I am wondering if I am misunderstanding the use of value_template or whether regex_search is the right tool and if so, what is returned when there is a match and whether it can be used as a condition?
I am also wondering whether I can have multiple automations triggering off the same message (one per zone)?
All thoughts and guidance gratefully appreciatedâŚ