OH 3 create Rule (or other solution ) to trigger starttime and endtime

@all out there

first a happy new year to all

Now i would explain my problem:

I have a wallbox and read the values with modbus but unfortunataly ther are no data points to read out the ‘starttime’ and ‘endtime’ and time that triggers the duration of charging the car.

So i want to create a proxy item (or items) for that, but dont know how to combine that with a rule.

I think i can do that with the wallbox status item when status changed to ‘charging’ i want to set ‘start datetime’ and when it is finished loading the car and status changed to ‘Terminated (or End)’ set ‘end datetime’, but i dont know how to do that with a rule or any other solution.

To make it clear in a view words:

  1. Item ‘WallboxState’ changed State from ‘Idle’ to ‘Charging’ —> set ‘DateTime’ as Starttime Value
  2. trigger time in a value until… Step 3
  3. Item ‘WallboxState’ changed State from ‘Charging’ to ‘Terminated’ → set 'DateTime as Endtime Value

next Time when this Progress starts again check if there is a Starttime set as value of an Item and reset to start a new count

I hope it is clear what i want to do and sombody can help my or give me a hint to that.

cu Holger

There are DateTime Items. Trigger a rule when the Indicator Item changes to Charging and postUpdate to the DateTime Item now.

In another rule trigger when the Indicator Item changes to Idle. In this rule, calculate what ever it is your are calculating.

This should be very straightforward in Blockly.

Now i have created two DateTime Items to trigger Start and Stop

DateTime AmtronStartCharge                         "Charging Start"                          <datetime>
DateTime AmtronEndCharge                           "Charging End"                            <datetime>

and i have two rules

rule "Amtron set Start DateTime"

    Item AmtronState changed from 1 to 3
    postUpdate(AmtronStartCharge, new DateTimeType())

rule "Amtron set End DateTime"

    Item AmtronState changed from 3 to 5
    postUpdate(AmtronEndCharge, new DateTimeType())

that works fine for me, but what i now want to do is to trigger the time between ‘Start’ and ‘Stop’, and store that in an Item, so i can see in habpanel how long the charging is in progress.

blocky doesen’t work for me because my Items are all text based and not in the model.

Cu Holger

That sounds like something you would calculate in a rule that triggers at stop time.
You’ve already got one of those - add some calculating code to it.

Blockly does not care at all about the model. An Item is an Item.

that’s my problem at the moment, i am not so good in coding and have searched the forum but didn’t find the right code snippets that i might can use, and do i have to create another Item to store the calculated time, so i can see during the charging progress how many time is passed since start

please can you give me a hint

cu Holger

That is a very different question to calculating runtime at the end, and it is more complicated because you have to update it every … what do you want, up to the minute reports?

yes thats exactely what i want to do, i want to see the chargetime since start, so if i look at my habpanel i see the car is loading with xxKwh, it has loaded xx kwh so far and the time since start charging is xx min.

I hope it’s clear now, it’s like a progressbar, but progressbar is more complicated

cu Holger

Okeydoke, it is a complicated task that you have chosen for yourself.
You might use a Number:Time Item for your ‘counter’, that will hold a time duration.
Assuming your preferred rule usage is xxx.rules files, I think I’d use a timer.
Allocate a ‘global’ variable to hold a timer reference.
When charging begins, set your ‘counter’ to zero.
Also create a timer to run in one minute’s time, storing the referece in your ‘global’.
When the timer code runs, have it check to see if charging is still taking place.
If so, increment your ‘counter’ and reschedule itself for another minute.
If not, just exit.

This sounds complicated, but really its just repurposing the standard kind of thing used for door timers.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.