Page 1 of 1
Updating Last Seen - with no notification
Posted: Wednesday 06 March 2019 17:48
by pipiche
I'm looking for a way to update a domotciz device in order to get the 'last seen' updated, without triggering any notifications ( no trigger of LUA or dzVent script)
Is there a particular way to do that ? As the Update Api from the Python Framework always trigger notification, which could be annoying.
The main issue today is if you have a door sensor, it only update its state on Domoticz when someone Open or close the door. However this sensor is communicating on a regular basic like sending battery information ... ( for instance Xiaomi is sending every 10' a status update). It would be annoying to get a notficiation every 10' while nothing really happen except that the device is alive!
Re: Updating Last Seen - with no notification
Posted: Thursday 07 March 2019 4:56
by Dnpwwo
Sounds like you are really looking for a kind of 'Device.Touch' function.
I would prefer adding an extra function like that rather than continuing to overload the Device.Update function.
Re: Updating Last Seen - with no notification
Posted: Thursday 07 March 2019 7:39
by pipiche
I think you found the point and agree with you. This is a kind of device heartbeat.
Is that something making sense ?
Envoyé de mon iPhone en utilisant Tapatalk
Re: Updating Last Seen - with no notification
Posted: Thursday 07 March 2019 11:40
by Dnpwwo
Pushed an experimental 'Device.Touch()' function to the beta channel.
Does that do what you need?
Re: Updating Last Seen - with no notification
Posted: Thursday 07 March 2019 12:36
by pipiche
Thanks, I have updated the code on my end, Set clause was missing.
It is now on test
Envoyé de mon iPhone en utilisant Tapatalk
Re: Updating Last Seen - with no notification
Posted: Thursday 07 March 2019 13:51
by pipiche
pipiche wrote: Thursday 07 March 2019 12:36
Thanks, I have updated the code on my end, Set clause was missing.
It is now on test
Envoyé de mon iPhone en utilisant Tapatalk
Line 1434 of PythonObjects.cpp - 'SET' was missing in the UPDATE statement
Code: Select all
m_sql.safe_query("UPDATE DeviceStatus [b]SET [/b]LastUpdate='%s' WHERE (ID == %s )", TimeToString(NULL, TF_DateTime).c_str(), sID.c_str());
Re: Updating Last Seen - with no notification
Posted: Friday 08 March 2019 9:31
by pipiche
@Dnpwwo, I think that API is perfect and doing what it should do.
I'm just wondering to avoid to much Write I/O if a Query should be done prior to write and if the delta between the Read Last Seen, and thhe time to write is below 1 minute, then we do not write .
What do you think ?
Re: Updating Last Seen - with no notification
Posted: Friday 08 March 2019 22:47
by pipiche
@dnpwwo
It looks that there is a side effect not working as expected.
For instance the Touch() is updating the Database , but it seems that the Devices structure seems not to be updated.
SO for example, if you try to access lastupdate from dzVent script it seems not updated accordingly
domoticz.devices(name).lastUpdate
Is that possible ?
Re: Updating Last Seen - with no notification
Posted: Saturday 09 March 2019 1:39
by Dnpwwo
@pipiche,
I think it is better to allow plugin developers to choose how often they call Touch(). This is easy to do by comparing the current time with Device.LastUpdate and only 'Touching' if the difference is greater than x seconds/minutes. Different authors will have different needs so imposing a restriction on them unnecessarily will just cause frustration.
The main event system reads device data prior to invoking the script but I don't know anything about dzVents so can't confirm it does the same. If the database is being updated correctly then I would suggest raising a separate issue on the dzVents sub-forum for this
Re: Updating Last Seen - with no notification
Posted: Saturday 09 March 2019 9:11
by pipiche
Dnpwwo wrote: Saturday 09 March 2019 1:39
@pipiche,
I think it is better to allow plugin developers to choose how often they call Touch(). This is easy to do by comparing the current time with Device.LastUpdate and only 'Touching' if the difference is greater than x seconds/minutes. Different authors will have different needs so imposing a restriction on them unnecessarily will just cause frustration.
Make sense.
Re: Updating Last Seen - with no notification
Posted: Saturday 09 March 2019 9:43
by waaren
pipiche wrote: Friday 08 March 2019 22:47
It looks that there is a side effect not working as expected.
For instance the Touch() is updating the Database , but it seems that the Devices structure seems not to be updated.
SO for example, if you try to access lastupdate from dzVent script it seems not updated accordingly
domoticz.devices(name).lastUpdate
Is that possible ?
My understanding of what you try to achieve with the Touch() function is that you update the LastUpdate field in the database but don't want Lua or dzVents to react (no script Trigger).
Without such a trigger dzVents will not renew it's device information.
This is by design and changing it will take away the big performance advantage of only getting device information when really needed and then get all information for all devices, variables, groups, scenes, cameras and settings in one pass.
Re: Updating Last Seen - with no notification
Posted: Saturday 09 March 2019 9:48
by pipiche
@waaren you are totally right.