Page 1 of 1

How can i get last state of device ?

Posted: Wednesday 02 August 2017 20:52
by landaisbenj
Hello.

I seek on french board, but we don't find a solution for my need.

I want to return last state of a device, and no lastupdate...

Like devicechanged table indicating the new state for the device that triggered the device event, can we have a table who contain last state ?

Because if i have a device who juste update to on and on and on and on, i can't do a notif for the first on without having 4 notif.

Re: How can i get last state of device ?

Posted: Saturday 12 August 2017 10:42
by zicht
You Can do a check with Otherdevices['devicenname']

so to avoid what you write :

Code: Select all

if (otherdevices['yourdevicename'] == 'On') then commandArray['yourdevicename']='Off' end
this would only change to off if current state is on

I agree i observed also :
There are sometimes conditions by timing that the script is fired again before commandarray has finished last action so other devices is still on off in the table. But i can live with that as it is not so often that happens (DB update or externa scripts running are causes)

Re: How can i get last state of device ?

Posted: Tuesday 12 September 2017 15:34
by landaisbenj
zicht wrote: Saturday 12 August 2017 10:42
this would only change to off if current state is on
Yes but if my device send a 'on' signal three time ago, commandarray as send 3 time ago too (if i check devicechanged)...

I want to send a commandarray just on the first 'on'...

Re: How can i get last state of device ?

Posted: Tuesday 12 September 2017 15:40
by jannl
I think you could use a dummy switch which you set to on the first time only

Re: How can i get last state of device ?

Posted: Tuesday 12 September 2017 16:46
by Egregius
In pass2php I store all states in php caches. That way I can compare the new state with the previous state.

Re: How can i get last state of device ?

Posted: Saturday 16 September 2017 11:28
by landaisbenj
Thank you. i look at this

Re: How can i get last state of device ?

Posted: Tuesday 19 September 2017 12:28
by lonebaggie
I have written a universal LUA script to link switches together

viewtopic.php?f=38&t=19217

One of the options is to update a User variable ( it can trigger it as well ) with pre-set info

45||19|USwith %n% triggered at %t%

will set User Variable with Idx 19 with "Switch Hall Lights triggered at 12:45:10" when switch 45 triggered. This will also trigger any User variable scripts

Does this help ?