How can i get last state of device ?

Moderator: leecollings

Post Reply
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

How can i get last state of device ?

Post 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.
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
zicht
Posts: 251
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: How can i get last state of device ?

Post 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)
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

Re: How can i get last state of device ?

Post 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'...
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
jannl
Posts: 625
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: How can i get last state of device ?

Post by jannl »

I think you could use a dummy switch which you set to on the first time only
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: How can i get last state of device ?

Post by Egregius »

In pass2php I store all states in php caches. That way I can compare the new state with the previous state.
landaisbenj
Posts: 147
Joined: Wednesday 02 August 2017 18:12
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Location: France
Contact:

Re: How can i get last state of device ?

Post by landaisbenj »

Thank you. i look at this
Platforme: Rpbi3b
Domoticz: Last stable
Bridge: RFLINK last stable
User avatar
lonebaggie
Posts: 86
Joined: Tuesday 31 January 2017 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: England
Contact:

Re: How can i get last state of device ?

Post 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 ?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest