Time Counter Logic Homematic/ Raspberrymatic

Hello community,
I am facing a problem with Homematic/ Raspberrymatic that is difficult for me to solve.

The task is as follows:

There are several valves from which I have extracted the valve opening and added them via script.
The result is the system variable “Ventilöffnung_All”.

I would now like to create a program that contains the following logic:

If “Valveopening_All” >= 250, then
Start Time Counter (1800 seconds).

If the value of “Ventilöffnung_All” < 250 within this time, the Time Counter is reset and as soon as “Ventilöffnung_All” >= 250 again, it starts again from the beginning.

If the value of “Valve_opening_all” is still >= 250 after 1800 seconds, then device XYZ should be triggered to on.

I’ve already tried a few things and I can’t get any of the solutions to work properly because I can’t get a proper time counter to work…

Maybe you can help me or maybe you know a template code which I can change.

Many thanks in advance

Just create a Automation

the Trigger would be

Valveopening_All above 250

  - trigger: numeric_state
    entity_id:
    - sensor.Valveopening_All
    above: 249

Create a Help timer “Valveopening_All”

for 1800 well it only know hours:min:sec 03:00:00

  actions:
  - data:
      duration: 03:00:00
    target:
      entity_id: timer.Valveopening_All
    action: timer.start

so that be on automation

now the other one

  - trigger: numeric_state
    entity_id:
    - sensor.Valveopening_All
    below: 249

add a condition check if timer running

condition: state
entity_id: timer.Valveopening_All
state: active

in the action part we can cancel a timer

  actions:
  - target:
      entity_id: timer.Valveopening_All
    data: {}
    action: timer.cancel

now if the timer is

trigger: state
entity_id:
  - timer.Valveopening_All
to: idle

check the condition

condition: numeric_state
entity_id: sensor.Valveopening_All
above: 249

this should point down the right track well a track

there more than one way to skin this cat.
i like written in YAML

but you could create in the GUI

dont try and do all in one automation

use each automation to solve 1 problem

once you get your haed around you mite beable to in 1 automation.

let us know how you get on.

Hello Myle,

in Home Assistant this would be absolutely no problem for me, but I want/need to programme this in the Raspberrymatic environment, that’s where the problem lies :wink: