Automation trigger numeric state

Hello guys,
i have a problem triggering my heatpump status automation.
My goal is to have the duration of my heatpump running in a sensor.
Therefor i use helper and created a “input_boolean.wp_status” and count the time this status is up with the following config in configaration.yaml:

sensor:
  - platform: history_stats
    name: Wärmepumpe Betriebsstunden
    entity_id: input_boolean.wp_status
    state: "on"
    type: time
    start: "{{ 0 }}"
    end: "{{ now() }}"
  - platform: history_stats
    name: Wärmepumpe Betriebsstunden Monat
    entity_id: input_boolean.wp_status
    state: "on"
    type: time
    start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: "{{ now() }}"

Which works good.

But now i wanted to create automations which shut this helper on and off .

i tried with:

alias: Wärmepumpe Status An
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    for:
      hours: 0
      minutes: 0
      seconds: 0
    above: '10'
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.wp_status
mode: single

for shutting on and the following for shutting off:

alias: Wärmepumpe Status Aus
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    below: '100'
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition: []
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.wp_status
mode: single

But this does not get triggered by the sensor “sensor.hp_sdm630_total_system_power_demand”
Which has the follwing status:

i could not get it working and need your help.
Or is there a smarter way to get to my “goal”?
Thank you in advance

Numeric State Trigger will trigger only when the entity’s value crosses the threshold you specified.

The following will trigger the moment the sensor’s value decreases from below 10 and crosses the threshold of 10 to above 10.

  - platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    above: '10'

It won’t continue to trigger if the sensor’s value continues to increase. It also won’t trigger again until the sensor’s value first decreases below the threshold of 10 and then increases above it

The sensor’s current value is 19.51. If it never decreased below 10 before increasing to 19.51 then it never triggered the Numeric State Trigger.

Maybe I am totally off (if so, sorry for that), but if I am not mistaking you don’t want to know the duration, bit you want it to toggle (turn off or on) after a certain time.

If so, why not just put a time in a input_datetime-helper and set a trigger to input_datetime-helper + timedelta( hours = x, minutes = y ) or you could even put off-time directly into the helper.

Third, but less reliable option in case of a reboot is to check the last_changed timestamp of the heat-pump switch and add the timedelta to that, to have it triggered.

Yes i want the toggle and have another sensor which is counting the “on” state of this input_boolean.wp_status.
This is working and tested.

Thank you very much for explanation.
I played around some more time and got it fixed with the following automations:

alias: Wärmepumpe Status An
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    for:
      hours: 0
      minutes: 0
      seconds: 0
    above: '100'
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.wp_status
mode: single

and:

alias: Wärmepumpe Status Aus
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    below: '100'
    for:
      hours: 0
      minutes: 0
      seconds: 0
condition: []
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.wp_status
mode: single

And this works! Thank you.

Your requirements appear to have changed because now all you want to do is trigger when the sensor’s value is above or below 100. That’s easily done with a single automation.

alias: Wärmepumpe Status
trigger:
  - id: 'on'
    platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    above: '100'
  - id: 'off'
    platform: numeric_state
    entity_id: sensor.hp_sdm630_total_system_power_demand
    below: '100'
condition: []
action:
  - service: 'input_boolean.turn_{{ trigger.id }}'
    target:
      entity_id: input_boolean.wp_status
mode: single
2 Likes

Maybe this is due my English,sorry for misunderstanding. I will update to your proposal.
Thank you again