Hi Guys,
I have for me an excellent DZ Vents Script created for me, it runs nearly every light in the house, however I could do with some assistance to tweak it a bit.
I'm going to add a door sensor to my bathroom door and would like to have it set like so:
if detector picks you up and the door remains open continue as normal
if the door is closed regardless of the detector state, lights to come on indefinately until door is opened but @20%
and after 23:30 just come on @1% as it is now
Many Thanks
Modify DZ Vents [Solved]
Moderator: leecollings
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Modify DZ Vents
Forgot to attach code
Cheers
Code: Select all
return {
on = {
devices = {
"Bathroom MD Burglar",
}
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "Bathroom Motion"
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(str,level or dz.LOG_DEBUG)
end
-- local Lux = dz.devices("Kitchen MD Lux").lux
local LuxDevice = dz.devices(177) -- <<<--- replace xxx by IDX of your Lux device
local Lux = LuxDevice.lux
-- local Lights = dz.devices("Bathroom Dimmer Level")
local Lights = dz.devices(68) -- <<<--- replace xxx by IDX of your Bathroom lights
logWrite(LuxDevice.name .. " ==>> Lux: " .. Lux )
logWrite(Lights.name .. " ==>> State: " .. Lights.state)
logWrite(item.name .. " ==>> State: " .. item.state)
if Lux < 1020 and item.state == "On" then
Lights.cancelQueuedCommands()
if dz.time.matchesRule("at 23:30-06:00") then
Lights.dimTo(01)
else
Lights.dimTo(90)
end
elseif item.state == "Off" and Lights.state == "On" then
Lights.switchOff().afterSec(300)
end
end
} - waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Modify DZ Vents
If my interpretation of your requirements is correct it could look likealarm_guy1 wrote: Saturday 20 July 2019 1:52 I'm going to add a door sensor to my bathroom door and would like to have it set like so:
if detector picks you up and the door remains open continue as normal
if the door is closed regardless of the detector state, lights to come on indefinately until door is opened but @20%
and after 23:30 just come on @1% as it is now
Code: Select all
local bathroomSensor = "Bathroom MD Burglar"
local bathroomDoor = "Bathroom door"
return
{
on =
{
devices =
{
bathroomSensor,
bathroomDoor,
},
timer =
{
"every 5 minutes between 23:30 and 06:00",
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = "Bathroom Motion"
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(str,level or dz.LOG_DEBUG)
end
local door = dz.devices(bathroomDoor)
local sensor = dz.devices(bathroomSensor)
-- local Lux = dz.devices("Kitchen MD Lux").lux
local LuxDevice = dz.devices(177) -- <<<--- replace xxx by IDX of your Lux device
local Lux = LuxDevice.lux
-- local Lights = dz.devices("Bathroom Dimmer Level")
local Lights = dz.devices(68) -- <<<--- replace xxx by IDX of your Bathroom lights
logWrite(LuxDevice.name .. " ==>> Lux: " .. Lux )
logWrite(Lights.name .. " ==>> State: " .. Lights.state)
logWrite(door.name .. " ==>> State: " .. door.state)
logWrite(sensor.name .. " ==>> State: " .. sensor.state)
local function timeConditionalDimmer(wake, sleep)
if not wake then wake = 90 end
if not sleep then sleep = 1 end
Lights.cancelQueuedCommands()
if dz.time.matchesRule("at 23:30-06:00") then
Lights.dimTo(sleep)
else
Lights.dimTo(wake)
end
end
if item.isTimer then
if ( door.state == "Closed" ) and ( door.lastUpdate.secondsAgo > 300 ) and ( sensor.lastUpdate.secondsAgo > 300 ) then
timeConditionalDimmer()
end
elseif Lux < 1020 and sensor.state == "On" then
timeConditionalDimmer()
elseif door.state == "Closed" then
timeConditionalDimmer(20)
elseif sensor.state == "Off" and Lights.state == "On" and door.state == "Open" then
Lights.switchOff().afterSec(300)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
alarm_guy1
- Posts: 132
- Joined: Tuesday 14 January 2014 0:03
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Modify DZ Vents [Solved]
Cool cheers.
Im just in the process of adding the contact to my alarm system then I will implement this code.
It wont be for a week or so as I never expected such a swift response.
Many many thanks.
I will let you know how it goes
cheers
Im just in the process of adding the contact to my alarm system then I will implement this code.
It wont be for a week or so as I never expected such a swift response.
Many many thanks.
I will let you know how it goes
cheers
Who is online
Users browsing this forum: No registered users and 1 guest