Time how much a device is ON [Solved]
Moderator: leecollings
-
- Posts: 3
- Joined: Friday 03 May 2019 2:48
- Target OS: -
- Domoticz version:
- Contact:
Time how much a device is ON
Hi, I want to achieve this effect using dzVents
https://www.domoticz.com/forum/viewtopic.php?t=18848
I don't know how to set time for this counter, there is no problem when the counter is just counter but when I change it to time version I have a problem. Can anybody help?
https://www.domoticz.com/forum/viewtopic.php?t=18848
I don't know how to set time for this counter, there is no problem when the counter is just counter but when I change it to time version I have a problem. Can anybody help?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
Can you please explain in more detail what you try to achieve and what the problem is you face ? For me it's unclear from the above description and after reading the topic.16pxdesign wrote: ↑Friday 03 May 2019 2:52 Hi, I want to achieve this effect using dzVents
https://www.domoticz.com/forum/viewtopic.php?t=18848
I don't know how to set time for this counter, there is no problem when the counter is just counter but when I change it to time version I have a problem. Can anybody help?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 3
- Joined: Friday 03 May 2019 2:48
- Target OS: -
- Domoticz version:
- Contact:
Re: Time how much a device is ON
Ok so I have dummy counter and I set the counter in Domoticz as time counter. When I try to use a method "updateCounter()" and pass any number it not change any state of this counter. This method works for the normal counter but doesn't want to work with a time counter. So my question is how I can set time counter values in dzVents
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
Ok understand now but have to disappoint you. It cannot be done from dzVents. In fact I asked the core developers some time ago how to update this from the API and no one could give me an answer. So either the developer that introduced this (maybe for future use) is no longer developing here or it is a left over from the past.16pxdesign wrote: ↑Friday 03 May 2019 19:25 Ok so I have dummy counter and I set the counter in Domoticz as time counter. When I try to use a method "updateCounter()" and pass any number it not change any state of this counter. This method works for the normal counter but doesn't want to work with a time counter. So my question is how I can set time counter values in dzVents
But if you tell what is it that you want to measure, I might be able to help using another solution than a time counter.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 3
- Joined: Friday 03 May 2019 2:48
- Target OS: -
- Domoticz version:
- Contact:
Re: Time how much a device is ON
OK, Good to know, thanks. I got 3 heaters but I need to know how long they work in minutes or hours. I know you got logs but it hard to read total time it been ON or OFF.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
How do you want to record the heaters on time ?16pxdesign wrote: ↑Friday 03 May 2019 23:43 OK, Good to know, thanks. I got 3 heaters but I need to know how long they work in minutes or hours. I know you got logs but it hard to read total time it been ON or OFF.
Could be stored in a domoticz variable, a counter device per heater, One or more text devices, stored in the description field of these heaters and probably in a couple of other ways.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- felix63
- Posts: 244
- Joined: Monday 07 December 2015 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Gouda
- Contact:
Re: Time how much a device is ON
I have a similar use case. When a device is switched off I want to update a virtual device - (timer) counter so I can track the time the device has been on. In dzvents I tried but can't get it to work.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
Could look like below
Code: Select all
return
{
on =
{
devices =
{
1324, -- device for which you want to record the On time.
},
},
data =
{
lastOn = { initial = 0 },
},
logging = {
level = domoticz.LOG_DEBUG,
marker = 'timeKeeper',
},
execute = function(dz, item)
local secondsActive = 0
local iCounter = dz.devices('timeKeeper') -- define as virtual incremental counter
if item.active then
if dz.data.lastOn == 0 then dz.data.lastOn = os.time() end
return
else
if dz.data.lastOn == 0 then
secondsActive = os.time() - item.lastUpdate.dDate
else
secondsActive = os.time() - dz.data.lastOn
dz.data.lastOn = 0
end
iCounter.updateCounter(secondsActive)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- felix63
- Posts: 244
- Joined: Monday 07 December 2015 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Gouda
- Contact:
Re: Time how much a device is ON
Works, thanks. But I am still completely baffled by (incremental) counters.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
Do you have specific questions on how they work?felix63 wrote:Works, thanks. But I am still completely baffled by (incremental) counters.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
- felix63
- Posts: 244
- Joined: Monday 07 December 2015 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.1
- Location: Gouda
- Contact:
Re: Time how much a device is ON
I am trying to find some info on:
- difference between counter, managed counter and incremental counter
- what is the function of counter type 'Time', and how to use it from a script. The following command for instance doesn't do anything on a counter of type time.
- difference between counter, managed counter and incremental counter
- what is the function of counter type 'Time', and how to use it from a script. The following command for instance doesn't do anything on a counter of type time.
Code: Select all
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=1
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
counter: When you send something to the counter the existing value is replaced.
incremental counter: When you send something to this one the value is added to the existing value.
managed counter: counter without automatic history. You have to take care of the history yourself using API 's
I asked the core developers months ago how to update this from the API and no one could give me an answer. So either the developer that introduced this (maybe for future use) is no longer developing here or it is a left over from the past.- what is the function of counter type 'Time', and how to use it from a script. The following command for instance doesn't do anything on a counter of type time.
No one stepped forward until now on how to use this. (if at all possible)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 2
- Joined: Tuesday 18 May 2021 18:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Time how much a device is ON
Hi waaren,
I tried your code and it works for logging on-time for each event.
But what if you'd like a counter that records total time a device has been turned on over a longer period (accumulated time)?
Do you have an example of that as well?
I tried your code and it works for logging on-time for each event.
But what if you'd like a counter that records total time a device has been turned on over a longer period (accumulated time)?
Do you have an example of that as well?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Time how much a device is ON
Maybe I do not completely understand what you mean but if you used incremental counter as device type when creating the counter it should already do just that. If not please elaborate on your question.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 2
- Joined: Tuesday 18 May 2021 18:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Time how much a device is ON [Solved]
Hi, and thanks for replying. Sorry for not answering sooner.
Well, I learned something new today. Created a new counter but incremental instead. works fine!
Thanks!
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Time how much a device is ON
Is it possible to get this in Minutes or Hours?
Re: Time how much a device is ON
Is it possible to get this in Minutes or Hours?
- Treve
- Posts: 107
- Joined: Thursday 05 November 2015 10:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v4.11474
- Location: Rotterdam, NL
- Contact:
Re: Time how much a device is ON
FYI: Waaren will never answer again, he passed away.
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.
for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.
for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
Re: Time how much a device is ON
maybe anybody other knows?
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Time how much a device is ON
Yes but you will have to modify the script to have it give minutes or hours to the counter instead of seconds (value SecondsActive).
Be aware you have to make it an integer so be careful with rounding. See https://domoticz.com/forum/viewtopic.php?t=26512
Edit: Also a Counter divider value of 60 (for minutes) or 3600 (for hours) should work.....
Be aware you have to make it an integer so be careful with rounding. See https://domoticz.com/forum/viewtopic.php?t=26512
Edit: Also a Counter divider value of 60 (for minutes) or 3600 (for hours) should work.....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: habahabahaba and 1 guest