Page 2 of 3
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 13:44
by Milifax
dannybloe wrote:
And, the question is: should events be triggered when you switch Master and Slave(s) are synced? I'd say yes. When a device changes, ALWAYS trigger scripts.
So, what you're bascily saying is that scripts are not triggered when this syncing is activated? And thus the state is not update?
On top of that, the nValue isn't something you should be using in dzVents I guess as I hope all devices have more sane/readable attributes.
Ok, noted. But, out of curiosity, why is there a nValue available in Dzvents as mentioned on the wiki and why isn't it displaying the correct information, or equal information as in the db?
Wiki --> nValue: Number. Numerical representation of the state.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 13:47
by Milifax
jvandenbroek wrote:Yes, danny described it thorough. Conclusion for now: Only switch master through slaves only, not directly or via scripting. The trick in this case would probably just adding a second slave and use that for the timer.
Could you explain that a bit more?
Bot, master and slave, are devices which are triggered from a message to RFLink. How can I add an extra slave. If I want to do that Domoticz says it is already in use.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 13:48
by dannybloe
Milifax wrote:
Ok, noted. But, out of curiosity, why is there a nValue available in Dzvents as mentioned on the wiki and why isn't it displaying the correct information, or equal information as in the db?
Wiki --> nValue: Number. Numerical representation of the state.
Goog question. Guess it is a left-over from earlier dzVents versions. This nValue is just handed to dzVents from Domoticz. To be honest I have no idea how exactly it is constructed.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 13:55
by jvandenbroek
Milifax wrote:jvandenbroek wrote:Yes, danny described it thorough. Conclusion for now: Only switch master through slaves only, not directly or via scripting. The trick in this case would probably just adding a second slave and use that for the timer.
Could you explain that a bit more?
Bot, master and slave, are devices which are triggered from a message to RFLink. How can I add an extra slave. If I want to do that Domoticz says it is already in use.
Isn't it possible to add a dummy slave next to the rflink slaves and use this one to switch on/off through scripting (dzVents)? Not tested, just an idea..
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 13:57
by Milifax
jvandenbroek wrote:Milifax wrote:jvandenbroek wrote:Yes, danny described it thorough. Conclusion for now: Only switch master through slaves only, not directly or via scripting. The trick in this case would probably just adding a second slave and use that for the timer.
Could you explain that a bit more?
Bot, master and slave, are devices which are triggered from a message to RFLink. How can I add an extra slave. If I want to do that Domoticz says it is already in use.
Isn't it possible to add a dummy slave next to the rflink slaves and use this one to switch on/off through scripting (dzVents)? Not tested, just an idea..
What should I use to switch on then? As scripts are not triggered, only when the door opens. And not when it closes.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 14:05
by jvandenbroek
Ah I understand what you mean. You should create a dummy device as master and add both RFLink devices as slaves to it. Now you should get the correct status on the dummy device..
Edit: Well I think I understand it, is it correct that you have 2 RFLink devices, one only triggers when door is open and the other when door is closed? And do they sent the correct On and Off status, or both the same (always On or Off)? If the latter is the case, you should use a script and not master/slave devices.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 14:13
by Milifax
jvandenbroek wrote:Ah I understand what you mean. You should create a dummy device as master and add both RFLink devices as slaves to it. Now you should get the correct status on the dummy device..
Edit: Well I think I understand it, is it correct that you have 2 RFLink devices, one only triggers when door is open and the other when door is closed? And do they sent the correct On and Off status, or both the same (always On or Off)? If the latter is the case, you should use a script and not master/slave devices.
Nope no luck unfortunately,
the master swithes on once and stays on.
The dummy devices are always open if I log the states.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 14:20
by Milifax
Maybe not the cleanest solution, but the nvalue is the one probably I can use now as it switches on the door.
Is there a way, through python or such, to read the value of nvalue out of the db directly?
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 14:50
by jvandenbroek
Milifax wrote:jvandenbroek wrote:Ah I understand what you mean. You should create a dummy device as master and add both RFLink devices as slaves to it. Now you should get the correct status on the dummy device..
Edit: Well I think I understand it, is it correct that you have 2 RFLink devices, one only triggers when door is open and the other when door is closed? And do they sent the correct On and Off status, or both the same (always On or Off)? If the latter is the case, you should use a script and not master/slave devices.
Nope no luck unfortunately,
the master swithes on once and stays on.
The dummy devices are always open if I log the states.
I guess your hardware send On or Off for both states, but as different devices.. Then you could do something like this:
Create 1 dummy device named 'Achterdeur'
Name your RFLink device as 'Achterdeur_Open' and 'Achterdeur_Dicht'
Code: Select all
return {
active = true,
on = {
devices = {
'Achterdeur_Open',
'Achterdeur_Dicht'
}
},
execute = function(domoticz, device)
if (device.name == 'Achterdeur_Open') then
domoticz.devices('Achterdeur').switchOn()
else
domoticz.devices('Achterdeur').switchOff()
end
end
}
Now you could use your scripting on dummy 'Achterdeur' for the correct status...?
And don't make any devices slaves, just keep them as stand-alone.
Don't depend on the nvalue, this is somewhat an 'illegal' way of obtaining the correct status.. Sure it may work for now, but might not in the future.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:01
by Milifax
jvandenbroek wrote:
I guess your hardware send On or Off for both states, but as different devices.
No, it only sends On apparently for an Open and an On for Close, two different devices.
Then you could do something like this:.....
Nope, doesn't work as the script doesn't get triggered.
Don't depend on the nvalue, this is somewhat an 'illegal' way of obtaining the correct status.. Sure it may work for now, but might not in the future.
But I see it as the only solution. I can't get my head around the fact the GUI states the correct state and everything else doesn't.
Maybe the question should be, where does the GUI gets it state from?
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:05
by jvandenbroek
Yes the GUI gets it's info from DB directly, so no strange behaviour here and all as expected

Well then I'm out of options then, because the script above should definitely work if you've got 2 separate RFlink devices sending the On status (or Off, doesn't matter). But to be clear: We're not talking about one RFLink device sending always On, but 2 separate ones? Otherwise it would be much simpler, you could just toggle the state...
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:13
by dannybloe
Just spoke to gizmocus and the master/slave thing is intended for Kaku (like) devices in combination with linked/paired remote controls where the light isn't able to tell Domoticz that it is switched on.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:17
by Milifax
jvandenbroek wrote:Yes the GUI gets it's info from DB directly, so no strange behaviour here and all as expected

-
So why not get the right data that way? If only I knew how
Well then I'm out of options then, because the script above should definitely work if you've got 2 separate RFlink devices sending the On status (or Off, doesn't matter). But to be clear: We're not talking about one RFLink device sending always On, but 2 separate ones? Otherwise it would be much simpler, you could just toggle the state...
I'm out of options as well, hench my question to do it on a dirty way and get the nValue out of the db.
The script above definitely doesn't work

I tested it right here, just now and multiple times before

, and no luck.
The device is 1 device. But it sends as two devices, how can I explain. The device sends an On state for opening and an On state for closing:
2017-08-04 15:14:08.399 RFLink: 20;DD;EV1527;ID=03b2c0;SWITCH=0e;CMD=ON;
2017-08-04 15:14:08.401 (RFLink) Light/Switch (Achterdeur_Dicht)
2017-08-04 15:14:10.658 RFLink: 20;DE;EV1527;ID=03b2c0;SWITCH=0a;CMD=ON;
2017-08-04 15:14:10.659 (RFLink) Light/Switch (Achterdeur_Open)
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:21
by Milifax
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.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:31
by dannybloe
But the script is executed right? When the door opens or closes? Do you get dzVents logging in the logs?
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:35
by jvandenbroek
Milifax wrote:jvandenbroek wrote:Yes the GUI gets it's info from DB directly, so no strange behaviour here and all as expected

-
So why not get the right data that way? If only I knew how
Because it now accidentally works for you and gives the correct value, but it's not intended to use the way you do, resulting in unexpected behaviour. Switching master will
always put the slave device to Off, despite being set to On or Off... And the script should just work, period

Just make sure you've got 3 devices (1 dummy, 2 RFLink) and maybe to be sure, first add the 'Achterdeur' as On/Off switch, not a Door type. Also check for On and Off status instead of Open / Close while testing this...
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:40
by Milifax
jvandenbroek wrote:
And the script should just work, period

Just make sure you've got 3 devices (1 dummy, 2 RFLink) and maybe to be sure, first add the 'Achterdeur' as On/Off switch, not a Door type. Also check for On and Off status instead of Open / Close while testing this...
Believe me, tried it, tried it, tried it....
The script doesn't work, period

and I think the reason is because the device only sends an On. Never an Off.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:44
by jvandenbroek
Milifax wrote:jvandenbroek wrote:
And the script should just work, period

Just make sure you've got 3 devices (1 dummy, 2 RFLink) and maybe to be sure, first add the 'Achterdeur' as On/Off switch, not a Door type. Also check for On and Off status instead of Open / Close while testing this...
Believe me, tried it, tried it, tried it....
The script doesn't work, period

and I think the reason is because the device only sends an On. Never an Off.
Doesn't matter, it just checks for a device change, not whether it's On or Off... Well then it could potentially be a bug in dzvents...

And this in Lua?:
Code: Select all
commandArray = {}
if (devicechanged['Achterdeur_Open']) then
commandArray['Achterdeur'] = 'On'
elseif (devicechanged['Achterdeur_Dicht']) then
commandArray['Achterdeur'] = 'Off'
end
return commandArray
Edit: oops, don't forget the return commandArray!
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:50
by Milifax
jvandenbroek wrote:
Doesn't matter, it just checks for a device change, not whether it's On or Off... Well then it could potentially be a bug in dzvents...

And this in Lua?:
Tried it, tried it just now again, no luck.
If I detach the slave/master, nothing switches. Both are On, as the device sends only On.
Re: DzVents door.state is always open?
Posted: Friday 04 August 2017 15:53
by jvandenbroek
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!