Numeric value trigger automation

Hi,

I have this automation to trigger my heatpump hot water production when I produce over 3kw of excess solar energy. For that I use a numerical value trigger.
I also want to add a time condition that it would only do so when it is after 12.00 and before 17.00 to avoid the peek electricity price.

The problem is that if it is a sunny day and the excess production was already above 3kw before 12.00 then the automation is not triggered.

Does anybody has a idea how to work around that?

Pierre

alias: solar water on
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.smart_gateways_smart_meter_power_produced
    for:
      hours: 0
      minutes: 5
      seconds: 1
    above: 3
condition:
  - condition: time
    after: "12:00:00"
    before: "17:00:00"
action:
  - metadata: {}
    data: {}
    target:
      entity_id:
        - switch.ctc_hotwater_mode_comfort
        - switch.ctc_price_mode
    action: switch.turn_on
mode: single

Yes,

Set another trigger, time at 12.00
And another condition, that the numeric state is above 3.

This way it will trigger both at 12 and above 3.
But only run if both conditions are true.

Thanks for the swift answer, that indeed makes perfect sense!

But does it mean that if it is not above 3 at 12 but it is at 13 the automation will not be triggered because it runs only once at 12?

No, it will trigger again once above 3 and then pass and run the action.
So basically:

It triggers once at 12.00 by one of the triggers.
Checks if the time is 12.00-17.00 AND that the numeric state is above 3.
If yes, then it runs your action.
If numeric state at 12.00 is below 3, it will not run the action.

Then if for example the time is 13.05 and the numeric state goes above 3, then the automation is triggered again by the numeric state trigger.
Once again it checks the conditions, and since both returns true then the action runs.

Edit: think of this in this way, an automation can be triggered by multiple different triggers but the action will only run if all conditions pass.

Edit2: when I wrote “set another trigger” I mean set one additional trigger. So you trigger at both 12.00 and above 3 :slight_smile:

Ok, perfect!
Thank you very much for the explanation! :slight_smile:

You can post your yaml here after the changes if you like :slight_smile:

I think it should work now.

alias: solar water on
description: ""
trigger:
  - platform: time
    at: "12:00:00"
  - platform: numeric_state
    entity_id:
      - sensor.smart_gateways_smart_meter_power_produced
    for:
      hours: 0
      minutes: 5
      seconds: 1
    above: 2.5
condition:
  - condition: time
    after: "12:00:00"
    before: "17:00:00"
  - condition: numeric_state
    entity_id: sensor.smart_gateways_smart_meter_power_produced
    above: 2.5
action:
  - metadata: {}
    data: {}
    target:
      entity_id:
        - switch.ctc_hotwater_mode_comfort
        - switch.ctc_price_mode
    action: switch.turn_on
mode: single

Looks good, hopefully it works to your satisfaction :+1: