Simple Blockly rule to calculate consumption (item state gain) from the start of the day (Midnight)

Is there any simple rule in blockly to calculate the item state gain for each day, from Midnight. I would like to use that rule to calculate daily usage of water, energy etc.

You could use the persistence blocks to do that. What do you have in the item state? The absolute or the relative value?

Item state is the reading from my water and heat energy meter, so each time water or heat is used the value of usage is added to the total item state. I was looking on those persistence blocks and maybe this is solution:

The rule is executed each time the reading from the meter is updated and some seconds after the Midnight.

1 Like

Ok, let me know if it doesn’t do the trick and we then move on from there.

Looks that it works well:


Thanks!

1 Like

Great, good to hear. Then go on “Blocklying” :wink:

Michal,

I know it’s a post of more than a year ago, but I wanted to do the same think, but I can’t find this block.
Schermafbeelding 2024-02-05 141338

In which library can I find this?

Thanks

you can check my rule templates for this.

This has been taken from a marketplace block library: Date and Time

The official block looks like this

image

Hans,

It’s working perfect with your rule template.

1 Like