Why does this dzVents script not work  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Why does this dzVents script not work

Post by RvdM »

Hi all,

After migrating to the newest version of Domoticz my climatControl scripts (written in dzVents) stopped working.
Based on the temperature and humidity in our home certain user variables are regularly set.
Based on several time scripts the mechanical fan should switch to a lower or higher RPM (DIMMER 0-10V Z-WAVE)

Tried to get this working again but somehow I can't. Even the log line doesn't work.

Code: Select all

return {
        active = true,
        on = {
                ['timer'] = {'at 19:28'}
        },
    
    	logging = {
            level = domoticz.LOG_DEBUG,
        },

        execute = function(dz)
            
            fan = dz.devices('Mechanische Ventilatie')
            target = domoticz.variables('climatControlBaselinePostCooking').value
            
            domoticz.log('Mechanische ventilatie snelheid wordt aangepast (Post-Cooking) - Level: ' .. target )
            fan.switchSelector(target)

        end
}
Logging:
Spoiler: show
2020-06-01 19:28:00.086 Status: dzVents: Info: ------ Start internal script: climatControlPostCooking:, trigger: "at 19:28"
2020-06-01 19:28:00.090 Status: dzVents: Debug: Processing device-adapter for Mechanische Ventilatie: Switch device adapter
2020-06-01 19:28:00.090 Status: dzVents: Info: ------ Finished climatControlPostCooking
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Why does this dzVents script not work

Post by besix »

I don't know dzVents, but it can help

Code: Select all

return {
        active = true,
        on = {
                ['timer'] = {'at 19:28'}
        },
    
    	logging = {
            level = domoticz.LOG_DEBUG,
        },

        execute = function(dz)
            
            fan = dz.devices('Mechanische Ventilatie')
            target = dz.variables('climatControlBaselinePostCooking').value
            
            dz.log('Mechanische ventilatie snelheid wordt aangepast (Post-Cooking) - Level: ' .. target )
            fan.switchSelector(target)

        end 
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Why does this dzVents script not work

Post by waaren »

RvdM wrote: Monday 01 June 2020 19:31 Tried to get this working again but somehow I can't. Even the log line doesn't work.
You cannot mix dz (first parm of the execute function) and domoticz in the body of the script. Either they are both dz or both domoticz.

What are the possible values of the variable climatControlBaselinePostCooking ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Re: Why does this dzVents script not work

Post by RvdM »

waaren wrote: Monday 01 June 2020 20:06
RvdM wrote: Monday 01 June 2020 19:31 Tried to get this working again but somehow I can't. Even the log line doesn't work.
You cannot mix dz (first parm of the execute function) and domoticz in the body of the script. Either they are both dz or both domoticz.

What are the possible values of the variable climatControlBaselinePostCooking ?
Ah yes. With that the printing works. However still not the adjustment of the fan.
User variable is a integer.

Code: Select all

return {
        active = true,
        on = {
                ['timer'] = {'at 21:14'}
        },
    
    	logging = {
            level = domoticz.LOG_DEBUG,
        },

        execute = function(dz)
            
            fan = dz.devices('Mechanische Ventilatie')
            target = dz.variables('climatControlBaselinePostCooking').value
            
            dz.log('Mechanische ventilatie snelheid wordt aangepast (Post-Cooking) - Level: ' .. target )
            fan.switchSelector(target)

        end
}
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Why does this dzVents script not work

Post by besix »

User variable is a integer.
But for the selector
must be 0ff, 10, 20 ..... 60
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Re: Why does this dzVents script not work

Post by RvdM »

Shouldnt that be fine with an integer?
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Why does this dzVents script not work

Post by besix »

Code example for selector

Code: Select all

if (dz.devices('Kominek').state == 'On' and dz.variables('kominek').value == 0) then
		    dz.devices('Kominek Wentylator').switchOn()
			dz.devices('Kominek przepustnica').switchSelector(60)
			dz.log('Rozpalanie')

The position of the selector 60 is the name of the level.
Level 1 is Off, 2 is 10, 3 is 20 etc.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Why does this dzVents script not work

Post by waaren »

RvdM wrote: Monday 01 June 2020 21:48 Shouldnt that be fine with an integer?
Yes, it should. Can you show whats in the log ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Why does this dzVents script not work

Post by waaren »

besix wrote: Monday 01 June 2020 21:52 The position of the selector 60 is the name of the level.
Sorry but no.

60 is the level in this example. The name can be any string.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Re: Why does this dzVents script not work

Post by RvdM »

waaren wrote: Monday 01 June 2020 22:21
RvdM wrote: Monday 01 June 2020 21:48 Shouldnt that be fine with an integer?
Yes, it should. Can you show whats in the log ?

Code: Select all

2020-06-01 22:29:00.464 Status: dzVents: Info: ------ Start internal script: climatControlPostCooking:, trigger: "at 22:29"
2020-06-01 22:29:00.468 Status: dzVents: Debug: Processing device-adapter for Mechanische Ventilatie: Switch device adapter
2020-06-01 22:29:00.468 Status: dzVents: Info: Mechanische ventilatie snelheid wordt aangepast (Post-Cooking) - Level: 50
2020-06-01 22:29:00.468 Status: dzVents: Info: ------ Finished climatControlPostCooking
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Why does this dzVents script not work

Post by waaren »

RvdM wrote: Monday 01 June 2020 22:42 [

Code: Select all

2020-06-01 22:29:00.464 Status: dzVents: Info: ------ Start internal script: climatControlPostCooking:, trigger: "at 22:29"
2020-06-01 22:29:00.468 Status: dzVents: Debug: Processing device-adapter for Mechanische Ventilatie: Switch device adapter
2020-06-01 22:29:00.468 Status: dzVents: Info: Mechanische ventilatie snelheid wordt aangepast (Post-Cooking) - Level: 50
2020-06-01 22:29:00.468 Status: dzVents: Info: ------ Finished climatControlPostCooking
I assume based on this that the device is not set at level 50 ?

Can you show a printscreen of the levels of the device?
What is the type / subtype (as seen on the device tab?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Re: Why does this dzVents script not work

Post by RvdM »

See attached, and no its not set to 50
Attachments
Schermafbeelding 2020-06-01 om 22.52.38.png
Schermafbeelding 2020-06-01 om 22.52.38.png (140.41 KiB) Viewed 1684 times
Schermafbeelding 2020-06-01 om 22.52.29.png
Schermafbeelding 2020-06-01 om 22.52.29.png (399.51 KiB) Viewed 1684 times
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Why does this dzVents script not work  [Solved]

Post by besix »

selector please no dimmer
or

Code: Select all

return {
        active = true,
        on = {
                ['timer'] = {'at 19:28'}
        },
    
    	logging = {
            level = domoticz.LOG_DEBUG,
        },

        execute = function(dz)
            
            fan = dz.devices('Mechanische Ventilatie')
            target = dz.variables('climatControlBaselinePostCooking').value
            
            dz.log('Mechanische ventilatie snelheid wordt aangepast (Post-Cooking) - Level: ' .. target )
            fan.dimTo(target)

        end 
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Why does this dzVents script not work

Post by waaren »

RvdM wrote: Monday 01 June 2020 22:53 See attached, and no its not set to 50
switchSelector is to be used for selector type devices. For dimmers you should use the dimTo() method
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Re: Why does this dzVents script not work

Post by RvdM »

That indeed was the probleem. No sure why it worked in older versions of Domoticz because this script was from a post 2020 release
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
User avatar
RvdM
Posts: 39
Joined: Friday 10 July 2015 21:06
Target OS: Linux
Domoticz version: 2020.2 1
Location: Deventer, NL
Contact:

Re: Why does this dzVents script not work

Post by RvdM »

Just started up the old machine and the code looks like this

Code: Select all

return {
        active = true,
        on = {
                ['timer'] = {'at 18:30'}
        },
        execute = function(domoticz)
                domoticz.log('Ventilatie op post-kookstand')
                domoticz.devices('Mechanische Ventilatie').switchSelector(domoticz.variables('climatControlBaselinePostCooking').value)
        end
}
Running virtualized domoticz server on a proxmox cluster with a slave for optimal RFX communication. Using Aeotec Z-Stick Gen5, rfxtrx433e, Homebridge and a Philips HUE bridge for all sort of home automation.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Why does this dzVents script not work

Post by waaren »

RvdM wrote: Monday 01 June 2020 23:23 Just started up the old machine.
Could well be that this switchSelector() method worked in your old version. It was never intended to work on a dimmer device and since the change in the switchSelector code in dzVents 2.4.22 it no longer work for dimmers.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest