I'm struggeling a bit with the following case;
I want to have the last time a device is switch ON and in most case the last ON time is not equal to the lastUpdate property.
So I decided to save the Time() to an (global)data variable, but that isn't working.
Look like dzVents is not saving the Time() object when doing something like:
domoticz.globalData.BadkamerLastMotionOn = Time()
or
domoticz.data.BadkamerLastMotionOn = Time()
both variables are define in OR global_data.lua OR in the script itself.
Is this a known "bug" and/or has somebody an idea how to save the last ON time to persistent storage?
Persistent (global)data save Time()
Moderator: leecollings
-
Freemann
- Posts: 94
- Joined: Thursday 24 November 2016 14:55
- Target OS: Linux
- Domoticz version: >=Béta
- Location: Netherlands
- Contact:
Persistent (global)data save Time()
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam
https://www.frijduurzaam.nl
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam
https://www.frijduurzaam.nl
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Persistent (global)data save Time()
Don't save the Time object but just the raw value. If you use historical=true with persistence you automatic get a time stamp on your data. So, define your persistent variable with history = true and maxItems = 1 and simply store the state value in there. Then you can easily read the time stamp of the current value. Check the documentation about historical data.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
Freemann
- Posts: 94
- Joined: Thursday 24 November 2016 14:55
- Target OS: Linux
- Domoticz version: >=Béta
- Location: Netherlands
- Contact:
Re: Persistent (global)data save Time()
So easy... (zo simple)
Hero (HELD)!!
Hero (HELD)!!
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam
https://www.frijduurzaam.nl
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam
https://www.frijduurzaam.nl
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Persistent (global)data save Time()
Just for completeness; dzVents is capable of storing the time object in persistent storage.Freemann wrote: Monday 18 June 2018 12:30 I want to have the last time a device is switch ON and in most case the last ON time is not equal to the lastUpdate property.
So I decided to save the Time() to an (global)data variable.
Look like dzVents is not saving the Time() object when doing something like:
domoticz.globalData.BadkamerLastMotionOn = Time()
or
domoticz.data.BadkamerLastMotionOn = Time()
... has somebody an idea how to save the last ON time to persistent storage?
see example code and resulting datafile
- Spoiler: show
- Spoiler: show
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
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Persistent (global)data save Time()
Yes but it is not needed as I explained above. You can however extract the raw time string and store that and feed that back into Time() when you need it again.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
Freemann
- Posts: 94
- Joined: Thursday 24 November 2016 14:55
- Target OS: Linux
- Domoticz version: >=Béta
- Location: Netherlands
- Contact:
Re: Persistent (global)data save Time()
So to "reuse" this topic;
Trying to make my variables global available, but not getting there.
how should I use the global define variables for getting/setting in my scripts?
Tried some variations like;
for setting:
I'm not getting the __data_global_data.lua to show data...
and should I define the global_data vars in my "local" scripts again?
[SOLVED] and maybe it can help somebody
found it after some "testing/debugging";
/home/user/domoticz/scripts/dzVents/scripts/global_data.lua looks like;
normal dzvents script is doing for historical setting;
normal dzvents script is doing for historical getting;
Trying to make my variables global available, but not getting there.
how should I use the global define variables for getting/setting in my scripts?
Tried some variations like;
for setting:
Code: Select all
domoticz.globalData.motionVar.add('Foo')
domoticz.globalData.motionVar = 'On'
domoticz.data.motionVar.add('Foo')
domoticz.data.motionVar = 'On'and should I define the global_data vars in my "local" scripts again?
[SOLVED] and maybe it can help somebody
found it after some "testing/debugging";
/home/user/domoticz/scripts/dzVents/scripts/global_data.lua looks like;
Code: Select all
data = {
LastMotionOn = { history = true, maxItems = 1}
}Code: Select all
domoticz.globalData.LastMotionOn.add('On')Code: Select all
domoticz.globalData.LastMotionOn.get(1).time.secondsAgoDomotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam
https://www.frijduurzaam.nl
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam
https://www.frijduurzaam.nl
Who is online
Users browsing this forum: Bing [Bot] and 1 guest