Dead zwave devices

Moderator: leecollings

Post Reply
Docc
Posts: 22
Joined: Saturday 02 May 2015 8:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Sweden
Contact:

Dead zwave devices

Post by Docc »

Is there a way to find if a device is dead or alive in a LUA device script and will a device script be triggered if a device goes dead or alive?
So can I do something like this in a device script for 'MyDeviceName':

if (devicechanged['MyDeviceName'] == 'Dead' ) then
...
or
if (devicechanged['MyDeviceName'] == 'Alive' ) then
...
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Dead zwave devices

Post by emme »

I think it could be done by evaluating the time difference between the actua time and the last update value
...the script could be a Time script instead of a Device script and you could use a user variable with the value (in minutes or hours or days or whatever) to trigger the events

ciao
M
The most dangerous phrase in any language is:
"We always done this way"
Docc
Posts: 22
Joined: Saturday 02 May 2015 8:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Sweden
Contact:

Re: Dead zwave devices

Post by Docc »

Yes, I suppose, but I would like it to be more instant or at least within a few seconds of the device change.
User avatar
Egregius
Posts: 2589
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Dead zwave devices

Post by Egregius »

Query your devices using the JSON API.
It's in the reply if a device is marked as 'HasTimeout'.
And how are you expecting a dead device to update it's status? Normally they don't, otherwise they aren't dead right?
Docc
Posts: 22
Joined: Saturday 02 May 2015 8:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Sweden
Contact:

Re: Dead zwave devices

Post by Docc »

I followed emme's suggestion and wrote the script below.
This is to let Domoticz know when my Verisure alarm is activated.
I use a variable in the script but might change that to a dummy switch since variable events doesn't seem to work properly.

This script sets a variable to indicate the state of my Verisure alarm and sets a scene to off
For this to work you need a Verisure mains plug set to activate when the alarm is armed and a zwave plug in series.
The zwave plug will go dead when the alarm is disarmed and the script checks for that timeout.
It also makes sure that the zwave plug is On when the alarm is armed, to light up a night lamp to show that the alarm is armed.

Code: Select all

function timedifference(s)
   year = string.sub(s, 1, 4)
   month = string.sub(s, 6, 7)
   day = string.sub(s, 9, 10)
   hour = string.sub(s, 12, 13)
   minutes = string.sub(s, 15, 16)
   seconds = string.sub(s, 18, 19)
   t1 = os.time()
   t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
   difference = os.difftime (t1, t2)
   return difference
end

commandArray = {}



		difference = timedifference(otherdevices_lastupdate['Verisure-Status-Voltage'])
		print('difference = ' .. difference)
		
        if difference > 30 then
			
			commandArray['Variable:securityState'] = 'Disarmed'
			print('#Security = Disarmed')
		else
			
			if uservariables['securityState'] == 'Disarmed'	then
				commandArray['Scene:NightMode']='Off'	
				print('Setting Night mode')
			end
			
			commandArray['Variable:securityState'] = 'Armed Home'
			
			print('#Security = Armed Home')
		end

		if (otherdevices['Verisure-Status'] == 'Off') then
			commandArray['Verisure-Status'] = 'On'	
		end
	print('Verisure-Status = ' .. otherdevices['Verisure-Status'])
	print('Variable:securityState = ' .. uservariables['securityState'])	

return commandArray
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Dead zwave devices

Post by emme »

mmmmh... just a question as I'm not so skilled in LUA....
doees the time difference function works?
I mean... it would return an array with s.year, s.month etc etc....
is it correct to check it simply as s > 30 ?!
it's just a newbe question... I'll give it a try as soon as I can :P
The most dangerous phrase in any language is:
"We always done this way"
Docc
Posts: 22
Joined: Saturday 02 May 2015 8:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Sweden
Contact:

Re: Dead zwave devices

Post by Docc »

Yes it works, I've copied that function from the wiki :-)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Dead zwave devices

Post by emme »

thanks
The most dangerous phrase in any language is:
"We always done this way"
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest