Page 1 of 1
Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 13:05
by Markiey99
Hello guys,
I have the following problem, I am unable to turn on the fan in the toilet when the lamp in the toilet is on for more than 2 minutes.
I now use a blockly where I can only set the fan to turn on after x number of seconds, but if the lamp is on for less than the set number of seconds, the fan will still turn on.
Now I have seen that with a LUA script you can control it better with the 'last seen' status of the lamp. But unfortunately I can't get this done ..
example script which I am currently using but does not work. :
Code: Select all
t1 = os.time ()
s = otherdevices_lastupdate ['WC']
- returns a date time like 2013-07-11 17:23:12
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)
commandArray = {}
t2 = os.time {year = year, month = month, day = day, hour = hour, min = minutes, sec = seconds}
difference = (os.difftime (t1, t2))
if (otherdevices ['WC'] == 'On' and difference> 120 and difference <130) then
commandArray ['ventilation'] = 'On'
end
return commandArray
Kind regards,
Mark
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 14:16
by Treve
if I understand correctly, should the fan turn on if the lamp is on for more than 2 minutes and turn off when the lamp goes out again?
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 16:02
by Markiey99
Thanks for your reply
If the light is on longer than 2min, the fan should turn on. And if the light is shorter than 2min on the fan does not turn on. When the light goes out, the fan should remain on when it is turned on.
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 16:25
by Treve
Markiey99 wrote: ↑Tuesday 06 October 2020 16:02
Thanks for your reply
If the light is on longer than 2min, the fan should turn on. And if the light is shorter than 2min on the fan does not turn on.
This is easely done by a Blockly
When the light goes out, the fan should remain on when it is turned on.
When or what switch the Fan off?
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 17:02
by Markiey99
With blockly it is not possible, I have already tried everything in that. Blockly can't handle the option if the light is on shorter than 2min
The fan goes automaticly off.
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 17:30
by Treve

- B1.jpg (25.84 KiB) Viewed 1523 times
Set the delay of 2 minutes

- B2.jpg (24.94 KiB) Viewed 1523 times
The second set (Ventilator = off) stops the timer of the Fan
This is working at my Domoticz 2020.2
Evert
Re: Switch on Ventilation Toilet. [Solved]
Posted: Tuesday 06 October 2020 17:42
by waaren
Markiey99 wrote: ↑Tuesday 06 October 2020 17:02
With blockly it is not possible, I have already tried everything in that. Blockly can't handle the option if the light is on shorter than 2min
This dzVents script should do it
______________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading
Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
______________________________________________________________________________________________________________________________
Code: Select all
return
{
on =
{
devices =
{
'WC', -- WC light
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all OK
marker = 'Fan control',
},
execute = function(dz, item)
local fan = dz.devices('ventilation')
if item.active then
fan.switchOn().afterSec(120)
else
fan.cancelQueuedCommands()
-- fan.switchOff().afterSec(5) -- uncomment if fan auto off takes too long
end
end
}
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 17:49
by waaren
Treve wrote: ↑Tuesday 06 October 2020 17:30
This is working at my Domoticz 2020.2
Nice find!
Reason why I prefer to do this with a dzVents script is that this kind of Blockly script is executed on every device update on the system. On my production system that is on average > 100 times/minute
Re: Switch on Ventilation Toilet.
Posted: Tuesday 06 October 2020 17:57
by Treve
I think dzvents is a better solution but I’m not a programmer and try to find solutions at the blockly front. Most of the times I find a solution whether or not supported with variables.
Re: Switch on Ventilation Toilet.
Posted: Wednesday 07 October 2020 14:29
by Markiey99
waaren wrote: ↑Tuesday 06 October 2020 17:42
Markiey99 wrote: ↑Tuesday 06 October 2020 17:02
With blockly it is not possible, I have already tried everything in that. Blockly can't handle the option if the light is on shorter than 2min
This dzVents script should do it
______________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading
Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
______________________________________________________________________________________________________________________________
Code: Select all
return
{
on =
{
devices =
{
'WC', -- WC light
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all OK
marker = 'Fan control',
},
execute = function(dz, item)
local fan = dz.devices('ventilation')
if item.active then
fan.switchOn().afterSec(120)
else
fan.cancelQueuedCommands()
-- fan.switchOff().afterSec(5) -- uncomment if fan auto off takes too long
end
end
}
Thank you! All working great now!
Re: Switch on Ventilation Toilet.
Posted: Wednesday 07 October 2020 14:34
by Markiey99
Treve wrote: ↑Tuesday 06 October 2020 17:57
I think dzvents is a better solution but I’m not a programmer and try to find solutions at the blockly front. Most of the times I find a solution whether or not supported with variables.
Thank you too, I've been trying to do exactly the same thing with blockly because I can't program either. But with the quick help on this forum it is still possible to use a programmed script

Re: Switch on Ventilation Toilet.
Posted: Wednesday 07 October 2020 15:32
by Treve
Markiey99 wrote:
Thank you! All working great now!
Witch solution did you choose?
Switch on Ventilation Toilet.
Posted: Wednesday 07 October 2020 15:42
by Treve
Markiey99 wrote:Treve wrote: ↑Tuesday 06 October 2020 17:57
I think dzvents is a better solution but I’m not a programmer and try to find solutions at the blockly front. Most of the times I find a solution whether or not supported with variables.
Thank you too, I've been trying to do exactly the same thing with blockly because I can't program either. But with the quick help on this forum it is still possible to use a programmed script

I can implement the most scripts, if you can read, you can make use of knowledge of programmers.
I struggle now how to login as Root to save the backup’s, I tried a lot without succes. I must read a lot more on the Forum I think.
Re: Switch on Ventilation Toilet.
Posted: Wednesday 07 October 2020 22:37
by Markiey99
Treve wrote: ↑Wednesday 07 October 2020 15:32
Markiey99 wrote:
Thank you! All working great now!
Witch solution did you choose?
dzVentz
Re: Switch on Ventilation Toilet.
Posted: Wednesday 07 October 2020 22:39
by Markiey99
Treve wrote: ↑Wednesday 07 October 2020 15:42
Markiey99 wrote:Treve wrote: ↑Tuesday 06 October 2020 17:57
I think dzvents is a better solution but I’m not a programmer and try to find solutions at the blockly front. Most of the times I find a solution whether or not supported with variables.
Thank you too, I've been trying to do exactly the same thing with blockly because I can't program either. But with the quick help on this forum it is still possible to use a programmed script

I can implement the most scripts, if you can read, you can make use of knowledge of programmers.
I struggle now how to login as Root to save the backup’s, I tried a lot without succes. I must read a lot more on the Forum I think.
Automaticly backups to the cloud are also on my to do list.

Re: Switch on Ventilation Toilet.
Posted: Thursday 08 October 2020 16:58
by Treve
Finally I found a editor (VIM) which allow me to edit a root file (sshd_config) as pi user.
Now I’m able to login as root user.