Page 2 of 2

Re: My dzVents Bathroom Humidity Control script

Posted: Sunday 16 July 2017 17:07
by Slorf
Hi,

I am trying to get the script to work, but unsuccessfully :-(

Our fanbox has 3 settings.

Setting 1: no one home ( only use this when we are on vacation, manually )
Setting 2: normal setting
Setting 3: shower of cooking

Plan is to have a remote in every ( 2 ) bathroom and a remote in the kitchen, when a remote is pressed the fanbox goes to setting 3, what I do not understand is how the targetHum can be higher then the Current Humidity, I am using dzVents 1.1

I did not change anything in the script except following lines:

local FAN_DEVICE = 'Ventilatie-3-Virtual' -- Fan device ( this a virtual switch that controls the fanbox settings )
local FORCE_FAN_DEVICE = 'Ventilatie-Remote-Virtual' -- (Optional) ( this is a virtual switch that goes on when I press a remote )
local FORCE_FAN_TIME = 45 -- Minutes to force the fan when button pushed
local HUMIDITY_SENSORS = {'Badkamer', 'Douche'}
local FAN_DELTA_TRIGGER = 5 -- % Rise in humidity that will trigger the fan
local FAN_MAX_TIME = 45 -- Maximum minutes that the fan can be on in case we never reach the target humidity
local TARGET_OFFSET = 1 -- Fan goes off if target + offset is reached
local TEST_MODE_HUMIDITY_READING = 0 -- Set to a value between 1 and 100. Set to 0 to disable test mode
local DEBUG = true
local READING_SAMPLES = 15

When I run the script it starts the fanbox all the time

2017-07-16 17:01:00.466 LUA: =====================================================

2017-07-16 17:01:00.466 LUA: >>> Handler: fanspeed

2017-07-16 17:01:00.466 LUA: .....................................................

2017-07-16 17:01:00.479 LUA: Dehumidification program doesn't run for: Badkamer

2017-07-16 17:01:00.479 LUA: targetHum: 74, Current humidity: 73, humDelta: 0

2017-07-16 17:01:00.480 LUA: Dehumidification program doesn't run for: Douche

2017-07-16 17:01:00.480 LUA: targetHum: 68, Current humidity: 67, humDelta: 0

2017-07-16 17:01:00.480 LUA: Turning the fan On

2017-07-16 17:01:00.485 LUA: .....................................................

2017-07-16 17:01:00.485 LUA: <<< Done

2017-07-16 17:01:00.485 LUA: -----------------------------------------------------

2017-07-16 17:01:00.486 LUA: [1] = Ventilatie-3-Virtual: On

2017-07-16 17:01:00.486 LUA: =====================================================

2017-07-16 17:01:00.487 EventSystem: Script event triggered: /home/domoticz/domoticz/scripts/lua/script_time_main.lua

Re: My dzVents Bathroom Humidity Control script

Posted: Thursday 10 August 2017 16:13
by BakSeeDaa
New version. Updated original post. Bathroom Humidity Control script to version 1.3.0.
Slorf wrote: Sunday 16 July 2017 17:07 When I run the script it starts the fanbox all the time
Hi there! I can't say what's going on really. Can you please upgrade both dzVents and the Bathroom Humidity Control script to latest version. After that, please let me know if you still experience any issues with my script.

Re: My dzVents Bathroom Humidity Control script

Posted: Sunday 20 August 2017 11:17
by renerene
I have tested your script in the first posting. It works ok, but the functionaliy of the override button is limited.

Can you please add following functionality: force fan off with override button. And stays off for 20 minutes or so. Because sometimes it triggers falsly (humidity rise but no shower) or want it to end because I open the window

Re: My dzVents Bathroom Humidity Control script

Posted: Monday 21 August 2017 8:37
by BakSeeDaa
renerene wrote: Sunday 20 August 2017 11:17 I have tested your script in the first posting. It works ok, but the functionaliy of the override button is limited.

Can you please add following functionality: force fan off with override button. And stays off for 20 minutes or so. Because sometimes it triggers falsly (humidity rise but no shower) or want it to end because I open the window
To customize the script to fit your needs you can easily add something similar to this:

After:

Code: Select all

			if ((forceFanReadings.getLatest().time.minutesAgo < FAN_MAX_TIME)
			and (forceFanReadings.getLatest().data == 'On')) then fanCmd = 'On' end
Add:

Code: Select all

			local blockingDevice = domoticz.devices('A window or a button')
			if blockingDevice.state == 'On'
			and blockingDevice.lastUpdate.minutesAgo < 20  then
				fanCmd = 'Off'
				domoticz.log('The blocking device prevents the fan from running', domoticz.LOG_INFO)
			end
Cheers!

Re: My dzVents Bathroom Humidity Control script

Posted: Wednesday 23 August 2017 14:21
by R0yk3
Hi, The script runs every minute, but it does not have to run when you're not at home. I have 2 (dummy) switches who turn on when my wife or me is at home (phone connects to network). So would it be a improvement to only le the script to run when one or both phones are at home, or is that a total waste of characters ;)

i am using this presence detection.
viewtopic.php?f=61&t=15531

Re: My dzVents Bathroom Humidity Control script

Posted: Wednesday 23 August 2017 19:33
by BakSeeDaa
R0yk3 wrote: Wednesday 23 August 2017 14:21 Hi, The script runs every minute, but it does not have to run when you're not at home. I have 2 (dummy) switches who turn on when my wife or me is at home (phone connects to network). So would it be a improvement to only le the script to run when one or both phones are at home, or is that a total waste of characters ;)

i am using this presence detection.
viewtopic.php?f=61&t=15531
You can easily modify the script to do a "return" if there is no presence detected at home. The script would still have to be invoked though. I believe though that the time you can save is so small so it won't be worth it.

You can easily measure how long time the script takes inside the execute function.
When I measure the script here, the measured time varies between 0.001 to 0.022

You can check your own script by logging dzVents and do some counting or you can do like this

After

Code: Select all

	execute = function(domoticz, device, triggerInfo)
Insert

Code: Select all

		local x = os.clock()
At the very few lines of the script... before

Code: Select all

	end
}
Insert

Code: Select all

domoticz.log(string.format("elapsed time: %.3f\n", os.clock() - x), domoticz.LOG_FORCE)

Re: My dzVents Bathroom Humidity Control script

Posted: Thursday 24 August 2017 8:53
by R0yk3
BakSeeDaa, the thought behind the question was to have less stress on the rpi. Do not run scripts when it is not necessary to run them. Less running scripts, less logging, less possible errors, les cpu stress etc. etc...
Like put the scripts asleep until triggered, then run every minute until put to sleep..

Re: My dzVents Bathroom Humidity Control script

Posted: Thursday 24 August 2017 15:18
by BakSeeDaa
R0yk3 wrote: Thursday 24 August 2017 8:53 BakSeeDaa, the thought behind the question was to have less stress on the rpi. Do not run scripts when it is not necessary to run them. Less running scripts, less logging, less possible errors, les cpu stress etc. etc...
Like put the scripts asleep until triggered, then run every minute until put to sleep..
It's beyond the scope of this topic but if you want to prevent the execute part of the script from being executed you can put a function in the active-setting as described in the dzVents Wiki.

However such a function will run every cycle so I think you won't gain something, actually I believe it will be counterproductive.

If you really need to save some CPU cycles on a dzVents script I believe the only way is to have another script rename those scripts you want to put asleep (out of the dzVents scripts folder) during the time they are not needed. That would be effective.

Please start a new topic if you'd like to discuss optimizing dzVents scripts.

EDIT: Maybe just do like this will do:

After:

Code: Select all

execute = function(domoticz, device, triggerInfo)
Add:

Code: Select all

if domoticz.devices('Presence Detected').state == 'On' then return end
This example assumes that you have a Domoticz device named 'Presence Detected' that is on when you are present.

Re: My dzVents Bathroom Humidity Control script

Posted: Wednesday 06 September 2017 20:09
by YcKe
Hi BakSeeDaa,

thanks a lot for your example script!

I think you made a little error in the script:

Code: Select all

if ((forceFanReadings.getLatest().time.minutesAgo < FAN_MAX_TIME)
         and (forceFanReadings.getLatest().data == 'On')) then fanCmd = 'On' end
FAN_MAX_TIME should be replaced with FORCE_FAN_TIME as we are checking to see if the forced time on is not exceeded.

The if statement eventually should look like this:

Code: Select all

if ((forceFanReadings.getLatest().time.minutesAgo < FORCE_FAN_TIME)
			and (forceFanReadings.getLatest().data == 'On')) then fanCmd = 'On' end
Greetz YcKe

Re: My dzVents Bathroom Humidity Control script

Posted: Thursday 07 September 2017 15:28
by BakSeeDaa
YcKe wrote: Wednesday 06 September 2017 20:09 Hi BakSeeDaa,

thanks a lot for your example script!

I think you made a little error in the script:

Code: Select all

if ((forceFanReadings.getLatest().time.minutesAgo < FAN_MAX_TIME)
         and (forceFanReadings.getLatest().data == 'On')) then fanCmd = 'On' end
FAN_MAX_TIME should be replaced with FORCE_FAN_TIME as we are checking to see if the forced time on is not exceeded.

The if statement eventually should look like this:

Code: Select all

if ((forceFanReadings.getLatest().time.minutesAgo < FORCE_FAN_TIME)
			and (forceFanReadings.getLatest().data == 'On')) then fanCmd = 'On' end
Greetz YcKe
Thanks YcKe. I will correct that! :D

Re: My dzVents Bathroom Humidity Control script

Posted: Thursday 07 September 2017 15:36
by BakSeeDaa
Updated the script to version 1.3.1. Please see the release notices for details.

Re: My dzVents Bathroom Humidity Control script

Posted: Tuesday 26 September 2017 9:53
by D3LTA
2 questions..

How can i use it with 1 humidity sensor? tried just using 1 but script calculates delta from 2 devices and im not skilled enough to chaneg that.. i fixed it now by just adding the humidity sensor name 2 times..

and what is "READING_SAMPLES = 15" ?

Re: My dzVents Bathroom Humidity Control script

Posted: Tuesday 14 November 2017 23:01
by Skippiemanz
Slorf wrote: Sunday 16 July 2017 17:07 Hi,

I am trying to get the script to work, but unsuccessfully :-(

Our fanbox has 3 settings.

Setting 1: no one home ( only use this when we are on vacation, manually )
Setting 2: normal setting
Setting 3: shower of cooking

Plan is to have a remote in every ( 2 ) bathroom and a remote in the kitchen, when a remote is pressed the fanbox goes to setting 3, what I do not understand is how the targetHum can be higher then the Current Humidity, I am using dzVents 1.1

I did not change anything in the script except following lines:

local FAN_DEVICE = 'Ventilatie-3-Virtual' -- Fan device ( this a virtual switch that controls the fanbox settings )
local FORCE_FAN_DEVICE = 'Ventilatie-Remote-Virtual' -- (Optional) ( this is a virtual switch that goes on when I press a remote )
local FORCE_FAN_TIME = 45 -- Minutes to force the fan when button pushed
local HUMIDITY_SENSORS = {'Badkamer', 'Douche'}
local FAN_DELTA_TRIGGER = 5 -- % Rise in humidity that will trigger the fan
local FAN_MAX_TIME = 45 -- Maximum minutes that the fan can be on in case we never reach the target humidity
local TARGET_OFFSET = 1 -- Fan goes off if target + offset is reached
local TEST_MODE_HUMIDITY_READING = 0 -- Set to a value between 1 and 100. Set to 0 to disable test mode
local DEBUG = true
local READING_SAMPLES = 15

When I run the script it starts the fanbox all the time

2017-07-16 17:01:00.466 LUA: =====================================================

2017-07-16 17:01:00.466 LUA: >>> Handler: fanspeed

2017-07-16 17:01:00.466 LUA: .....................................................

2017-07-16 17:01:00.479 LUA: Dehumidification program doesn't run for: Badkamer

2017-07-16 17:01:00.479 LUA: targetHum: 74, Current humidity: 73, humDelta: 0

2017-07-16 17:01:00.480 LUA: Dehumidification program doesn't run for: Douche

2017-07-16 17:01:00.480 LUA: targetHum: 68, Current humidity: 67, humDelta: 0

2017-07-16 17:01:00.480 LUA: Turning the fan On

2017-07-16 17:01:00.485 LUA: .....................................................

2017-07-16 17:01:00.485 LUA: <<< Done

2017-07-16 17:01:00.485 LUA: -----------------------------------------------------

2017-07-16 17:01:00.486 LUA: [1] = Ventilatie-3-Virtual: On

2017-07-16 17:01:00.486 LUA: =====================================================

2017-07-16 17:01:00.487 EventSystem: Script event triggered: /home/domoticz/domoticz/scripts/lua/script_time_main.lua
I'm trying to do the same thing, i have a fan under a selector switch. it has 3 levels, off, medium, maximum

I have the following script, the only thing i cant find out is where to putt the off level?! Maybe @BackSeeDaae knows?:
Spoiler: show

Code: Select all

--[[
bathroomHumControl.lua by BakSeeDaa
Version 1.3.1
	This script controls the humidity in a typical bathroom setting by detecting
	relative rises in humidity in a short period.
--]]

local FAN_DEVICE = 'Badkamer Ventilator' -- Fan device
local FORCE_FAN_DEVICE = 'Badkamer PIR' -- (Optional)
local FORCE_FAN_TIME = 10 -- Minutes to force the fan when button pushed
local HUMIDITY_SENSORS =  {'Badkamer Temp + Hum'}
local FAN_DELTA_TRIGGER = 3 -- % Rise in humidity that will trigger the fan
local FAN_MAX_TIME = 24 -- Maximum minutes that the fan can be on in case we never reach the target humidity
local TARGET_OFFSET = 3 -- Fan goes off if target + offset is reached
local TEST_MODE_HUMIDITY_READING = 0 -- Set to a value between 1 and 100. Set to 0 to disable test mode
local READING_SAMPLES = 15

-- Create the data declarations
local data = {}
for i, device in pairs(HUMIDITY_SENSORS) do
	data[device] = {history = true, maxItems = READING_SAMPLES + 1}
	data['dehumidProgramActive'..i] = {history = true, maxItems = 1} -- Need history to get time stamp
	data['forceFan'] = {history = true, maxItems = 1} -- Need history to get time stamp
	data['targetHum'..i] = {initial=0}
end

return {
	active = true,
	logging = {
		--level = domoticz.LOG_DEBUG, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
		marker = "bathRoom"
	},
	on = {
		devices = {
			FORCE_FAN_DEVICE
		},
		timer = {
			'every minute'
		}
	},
	data = data,
	execute = function(domoticz, device, triggerInfo)
		local forceFanReadings = domoticz.data.forceFan

		if (triggerInfo.type == domoticz.EVENT_TYPE_TIMER) then
			local fanCmd = 'Off'
			for i = 1, #HUMIDITY_SENSORS do
				local humidityReadings = domoticz.data[HUMIDITY_SENSORS[i]]
				-- Store the read value in the persistant data
				for j = 1, (humidityReadings.size == 0 and READING_SAMPLES + 1 or 1) do
					humidityReadings.add((TEST_MODE_HUMIDITY_READING == 0
						and domoticz.devices(HUMIDITY_SENSORS[i]).humidity or TEST_MODE_HUMIDITY_READING))
				end

				-- INIT
				local programActiveReadings = domoticz.data['dehumidProgramActive'..i]
				if (programActiveReadings.size == 0) then
					domoticz.log('programActiveReadings, Initialization was needed', domoticz.LOG_INFO)
					programActiveReadings.add(false)
				end
				local targetHum = domoticz.data['targetHum'..i]
				if (targetHum == nil) then
					domoticz.log('targetHum'..i..', Initialization was needed', domoticz.LOG_INFO)
					domoticz.data['targetHum'..i] = 0
					targetHum = 0
				end
				if (forceFanReadings.size == 0) then
					domoticz.log('forceFanReadings, Initialization was needed', domoticz.LOG_INFO)
					forceFanReadings.add('Init')
				end

				local programActiveState = programActiveReadings.getLatest()
				if (programActiveState.data) then -- The fan control program is active
					-- Has the fan control program timed out or have we reached the target humidity?
					local maxTime = (programActiveState.time.minutesAgo > FAN_MAX_TIME)
					local targetHumReached = (humidityReadings.getLatest().data <= targetHum)
					if (maxTime or targetHumReached) then
						domoticz.log('Dehumidification program stops for: '..HUMIDITY_SENSORS[i], domoticz.LOG_INFO)
						domoticz.log('Reason(s): '..(maxTime and 'Max time. ' or '')..(targetHumReached and 'Target humidity reached.' or ''), domoticz.LOG_INFO)
						programActiveReadings.add(false)
						programActiveState = programActiveReadings.getLatest()
					else
						domoticz.log('Dehumidification program is active for: '..HUMIDITY_SENSORS[i], domoticz.LOG_INFO)
						fanCmd = 'On'
					end
				else -- The fan is currently not running under the control of this program
					-- Has there been a significant rise in humidity lately?
					local humDelta = humidityReadings.getLatest().data - humidityReadings.min(2, READING_SAMPLES + 1)
					-- Calculate a target humidity but never try to push humidity below 40
					targetHum = math.max(humidityReadings.min(2, READING_SAMPLES + 1) + TARGET_OFFSET, 40)
					if (humDelta > FAN_DELTA_TRIGGER and humidityReadings.getLatest().data > targetHum) then
						domoticz.data['targetHum'..i] = targetHum
						programActiveReadings.add(true)
						programActiveState = programActiveReadings.getLatest()
						fanCmd = 'On'
						domoticz.log('Dehumidification program starts as a respond to: '..HUMIDITY_SENSORS[i], domoticz.LOG_INFO)
					else
						domoticz.log('Dehumidification program doesn\'t run  for: '..HUMIDITY_SENSORS[i], domoticz.LOG_INFO)
					end
					domoticz.log('targetHum: '..targetHum..', Current humidity: '..humidityReadings.getLatest().data..', humDelta: '..humDelta, domoticz.LOG_INFO)
				end
			end

			if ((forceFanReadings.getLatest().time.minutesAgo < FORCE_FAN_TIME)
			and (forceFanReadings.getLatest().data == 'On')) then fanCmd = 'On' end

			if (domoticz.devices(FAN_DEVICE).state ~= fanCmd) then
				domoticz.log('Turning the fan '..fanCmd, domoticz.LOG_INFO)
				domoticz.devices(FAN_DEVICE).switchSelector(20)
			end
		else
			-- The script gets executed due to a device-change event
			if (device.name == FORCE_FAN_DEVICE and device.state == 'On') then
				forceFanReadings.add('On')
				domoticz.log('The fan has been forced on for '..FORCE_FAN_TIME..'minutes.', domoticz.LOG_INFO)
				-- domoticz.helpers.speak(domoticz, 'joke sting')
				if (domoticz.devices(FAN_DEVICE).state ~= 'On') then domoticz.devices(FAN_DEVICE).switchSelector(10) end
			end
		end

	end
}

Re: My dzVents Bathroom Humidity Control script

Posted: Wednesday 15 November 2017 8:06
by BakSeeDaa
D3LTA wrote: Tuesday 26 September 2017 9:53 How can i use it with 1 humidity sensor? tried just using 1 but script calculates delta from 2 devices and im not skilled enough to chaneg that.. i fixed it now by just adding the humidity sensor name 2 times..
Just define a single sensor in the HUMIDITY_SENSORS table.
In the example, there are two sensors. So, remove one of them. E.g.

Code: Select all

local HUMIDITY_SENSORS =  {'My single sensor'}
D3LTA wrote: Tuesday 26 September 2017 9:53 and what is "READING_SAMPLES = 15" ?
The script compares the current humidity with recent readings to determine if there has been a significant rise in humidity. Those readings will be within the latest 15 minutes if READING_SAMPLES is set to 15 and the script runs every minute.

Re: My dzVents Bathroom Humidity Control script

Posted: Wednesday 15 November 2017 8:19
by BakSeeDaa
Skippiemanz wrote: Tuesday 14 November 2017 23:01 I have the following script, the only thing i cant find out is where to putt the off level?! Maybe @BackSeeDaae knows?:
As you've experienced, the script isn't designed for controlling fans with more than two states (On and Off).

Of course it can be modified to handle several states but I haven't had the time to do so. I could put the source on gitHub if someone care to collaborate to implement that functionality.

Re: My dzVents Bathroom Humidity Control script

Posted: Friday 15 December 2017 18:55
by remb0
I like your script but the alarm script is the best example of a modular, easy to understand and well documented script.
maybe it's an idea to extend this script so it would be more like the ideAlarm?
I have some ideas:


people had different types of fans, on/off or levels, like I do
selector switch: fan has 4 states: 1 2 3 and 4(10 minutes on max) manual(or off)

I want to do the following:
The fan must always on level 1 and when showering max, and with hum rising level 2/3.
I have no force button but in the selector I added a option: manual. to override the script.

humidity rising
sometimes max but except in the night (we sleep near the ventilation box :P

tapping hot water from boiler (cv)
tapping hot water + motion now or in the last x minutes is showering.


Logging to csv:

logging to a csv, so in the debugging weeks you can see when the fan does rise and why.

Code: Select all

package.path = package.path .. ';' .. '/home/pi/domoticz/scripts/lua/?.lua'
My = require('MyFunc')

logfile = ' /home/pi/domoticz/Logs/Fan ~m.csv' 

function LogActions()
	LogFile=string.gsub(LogFile,"~d",os.date("%Y-%m-%d"))
	LogFile=string.gsub(LogFile,"~m",os.date("%Y-%m"))
	if not My.File_exists(LogFile) then
	 f=io.open(LogFile,"a")
	 f:write("Datum ; Tijd ; Man_or_Auto ; Stand ;  Reason  ; HumidityTmin10; HumidityTmin5; HumDelta; LeidingTmin10; LeidingTmin5; LeidingDelta; FanRuntime; FanAanVoor; target")
     f:write("\r\n")
	 else
	 f=io.open(LogFile,"r")
	 c=f:read("*line")
	 f:close()
	 f=io.open(LogFile,"a")
   end
    f:write(os.date("%Y-%m-%d;%H:%M:%S") .. ";" .. Man_or_Auto .. ";" .. Stand .. ";" .. My.EnumClear(Reason) ..  ";"  .. HumidityTmin10 .. ";" .. HumidityTmin5 .. ";" .. HumDelta .. ";" .. LeidingTmin10 .. ";" .. LeidingTmin5 .. ";" .. LeidingDelta .. ";" .. FanRuntime .. ";" .. FanAanVoor .. ";" .. target)
    f:write("\r\n")
    f:close()
end

I have now:

Code: Select all

if (BoilerTemp.temperature > WaterTempTriggerOn and SomebodyHome == 'On') then
	fanCmd = 30
	domoticz.devices(FAN_DEVICE).switchSelector(fanCmd).forMin(FORCE_FAN_TIME)
	domoticz.log('Showering The fan has been forced on ' ..fanCmd.. ' for '..FORCE_FAN_TIME..' minutes.', domoticz.LOG_INFO)
end
Is it possible to check first what the status is, and when the level/status is the same it doesn't switch?

Re: My dzVents Bathroom Humidity Control script

Posted: Sunday 17 December 2017 17:28
by BakSeeDaa
Thanks for your suggestions remb0

Sometimes it's very hard to make a script that can be used by everyone. I feel this script needs an overhaul. Currently I'm in some other projects but eventually I will have some time to have a look at it and see if it can be improved. Thanks for your kind words about ideAlarm ;)

Another idea is to just put it on gitHub in case there are others interested to collaborate.

Cheers!

Re: My dzVents Bathroom Humidity Control script

Posted: Friday 23 February 2018 17:19
by glsf91
Great script.

This line

Code: Select all

local FAN_DELTA_TRIGGER = 3 -- % Rise in humidity that will trigger the fan
is suggesting the fan will go off if the rise is 3%.

But I think this is not the case when looking at:

Code: Select all

if (humDelta > FAN_DELTA_TRIGGER and humidityReadings.getLatest().data > targetHum) then
For percentage you can change to:

Code: Select all

percentageIncrease = (humDelta / humidityReadings.min(2, READING_SAMPLES + 1)) * 100
domoticz.log('Percentage increase: '..percentageIncrease, domoticz.LOG_INFO)
if ( percentageIncrease >= FAN_DELTA_TRIGGER and humidityReadings.getLatest().data > targetHum) then
Also a question:
Why are you using humidityReadings.min(2, READING_SAMPLES + 1) instead of humidityReadings.avg(2, READING_SAMPLES + 1) ?

If there is 1 low value (spike) the fan will go on because of this.

Re: My dzVents Bathroom Humidity Control script

Posted: Monday 07 January 2019 15:32
by airmarshall
Great script. I need to fine tune the settings and position of the humidity sensor but initial impressions are great. I have it toggling a sonoff that powers the fan.

Is there anyone willing to 'help' me alter to code to turn the Force Fan Device into a toggle rather than simply and ON for X minutes device.

I'd like to be able to FORCE the fan off with the same button used to force it on.

Still trying to decipher the script in my head but if someone has already done this....

TIA, Dan

Re: My dzVents Bathroom Humidity Control script

Posted: Tuesday 02 November 2021 21:02
by madpatrick
Hi,

I know this is an old thread, but i'm trying to get the script working without luck.

This is the error i'm getting.

Code: Select all

2021-11-02 21:00:12.499 Error: dzVents: Error: (3.1.7) .../domoticz/scripts/dzVents/generated_scripts/Badkamer.lua:20: bad argument #1 to 'for iterator' (table expected, got number)
2021-11-02 21:00:23.024 Zwave USB: Temp + Humidity (Air Temperature/Humidity)
2021-11-02 21:00:23.183 Zwave USB: Temp + Humidity (Air Temperature/Humidity)
2021-11-02 21:00:23.069 Error: dzVents: Error: (3.1.7) .../domoticz/scripts/dzVents/generated_scripts/Badkamer.lua:20: bad argument #1 to 'for iterator' (table expected, got number)
2021-11-02 21:00:23.233 Error: dzVents: Error: (3.1.7) .../domoticz/scripts/dzVents/generated_scripts/Badkamer.lua:20: bad argument #1 to 'for iterator' (table expected, got number)
Any clue how to solve this ?