Page 3 of 3
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:59
by Milifax
jvandenbroek wrote:But you see the logic in the script? When 'something' from Achterdeur_Open arrives (could just be On every time), it will set Achterdeur to On. If 'something' from Achterdeur_Dicht arrives (could also just be On every time), it will set it to Off. Achterdeur must change it's status, really weird if it doesn't. Are you using the latest beta btw? Because a few days ago there was a little issue, should be fine on latest version.
Also name the lua script something like script_device_justsomethingtotallyrandom.lua and not with the device name in the file name!
You see why I'm lost
Totally agree with you, but it just doesn't work.
I am now on version 3.8203
Filename is totally different.
Edit, And it even puzzles me more, and I quote:
My main question still remains:
Why is the state in the GUI different from the state which I call in the scripts.
I cannot get my head around that one.
The GUI is right in my opnion when I look at my door and at the state
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 16:16
by jvandenbroek
Milifax wrote:
My main question still remains:
Why is the state in the GUI different from the state which I call in the scripts.
I cannot get my head around that one.
The GUI is right in my opnion when I look at my door and at the state
Because there is no event generated for the slave device when being switched by the master (as I explained above, shouldn't be done, it's not where this function was created for). Yes, it does update the DB value and yes, we could change this in code to also trigger an event, but then we're solving an issue for a use case it isn't intended for. Besides, the alternatives are a more robust / correct way to handle it, if it only could just work for you.. Which it should, so we'd better focus on that. I even starting to think something is wrong with RFLink devices. Does the following print something?
Code: Select all
if (devicechanged['Achterdeur_Open'] == 'On') then
print ('Door is now open!')
elseif (devicechanged['Achterdeur_Dicht'] == 'On') then
print ('Door is now closed!')
end
commandArray = {}
return commandArray
And maybe even delete the devices completely and re-add them?
Edit: Also make them regular contacts or just switches, not doors. Just thinking there may be a bug in that part of the code...
Looking at your working example from page 1, you might want to use if (devicechanged['Achterdeur_Dicht'] == 'Open') then instead of 'On' (for both _Dicht and _Open)
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 16:27
by Milifax
jvandenbroek wrote:
Because there is no event generated for the slave device when being switched by the master (as I explained above, shouldn't be done, it's not where this function was created for). Yes, it does update the DB value and yes, we could change this in code to also trigger an event, but then we're solving an issue for a use case it isn't intended for. Besides, the alternatives are a more robust / correct way to handle it, if it only could just work for you..
Don't get me wrong, I'm not looking for a change in source code or functionality or any other change, beside a bugfix if so. Just looking for a solution and trying to understand why it doesn't work as I expect.
Will deleted everything tonight and start with a clean slate.
Will get it to work someday, sometime.....
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 23:51
by Milifax
Flabbergasted is the word I would like to use at this moment
It works
I removed all devices used before considering the doorsensors.
Created new ones, as switches.
Didn't use the master/slave settings.
And tried catching them with the mentioned Lua-script.
And it just works.
Also in DzVents the triggers are now right. The script I now use is:
Code: Select all
return {
active = true,
on = {
devices = {
'Achterdeur_Open',
'Achterdeur_Dicht',
'Voordeur_Open',
'Voordeur_Dicht'
}
},
execute = function(domoticz, device)
domoticz.log('Script active')
if (device.name == 'Achterdeur_Open') then
domoticz.devices('Achterdeur').switchOn()
domoticz.log('Door is open')
elseif (device.name == 'Achterdeur_Dicht') then
domoticz.devices('Achterdeur').switchOff()
domoticz.log('Door is closed')
end
if (device.name == 'Voordeur_Open') then
domoticz.devices('Voordeur').switchOn()
domoticz.log('Door is open')
elseif (device.name == 'Voordeur_Dicht') then
domoticz.devices('Voordeur').switchOff()
domoticz.log('Door is closed')
end
end
}
Absolutly no idea why it didn't work before. In my memory I tried to get the switched states without the slave/master as well.
@Dannybloe and @jvandenbroek, thanks a million for your help and patience. The working doorsensors make my day!
Re: [SOLVED] DzVents door.state is always open?
Posted: Sunday 19 November 2017 17:57
by Strummer
I had the same issue when trying to set up Friedland DC55 door contacts. I got 6 of them quite cheaply. i had set them as master / slave and had inconsistent results. So I was very pleased
to see this forum entry and the dzvents script. Set up the script and they still did not work. Deleted all the switches including the auto-generated RFlink / idx switches and re-recreated all the local dummy switches for use by the script to hold the change of state. Then opened and closed each door to allow Domoticz to find each switch again - The Friedland contacts send a short 'on' signal for 'open', [logged with RFLink] as unit 33 against the device ID. and another short 'on' signal logged as unit 1 when they close.
initially I set up each pair (one for open, one for close) of these as 'contact' switch-type - but that did not work, so now they are 'Push-on' buttons, and guess what, they and the script all work fine. Push-on makes sense when you look at what the contacts are sending. They also send a 'tamper' with unit 129 for some and 9 or 65 for others - since I am not using that function I have not spent too much time figuring why they are different. Thankfully the open and close are always 33 and 1 respectively.
Thanks to all for sharing the learning on this !