HA: Trigger using Text value from notificaiton

0

In this Code, we are basically basing the trigger on the presence of a specific text value from a sensor that has a text-like notification from a device linked to Homeasistant via App ( pixel mobile notification after giving this sensor a custom device class (device_class: last_notificaiton)

Or Logic

  • Trigger Name = lowsugar
  • Alias or how it appears = Approaching low
  • The platform is template –> value_template
  • We are looking for the words (glucose approaching Low) in either notification (last and last removed) on the mobile. That appear on the phone from other apps but on the same device ( after giving access on the device to those notifications on the Home Assistant app + Device privacy)
  • This template is for OR logic.
 
platform: template
value_template: >-
  {{ 'glucose approaching Low' in
     [ states('sensor.medtronic_pixel_last_notification_2'), 
       states('sensor.medtronic_pixel_last_removed_notification_2') ] }}
id: lowsugar
alias: Approaching Low

AND Logic

  • This template is for AND logic.
  • For this to trigger, it should have the in both notifications at the exact time text (glucose approaching Low) in both the last and last removed notifications ( I didn’t use this as this isn’t ideal)
 
platform: template
value_template: >-
  {{ 'glucose approaching Low' in states('sensor.medtronic_pixel_last_notification_2') and 
     'glucose approaching Low' in states('sensor.medtronic_pixel_last_removed_notification_2') }}
id: lowsugar
alias: Approaching Low
Share.

About Author

A BDS in dentistry and MBA in business and marketing. I am the founder of OziDent.com and enjoy the gym and mental challenges.

Leave A Reply