Page 1 of 1
dummy switch not switched
Posted: Thursday 11 June 2020 17:55
by AllesVanZelf
I have a dummy switch for motion on the ground floor (1st floor for us readers

).
But although I do see that the time changes on the button as 'last seen' I do not see this in the log of the dummy device. I do not understand why this is happening. The switch never goes to On state as it should.
This is the script I use:
Code: Select all
return
{
on =
{
devices =
{
'MS Keuken Beweging',
'MS Hal Beweging',
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionachterhuis = dz.devices('MS Achterhuis Beweging').state
local motionvoorhuis = dz.devices('MS Voorhuis Beweging').state
local motionbg = dz.devices('Beweging begane grond')
dz.log('State of MS Beweging Keuken ' .. tostring(motionkeuken), dz.LOG_DEBUG)
dz.log('State of MS Beweging Hal ' .. tostring(motionhal), dz.LOG_DEBUG)
dz.log('State of MS Beweging Achterhuis ' .. tostring(motionachterhuis), dz.LOG_DEBUG)
dz.log('State of MS Beweging Voorhuis ' .. tostring(motionvoorhuis), dz.LOG_DEBUG)
dz.log('State of Bewegingsdetectie begane grond ' .. tostring(motionbg), dz.LOG_DEBUG)
if motionkeuken == 'On' or motionhal == 'On' or motionachterhuis == 'On' or motionvoorhuis == 'On' then
motionbg.switchOn().forMin(1)
elseif motionkeuken == 'Off' and motionhal == 'Off' and motionachterhuis == 'Off' and motionvoorhuis == 'Off' then
motionbg.switchOff() --.afterMin(1)
end
end
}
Did I make a mistake in this script? I only see warning about switching off:
Code: Select all
2020-06-11 17:47:18.786 Status: dzVents: Info: Handling events for: "MS Achterhuis Beweging", value: "Off"
2020-06-11 17:47:18.786 Status: dzVents: Info: ------ Start internal script: Bewegingsdetectie Begane Grond DzVents: Device: "MS Achterhuis Beweging (OpenZwave)", Index: 219
2020-06-11 17:47:18.788 Status: dzVents: Debug: Processing device-adapter for MS Keuken Beweging: Switch device adapter
2020-06-11 17:47:18.791 Status: dzVents: Debug: Processing device-adapter for MS Hal Beweging: Switch device adapter
2020-06-11 17:47:18.794 Status: dzVents: Debug: Processing device-adapter for MS Voorhuis Beweging: Switch device adapter
2020-06-11 17:47:18.797 Status: dzVents: Debug: Processing device-adapter for Beweging begane grond: Switch device adapter
2020-06-11 17:47:18.797 Status: dzVents: Debug: State of MS Beweging Keuken Off
2020-06-11 17:47:18.797 Status: dzVents: Debug: State of MS Beweging Hal Off
2020-06-11 17:47:18.798 Status: dzVents: Debug: State of MS Beweging Achterhuis Off
2020-06-11 17:47:18.798 Status: dzVents: Debug: State of MS Beweging Voorhuis Off
2020-06-11 17:47:18.798 Status: dzVents: Debug: State of Bewegingsdetectie begane grond table: 0x6eee7018
2020-06-11 17:47:18.798 Status: dzVents: Debug: Constructed timed-command: Off
2020-06-11 17:47:18.798 Status: dzVents: Info: ------ Finished Bewegingsdetectie Begane Grond DzVents
2020-06-11 17:47:18.801 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
Re: dummy switch not switched
Posted: Thursday 11 June 2020 18:29
by waaren
AllesVanZelf wrote: Thursday 11 June 2020 17:55
I have a dummy switch for motion on the ground floor (1st floor for us readers

).
But although I do see that the time changes on the button as 'last seen' I do not see this in the log of the dummy device. I do not understand why this is happening. The switch never goes to On state as it should.
You mix a device with its state that's why you see a log-line referring to a table
Can you try this ?
Code: Select all
return
{
on =
{
devices =
{
'MS Keuken Beweging',
'MS Hal Beweging',
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionachterhuis = dz.devices('MS Achterhuis Beweging').state
local motionvoorhuis = dz.devices('MS Voorhuis Beweging').state
local motionbg = dz.devices('Beweging begane grond')
dz.log('State of MS Beweging Keuken ' .. motionkeuken, dz.LOG_DEBUG)
dz.log('State of MS Beweging Hal ' .. motionhal, dz.LOG_DEBUG)
dz.log('State of MS Beweging Achterhuis ' .. motionachterhuis, dz.LOG_DEBUG)
dz.log('State of MS Beweging Voorhuis ' .. motionvoorhuis, dz.LOG_DEBUG)
dz.log('State of virtual switch Bewegingsdetectie begane grond ' .. motionbg.state, dz.LOG_DEBUG)
if motionkeuken == 'On' or motionhal == 'On' or motionachterhuis == 'On' or motionvoorhuis == 'On' then
dz.log('Switching motionbg on for 1 minute', dz.LOG_DEBUG)
motionbg.cancelQueuedCommands()
motionbg.switchOn()
motionbg.switchOff().afterSec(60)
elseif motionkeuken == 'Off' and motionhal == 'Off' and motionachterhuis == 'Off' and motionvoorhuis == 'Off' then
dz.log('Switching motionbg off', dz.LOG_DEBUG)
motionbg.switchOff().afterMin(1)
end
end
}
Re: dummy switch not switched
Posted: Friday 12 June 2020 10:01
by AllesVanZelf
The script for upstairs does work well:
Code: Select all
return
{
on =
{
devices =
{
'MS Overloop Beweging',
'MS Zolder Overloop Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local motion1e = dz.devices('MS Overloop Beweging').state
local motion2e = dz.devices('MS Zolder Overloop Beweging').state
local motionboven = dz.devices('Bewegingsdetectie Boven')
dz.log('State of MS Beweging overloop ' .. tostring(motion1e), dz.LOG_DEBUG)
dz.log('State of MS Beweging Zolder Overloop ' .. tostring(motion2e), dz.LOG_DEBUG)
dz.log('State of Bewegingsdetectie Boven ' .. tostring(motionboven), dz.LOG_DEBUG)
if motion1e == 'On' or motion2e == 'On' then
motionboven.switchOn().forMin(2)
elseif motion1e == 'Off' and motion2e == 'Off' then
motionboven.switchOff().afterMin(2)
end
end
}
But downstairs is not:
Code: Select all
return
{
on =
{
devices =
{
'MS Keuken Beweging',
'MS Hal Beweging',
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionachterhuis = dz.devices('MS Achterhuis Beweging').state
local motionvoorhuis = dz.devices('MS Voorhuis Beweging').state
local motionbg = dz.devices('Beweging begane grond')
dz.log('State of MS Beweging Keuken ' .. tostring(motionkeuken), dz.LOG_DEBUG)
dz.log('State of MS Beweging Hal ' .. tostring(motionhal), dz.LOG_DEBUG)
dz.log('State of MS Beweging Achterhuis ' .. tostring(motionachterhuis), dz.LOG_DEBUG)
dz.log('State of MS Beweging Voorhuis ' .. tostring(motionvoorhuis), dz.LOG_DEBUG)
dz.log('State of Beweging begane grond ' .. tostring(motionbg), dz.LOG_DEBUG)
if motionkeuken == 'On' or motionhal == 'On' or motionachterhuis == 'On' or motionvoorhuis == 'On' then
motionbg.switchOn().forMin(2)
elseif motionkeuken == 'Off' and motionhal == 'Off' and motionachterhuis == 'Off' and motionvoorhuis == 'Off' then
motionbg.switchOff().afterMin(2)
end
end
}
These are the switches on the frontend. The left one does not update the icon to On and in text most of the time no update as: last seen ....

Maybe this is not DzVents related?
Re: dummy switch not switched
Posted: Friday 12 June 2020 13:01
by waaren
AllesVanZelf wrote: Friday 12 June 2020 10:01
The script for upstairs does work well:
But downstairs is not:
What do you see in the log when you try the modified script I posted ?
Re: dummy switch not switched
Posted: Friday 12 June 2020 14:11
by AllesVanZelf
If I disable the script, copy paste your version in a new one, then:
Code: Select all
2020-06-12 14:07:47.558 Status: dzVents: Info: Handling events for: "MS Keuken Beweging", value: "Off"
2020-06-12 14:07:47.558 Status: dzVents: Info: ------ Start internal script: test DzVents: Device: "MS Keuken Beweging (OpenZwave)", Index: 229
2020-06-12 14:07:47.560 Status: dzVents: Debug: Processing device-adapter for MS Hal Beweging: Switch device adapter
2020-06-12 14:07:47.562 Status: dzVents: Debug: Processing device-adapter for MS Achterhuis Beweging: Switch device adapter
2020-06-12 14:07:47.563 Status: dzVents: Debug: Processing device-adapter for MS Voorhuis Beweging: Switch device adapter
2020-06-12 14:07:47.565 Status: dzVents: Debug: Processing device-adapter for Beweging begane grond: Switch device adapter
2020-06-12 14:07:47.565 Status: dzVents: Debug: State of MS Beweging Keuken Off
2020-06-12 14:07:47.565 Status: dzVents: Debug: State of MS Beweging Hal Off
2020-06-12 14:07:47.566 Status: dzVents: Debug: State of MS Beweging Achterhuis Off
2020-06-12 14:07:47.566 Status: dzVents: Debug: State of MS Beweging Voorhuis Off
2020-06-12 14:07:47.566 Status: dzVents: Debug: State of virtual switch Bewegingsdetectie begane grond Off
2020-06-12 14:07:47.566 Status: dzVents: Debug: Switching motionbg off
2020-06-12 14:07:47.566 Status: dzVents: Debug: Constructed timed-command: Off
2020-06-12 14:07:47.566 Status: dzVents: Debug: Constructed timed-command: Off AFTER 60 SECONDS
2020-06-12 14:07:47.566 Status: dzVents: Info: ------ Finished test DzVents
2020-06-12 14:07:47.568 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
And then I do not see any device log, nor device change on the switch, or Icon.
Re: dummy switch not switched
Posted: Friday 12 June 2020 14:49
by waaren
AllesVanZelf wrote: Friday 12 June 2020 14:11
If I disable the script, copy paste your version in a new one, then:
Code: Select all
2020-06-12 14:07:47.566 Status: dzVents: Debug: Constructed timed-command: Off
2020-06-12 14:07:47.566 Status: dzVents: Debug: Constructed timed-command: Off AFTER 60 SECONDS
And then I do not see any device log, nor device change on the switch, or Icon.
Seems to work as expected to me. All motion detector states are 'Off' so virtual switch is switched 'Off' after 1 minute.
Because it was already 'Off' you will not see this as an extra line in the device log but any dependent event scripts will be triggered.
Re: dummy switch not switched
Posted: Friday 12 June 2020 14:55
by AllesVanZelf
Thanks Waaren for helping me out here.
Although the motion sensors are triggered, like achterhuis or keuken, still the virtual sensor is not triggered/set to On. It keeps Off.
I do not understand. I tried recreating a new virtual switch, but that did not help.
Re: dummy switch not switched
Posted: Friday 12 June 2020 16:37
by waaren
AllesVanZelf wrote: Friday 12 June 2020 14:55
Thanks Waaren for helping me out here.
Although the motion sensors are triggered, like achterhuis or keuken, still the virtual sensor is not triggered/set to On. It keeps Off.
I do not understand. I tried recreating a new virtual switch, but that did not help.
If the motion sensors are triggered, what state do they report in the log? if it's not 'On' you might want to change the script to
Code: Select all
return
{
on =
{
devices =
{
'MS Keuken Beweging',
'MS Hal Beweging',
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionachterhuis = dz.devices('MS Achterhuis Beweging').state
local motionvoorhuis = dz.devices('MS Voorhuis Beweging').state
local motionbg = dz.devices('Beweging begane grond')
dz.log('State of MS Beweging Keuken ' .. motionkeuken, dz.LOG_DEBUG)
dz.log('State of MS Beweging Hal ' .. motionhal, dz.LOG_DEBUG)
dz.log('State of MS Beweging Achterhuis ' .. motionachterhuis, dz.LOG_DEBUG)
dz.log('State of MS Beweging Voorhuis ' .. motionvoorhuis, dz.LOG_DEBUG)
dz.log('State of virtual switch Bewegingsdetectie begane grond ' .. motionbg.state, dz.LOG_DEBUG)
if motionkeuken ~= 'Off' or motionhal ~= 'Off'' or motionachterhuis ~= 'Off' or motionvoorhuis ~= 'Off' then
dz.log('Switching motionbg on for 1 minute', dz.LOG_DEBUG)
motionbg.cancelQueuedCommands()
motionbg.switchOn()
motionbg.switchOff().afterSec(60)
elseif motionkeuken == 'Off' and motionhal == 'Off' and motionachterhuis == 'Off' and motionvoorhuis == 'Off' then
dz.log('Switching motionbg off', dz.LOG_DEBUG)
motionbg.switchOff().afterMin(1)
end
end
}
Re: dummy switch not switched
Posted: Friday 12 June 2020 17:25
by AllesVanZelf
I use upstairs the same motion sensors from fibaro. So that is not the problem.
I just tried the same thing in Blockly. I had this working before. But now I see that this is not working anymore.

Re: dummy switch not switched
Posted: Friday 12 June 2020 17:31
by waaren
AllesVanZelf wrote: Friday 12 June 2020 17:25
I use upstairs the same motion sensors from fibaro. So that is not my problem.
Might be but I have not seen a state 'On' yet in the logs you showed here.
Re: dummy switch not switched
Posted: Friday 12 June 2020 22:58
by AllesVanZelf
According to the log, this switch is never On. Even when I uncomment the Off part.
Code: Select all
2020-06-12 22:53:25.619 Status: OpenZWave: Alarm received (Home Security: Motion Detected at Unknown Location), NodeID: 49 (0x31)
2020-06-12 22:53:25.799 Status: dzVents: Info: Handling events for: "MS Achterhuis Beweging", value: "Off"
2020-06-12 22:53:25.800 Status: dzVents: Info: ------ Start internal script: Bewegingsdetectie Begane Grond DzVents: Device: "MS Achterhuis Beweging (OpenZwave)", Index: 219
2020-06-12 22:53:25.801 Status: dzVents: Debug: Processing device-adapter for MS Keuken Beweging: Switch device adapter
2020-06-12 22:53:25.802 Status: dzVents: Debug: Processing device-adapter for MS Hal Beweging: Switch device adapter
2020-06-12 22:53:25.803 Status: dzVents: Debug: Processing device-adapter for MS Voorhuis Beweging: Switch device adapter
2020-06-12 22:53:25.804 Status: dzVents: Debug: Processing device-adapter for Bewegingsdetectie Beneden: Switch device adapter
2020-06-12 22:53:25.804 Status: dzVents: Debug: State of MS Beweging Keuken Off
2020-06-12 22:53:25.804 Status: dzVents: Debug: State of MS Beweging Hal Off
2020-06-12 22:53:25.804 Status: dzVents: Debug: State of MS Beweging Achterhuis Off
2020-06-12 22:53:25.804 Status: dzVents: Debug: State of MS Beweging Voorhuis Off
2020-06-12 22:53:25.804 Status: dzVents: Debug: State of Bewegingsdetectie Beneden Off
2020-06-12 22:53:25.805 Status: dzVents: Info: ------ Finished Bewegingsdetectie Begane Grond DzVents
The script is like:
Code: Select all
return
{
on =
{
devices =
{
'MS Keuken Beweging',
'MS Hal Beweging',
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz)
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionachterhuis = dz.devices('MS Achterhuis Beweging').state
local motionvoorhuis = dz.devices('MS Voorhuis Beweging').state
local motionbg = dz.devices('Bewegingsdetectie Beneden')
dz.log('State of MS Beweging Keuken ' .. motionkeuken, dz.LOG_DEBUG)
dz.log('State of MS Beweging Hal ' .. motionhal, dz.LOG_DEBUG)
dz.log('State of MS Beweging Achterhuis ' .. motionachterhuis, dz.LOG_DEBUG)
dz.log('State of MS Beweging Voorhuis ' .. motionvoorhuis, dz.LOG_DEBUG)
dz.log('State of Bewegingsdetectie Beneden ' .. motionbg.state, dz.LOG_DEBUG)
if motionkeuken ~= 'Off' or motionhal ~= 'Off' or motionachterhuis ~= 'Off' or motionvoorhuis ~= 'Off' then
motionbg.cancelQueuedCommands()
motionbg.switchOn().forMin(4)
dz.log('Switching motionbg on', dz.LOG_DEBUG)
--elseif motionkeuken == 'Off' and motionhal == 'Off' and motionachterhuis == 'Off' and motionvoorhuis == 'Off' then
-- dz.log('Switching motionbg off', dz.LOG_DEBUG)
-- motionbg.switchOff().afterMin(1)
end
end
}
I'm confused.
Re: dummy switch not switched
Posted: Saturday 13 June 2020 0:06
by waaren
Maybe this wil show some additional / useful information
Code: Select all
return
{
on =
{
devices =
{
'MS Keuken Beweging',
'MS Hal Beweging',
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
execute = function(dz, item)
dz.log('Script is started by ' .. item.name , dz.LOG_DEBUG)
dz.log('nValue: ' .. item.nValue , dz.LOG_DEBUG )
dz.log('sValue: ' .. item.sValue , dz.LOG_DEBUG )
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionachterhuis = dz.devices('MS Achterhuis Beweging').state
local motionvoorhuis = dz.devices('MS Voorhuis Beweging').state
local motionbg = dz.devices('Bewegingsdetectie Beneden')
dz.log('State of MS Beweging Keuken ' .. motionkeuken, dz.LOG_DEBUG)
dz.log('State of MS Beweging Hal ' .. motionhal, dz.LOG_DEBUG)
dz.log('State of MS Beweging Achterhuis ' .. motionachterhuis, dz.LOG_DEBUG)
dz.log('State of MS Beweging Voorhuis ' .. motionvoorhuis, dz.LOG_DEBUG)
dz.log('State of Bewegingsdetectie Beneden ' .. motionbg.state, dz.LOG_DEBUG)
if motionkeuken ~= 'Off' or motionhal ~= 'Off' or motionachterhuis ~= 'Off' or motionvoorhuis ~= 'Off' then
motionbg.cancelQueuedCommands()
motionbg.switchOn().forMin(4)
dz.log('Switching motionbg on', dz.LOG_DEBUG)
--elseif motionkeuken == 'Off' and motionhal == 'Off' and motionachterhuis == 'Off' and motionvoorhuis == 'Off' then
-- dz.log('Switching motionbg off', dz.LOG_DEBUG)
-- motionbg.switchOff().afterMin(1)
end
end
}
Re: dummy switch not switched [Solved]
Posted: Tuesday 07 July 2020 16:40
by AllesVanZelf
I'm so sorry Waaren!!
I made a mistake in choosing the right device from the list!!! So this motion sensors never went On.
This dummy switch is working now. Next step is setting up my alarm system.
to finish this thread:
Code: Select all
return
{
on =
{
devices =
{
'MS Achterhuis Beweging',
'MS Voorhuis Beweging',
'MS Keuken Beweging',
'MS Hal Beweging',
},
},
logging =
{
level = domoticz.LOG_ERROR,
},
execute = function(dz, item)
local motionah = dz.devices('MS Achterhuis Beweging').state
local motionvh = dz.devices('MS Voorhuis Beweging').state
local motionkeuken = dz.devices('MS Keuken Beweging').state
local motionhal = dz.devices('MS Hal Beweging').state
local motionbeneden = dz.devices('Bewegingsdetectie-Beneden')
dz.log('State of MS Achterhuis Beweging ' .. motionah, dz.LOG_DEBUG)
dz.log('State of MS Voorhuis Beweging ' .. motionvh, dz.LOG_DEBUG)
dz.log('State of MS Keuken Beweging ' .. motionkeuken, dz.LOG_DEBUG)
dz.log('State of MS Hal Beweging ' .. motionhal, dz.LOG_DEBUG)
dz.log('State of virtual switch Bewegingsdetectie-Beneden ' .. motionbeneden.state, dz.LOG_DEBUG)
if motionbeneden.state == 'Off' and (motionah == 'On' or motionvh == 'On' or motionkeuken == 'On' or motionhal == 'On') then
motionbeneden.switchOn()
--dz.log('Switching motion Beneden on', dz.LOG_DEBUG)
elseif motionbeneden.state == 'On' and motionah == 'Off' and motionvh == 'Off' and motionkeuken == 'Off' and motionhal == 'Off' then
motionbeneden.switchOff().afterSec(30)
--dz.log('Switching motion Beneden off', dz.LOG_DEBUG)
end
end
}
This is working in my case.