My dzVents Bathroom Humidity Control script

Slorf
Posts: 64
Joined: Friday 20 December 2013 12:55
Target OS: Raspberry Pi
Domoticz version:
Location: Voorburg
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by Slorf » 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
A lot of stuff :[-)

Orange PI
Evohome with HGI-80
SmartMeter USB Cable
Solar panels
RFLINK 433 MHz
AeonLabs usb z-wave plus
My Sensors ( Lan Gateway )
Wemos sensors
Arduino sensors

User avatar
BakSeeDaa
Posts: 434
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by BakSeeDaa » Thursday 10 August 2017 16:13

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.
Best wishes

// บักสีดา

renerene
Posts: 73
Joined: Wednesday 03 August 2016 11:36
Target OS: -
Domoticz version:
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by renerene » 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

User avatar
BakSeeDaa
Posts: 434
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by BakSeeDaa » Monday 21 August 2017 8:37

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!
Best wishes

// บักสีดา

R0yk3
Posts: 39
Joined: Sunday 24 July 2016 21:51
Target OS: Raspberry Pi
Domoticz version: beta
Location: the Netherlands
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by R0yk3 » 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

User avatar
BakSeeDaa
Posts: 434
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by BakSeeDaa » Wednesday 23 August 2017 19:33

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)
Best wishes

// บักสีดา

R0yk3
Posts: 39
Joined: Sunday 24 July 2016 21:51
Target OS: Raspberry Pi
Domoticz version: beta
Location: the Netherlands
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by R0yk3 » 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..

User avatar
BakSeeDaa
Posts: 434
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by BakSeeDaa » Thursday 24 August 2017 15:18

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.
Best wishes

// บักสีดา

YcKe
Posts: 43
Joined: Sunday 03 July 2016 0:53
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by YcKe » 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

User avatar
BakSeeDaa
Posts: 434
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by BakSeeDaa » Thursday 07 September 2017 15:28

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
Best wishes

// บักสีดา

User avatar
BakSeeDaa
Posts: 434
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by BakSeeDaa » Thursday 07 September 2017 15:36

Updated the script to version 1.3.1. Please see the release notices for details.
Best wishes

// บักสีดา

D3LTA
Posts: 34
Joined: Monday 15 July 2013 2:37
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Twente
Contact:

Re: My dzVents Bathroom Humidity Control script

Post by D3LTA » Tuesday 26 September 2017 9:53

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" ?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest