Reuse checked values in automation

My automation alerts me if the room temperature is above 24° C : it works
BUT…
I get a notify when it reaches 24.5, another one when it reaches 25, another when 25.5, another then is goes back to 25…
I think you get the point! :wink:

I could create a boolean that change state the first time, so I only get one notification but I would like to have all and only incremental values:

  • "notify me when T. reaches 24.5, then 25, then 25.5, (NOT 25), then 26…

Can I save the previous value, then reuse it (and put it back at midnight) ?

- id: 'NotifyCondSaraTEMP24'
  alias: Check Temperatura Sara (> 24 °C)
  trigger:
    platform: numeric_state
    entity_id: sensor.inside_temperature_saraap69238_inside_temperature
    above: "24"
  condition:
    - condition: time
      after: '08:00:00'
      before: '23:59:00'
  action:
    - service: notify.pbulletNote
      data_template:
        title: Home Assistant
        message: >
           Temperatura Sara {{ trigger.to_state.state }} °C

You could create a statistical sensor and use the max value attribute as part of the trigger / condition.

1 Like

Well, that’s interesting. I don’t think it’s supposed to do that. At least according to the docs, it seems to imply it should only trigger when it crosses the threshold - in your case, going from 24 or below to above 24. It shouldn’t trigger when it goes from above 24 to another value also above 24. Hmm.

Anyway, you can save the new value in an input_number via something like:

  action:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.hwm
        value: "{{ trigger.to_state.state }}"

And then add a new condition something like the following (if, e.g., you want to only report higher values than anything that has been reported so far):

  condition:
    - condition: template
      value_template: "{{ trigger.to_state.state > input_number.hwm }}"

And lastly add an automation that triggers at midnight that sets input_number.hwm to zero.

Haven’t tested any of this, but I believe this (or something close) could work for you.

So I just browsed through the code, and as best I can tell, once it goes above 24 (in your case), and the actions are run, it should not run the actions again until it goes to 24 or below and then back to above 24, or it goes to a state of unavailable or unknown and then back to above 24.

Are you sure the sensor’s value is not temporarily dipping below 24 or going to unavailable or unknown?

Schermata%20del%202018-05-31%2022-35-48

Thanks @pnbruckner for digging into it!
As you can see there is no throttling around 24 and I checked in the logbook but I only see “Cool” and “Off”.
I will monitor my notifications and I will analyze the problem from this point of view!

Thanks!

Wait, does sensor.inside_temperature_saraap69238_inside_temperature always have a numeric value, or does it sometimes have a value of Cool or Off? Or are you saying another, related entity shows as Cool and Off?

You might want to search your HA log to see the actual values sensor.inside_temperature_saraap69238_inside_temperature takes on over time. E.g., you could do a search like this:

grep 'new_state=<state sensor.inside_temperature_saraap69238_inside_temperature' home-assistant.log

And, specifically, you can see if it ever has a value of unavailable or unknown doing something like:

grep 'new_state=<state sensor.inside_temperature_saraap69238_inside_temperature=unknown' home-assistant.log

Thank @pnbruckner you were right!
I had some network problems!!

Thank a lot for digging it out! :grinning:

1 Like