Notify Mobile Companion App Devices

  1. Look at alerts - you might want to consider those…

  2. Also consider in your automation that sends the notification, you can also set whatever value you want into a helper, and then in that same automation put a condition. The helper can be the last time the notification was sent, and the condition used later can check the value against the current time. For example I have some automations that have a condition so they do not take place if a timestamp in an input_text helper (it would not work with datetime helpers for some reason so I used input_text and never bothered to go back and figure out why) - was less than 5 minutes ago. For example, if I manually turn off the basement laundry ceiling light, that timestamp I would place into an input_text named input_text.last_manual_off_basement_laundry_ceiling. Then my condition to take an action would not proceed if it had been turned off manually within the last 5 minutes - had this code:

condition: template
value_template: >-
  {{ (float(as_timestamp(now())) -
  float(states('input_text.last_manual_off_basement_laundry_ceiling'),0)) > 300
  }}
  • the above in the visual editor of the condition for the automation looks like this:

Note, the datetime comparison I found only seemed to work if both values were converted to floats before comparing them (to see if the difference was more than 300 seconds).

Hope that helps

Thanks for your response. I attempted creating some helpers and the condition you mentioned. I’m still missing something I think. I guess I really didn’t understand how to create an input_text helper as you suggested, but it got me thinking.

I created the threshold sensor with a lower limit of 25 and then came up with last triggered as the condition in the automation. Does something like this make sense?

Threshold sensor

entity_id: sensor.gw2000b_feels_like_temperature
hysteresis: 0
lower: 25
position: below
sensor_value: 17
type: lower
upper: null
friendly_name: Feels Like Under 25

Condition Template
{{ (float(as_timestamp(now())) - float(states('last_changed.last_time_feels_like_under_25'),0)) > 900 }}

Settings (in the sidebar) → Devices and services → Helpers (tab on top) → “+Create Helper” button in the bottom right corner → then pick “text” from the list of helper types.

My code to populate the helper (for the above example) looks like this, in the action part of an automation:

data:
  value: >-
    {{
    as_timestamp(states.sensor['basement_laundry_ceiling_light_off_context'].last_changed)
    }}
target:
  entity_id: input_text.last_manual_off_basement_laundry_ceiling
action: input_text.set_value

(FYI: Don’t worry about “sensor[‘basement_laundry_ceiling_light_off_context’]” for this example, that is a template sensor I have that will if you ask send you down a rabbit hole with a long explanation of something unrelated. Suffice it to say that almost every sensor has a “.last_changed” property which is a linux timestamp value.)

Thank you sir. I’ll give that a try.

Hey @genomez , I just discovered in reading through the forums, something already built for us for time comparisons used in HA… the “timedelta(…)” function! So for example instead of:

float(as_timestamp(now())) - float(states('input_text.last_manual_off_basement_laundry_ceiling'),0)) > 300

this can be done (I think I have the syntax right):

now() - as_datetime(states('input_text.last_manual_off_basement_laundry_ceiling')) > timedelta(minutes=5)

Great! I’ll try that one tomorrow since I’m struggling with the other lol

Well, I’m clearly totally lost. As a reminder, I’m trying to get a notification for when my weather station reports a Feel’s Like temperature of under 25 degress (in this example), but without spamming me when it wobbles between over and under.

I’ve created a threshold sensor that reports “on” when the temperature drops below 25 degrees and “off” above 25 degrees. That works and sends the notification properly, but I get too many notifications.

I’ve also created an input_text helper.

I’ve tried many different things so I thought I’d post the full automation yaml in hopes you see whatever the dumb mistake is. It’s driving me crazy! Thanks for all the help and looking at this mess!

description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.last_time_feels_like_under_25
conditions:
  - condition: template
    value_template: >-
      {{ now() - as_datetime(states('input_text.last_time_feels_like_under_25'))
      > timedelta(minutes=5) }}
    enabled: true
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: last_changed
    target:
      entity_id: input_text.last_time_feels_like_under_25
    enabled: true
  - action: script.notify_mobile_app_devices_2024_08
    metadata: {}
    data:
      notify_devices:
        - 327f7595e3a9b
      data_notification_icon: mdi:temperature-fahrenheit
      notify_title: Weather Station
      notify_message: Feel's Like Temperature is below 25°
      data_group: Weather
      data_channel: Weather
      data_importance: high
      data_clickaction: sensor.ecowitt_outdoor_temperature
mode: single

use the hysteresis function of the threshold sensor to reduce the number of notifications

Thanks for the suggestion. I considered the hysteresis function and that might be ok for a regular temperature notification. The problem I could see with Feel’s Like Temperature is it can swing so far in short periods of time. If I used ‘5’ as an example, that would lower the notifications, but it flucuates so much it would still be noisy. If I set it to ‘10’ that would help for windy days, but then limit it for calmer days.

That’s why I’ve been trying to figure out a way to simply (obviuosly not so simple) throttle/mute/snooze that notification for X amount of time. It sounds simple, but it clearly isn’t (at least for me). I assumed if I could figure it out for this one I could then incorporate it into other notifications.

I tried adding a hysteresis value of 5 to test and let it run overnight. It helped, but I still received 33 notifications. I guess I’ll try a value of 10 this time.

I thought I’d post a follow up to let you know what I did, just in case someone stumbles by this and wants an idea of one of the many ways to do it. It’s the best I could come up with for now. I created a threshold helper and a timer helper. I currently have the timer set to 10 minutes, but might adjust that. I’m certainly open to suggestions if anyone has some. Thank you!

Here is the full yaml.

alias: Feel's Like Notification Test
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.last_time_feels_like_under_25
    id: feel_like_trigger_id
    from: null
    to: "on"
conditions:
  - condition: state
    entity_id: timer.feels_like_notify_timer
    state: idle
    enabled: true
actions:
  - action: timer.start
    metadata: {}
    data: {}
    target:
      entity_id: timer.feels_like_notify_timer
  - action: script.notify_mobile_app_devices_2024_08
    metadata: {}
    data:
      notify_devices:
        - 327f7595e3a9b
      data_notification_icon: mdi:temperature-fahrenheit
      notify_title: Weather Station
      notify_message: >-
        Another-Feel's Like Temperature is low:

        {{(states('sensor.gw2000b_feels_like_temperature'))}}{{state_attr('sensor.gw2000b_feels_like_temperature',
        'unit_of_measurement')}}
      data_group: Weather
      data_channel: Weather
      data_importance: high
      data_clickaction: sensor.gw2000b_feels_like_temperature
mode: single
1 Like

What am I missing here? Installed the blueprint. Created a test script. Tested it out in developers tools with some parameters. How does the yaml that gets created get associated with the script? In other words how do I link the two so I can call the scipt with the data in an automation?

This Blueprint is a script, so once downloaded and imported you will have an new script like: script.name_that_you_used_to_import_it . Next up is to go to your automations or other scripts and use it as an action

  1. Open or create a automation (or script)

  2. Add a new Action and search for this imported script

  3. Fill in the details to send notification to your Mobile App devices

Ahh, Thanks. The opening description only talked about testing it in dev tools. I think it would of been better to test it using a trigger where you set the values and then just run the action. Then you don’t have to copy the settings from testing to the trigger. First time I had a script from a blueprint so i was a bit confused. Thanks.