Hi! I’m fairly new to HA, and I’m trying to do my first “advanced” automation, but I’m struggling a lot, here’s my project:
I simply want to detect when a precise set of characters are present in the text field of a notification I’m receiving on my android phone.
For a first attempt I wanted to try that with the facebook messenger app, I want to trigger an automation when the word “test” is anywhere in the message I’m receiving.
I had success in triggering something when the EXACT word is in the message (right now the word is “test”), but I want to add a condition saying “if the word ‘test’ is anywhere in the message, then trigger happens”, so it could also trigger when the message is something like “blablabla test blablabla”.
Here’s my code as of right now:
alias: test notif
description: ""
trigger:
- platform: state
entity_id:
- sensor.sm_g781b_last_notification
attribute: android.text
to: {%- if is_state_attr('sensor.sm_g781b_last_notification.android.text') | contains('test') %}
action:
- service: light.turn_on
metadata: {}
data:
rgb_color:
- 211
- 29
- 29
brightness_pct: 100
target:
device_id: 273b38c9d6eb63a7d2cf1ab9168d24
mode: single
Obviously this doesn’t work at all.
I’ve tried a lot of different codes from looking at other topics here, like “value_template:”, but nothing I could make successfully work
Any help would be greatly appreciated!