Trying to build a script which calculates electricity costs based on variable pricing (per hour).
I have a script running which updates a domoticz device with the current price (updates every first minute of the hour). Because the price is updated at minute 0 of the hour, and the electricity usage is only available short after the hour I have a timing challenge.
My thoughts: Create as script which retreives the current price at minute 58 of the hour, pause for 5 minutes and then collect the usage of the past hour and calculate the costs.
In concept this looks ok to me, but how to have a dz-script waiting for 5 minutes? I could build this in bash, but would like to try putting it in Domoticz itself.
Thanks,
Jeroen
Let script pause for few minutes
Moderator: leecollings
- jvdz
- Posts: 2441
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Let script pause for few minutes
You do not want any event script to pause/sleep as the event system is single threaded and any script running for longer than 10 seconds is killed.JeroenG wrote: Sunday 08 January 2023 16:01 In concept this looks ok to me, but how to have a dz-script waiting for 5 minutes? I could build this in bash, but would like to try putting it in Domoticz itself.
So those steps need to be separate steps and the first one could set a persistent variable which is then used in the second script.
The whole think could also be put into one script with 2 triggers, and then do these steps base on the current time.
-
JeroenG
- Posts: 27
- Joined: Monday 06 January 2020 20:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 20231
- Contact:
Re: Let script pause for few minutes
This makes sense, did not think of itjvdz wrote: Sunday 08 January 2023 16:13 You do not want any event script to pause/sleep as the event system is single threaded and any script running for longer than 10 seconds is killed.
Thanks!
-
Sarcas
- Posts: 86
- Joined: Wednesday 11 October 2017 8:50
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1ß
- Location: Friesland
- Contact:
Re: Let script pause for few minutes
Never tried this, but could you perhaps use a virtual switch and use light.switchOn().forMin(5) to turn it on for a few minutes and use that virtual switch as trigger device so you 'catch' it again after 5 minutes when it goes off, and then do the calculations you want...?
--
Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
Domoticz on rPi4 - RFXCOM RFXtrx433 USB - ZW090 Z-Stick Gen5 EU - IKEA Tradfri - Philips HUE - YouLess meter - SolarEdge
Who is online
Users browsing this forum: No registered users and 1 guest