[Solved] DzVents scripts not working anymore after upgrade  [Solved]

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

Moderator: leecollings

Post Reply
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

[Solved] DzVents scripts not working anymore after upgrade

Post by McJohn »

The 2 different scripts below worked perfectly in

Raspbian Stretch 9.8
Domoticz 4.9700

But after an upgrade / new installation to:

Raspbian Buster 10
Domoticz 2020.2 (build 12067)

Both scripts are dead.

Can somebody help us with the solution?
Thanks in advance.

Power available Script:

Code: Select all

return {
    on = {
            timer = { 'every minute' }},
        
    execute = function( dz )
        local voltage = dz.devices('Voltage')
        local power= dz.variables('Power')
        
        local function setvar(var, to)
            if var.value ~= to and dz.startTime.secondsAgo > 120 then var.set(to) end
        end
        
        if voltage.lastUpdate.secondsAgo > 120 then
            setvar(power,'Off')
        else
            setvar(power,'On')
        end
        
    end


Max temperature to Text Device script:

Code: Select all

local temperatureDevice = 'Temp+HumOutside -- change to name of your Temperature device
local temperatureTextDevice = 'TempOutside Max' -- change to name of your text device
local temperatureVariable = 'TempOutsideMax' -- change to name of your variable 

return {
            on = {
                     devices = { temperatureDevice }, 
                     timer = { 'at 00:03' },         -- time to reset variable and text device
                 },
            
    execute = function(dz, item)
        temperatureVariable =  dz.variables(temperatureVariable) 
        temperatureTextDevice = dz.devices(temperatureTextDevice)
        
        if item.isTimer then
            temperatureVariable.set(-55)
            temperatureTextDevice.updateText('max temp today: notset yet' .. dz.time.rawTime)
        elseif item.temperature > temperatureVariable.value then  
            temperatureVariable.set(dz.utils.round(item.temperature,1))
            temperatureTextDevice.updateText('max temp today: ' .. dz.utils.round(item.temperature,1) .. '° C om ' .. dz.time.rawTime)
        end
   end
}
Last edited by McJohn on Saturday 30 May 2020 21:19, edited 1 time in total.
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: DzVents scripts not working anymore after upgrade

Post by freijn »

I had a calculation going wrong.

There must be some hint in the log file. I suspect the round function
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: DzVents scripts not working anymore after upgrade

Post by waaren »

McJohn wrote: Saturday 30 May 2020 19:31 Can somebody help us with the solution?
I don't see something in the scripts that would cause them to fail.

Do you see anything in the log?
Do these scripts start at all; are there any other dzVents scripts active and working?

If you don't seen anything please double check if event system and dzVents are both set to active.

I activate debug logging in below scripts. Can you try again with these?

Code: Select all

return
{
    on =
    {
       timer =
       {
          'every minute',
       },
   },

   logging =
   {
       level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when everything executes without problems
   },

    execute = function( dz )
        local voltage = dz.devices('Voltage')
        local power= dz.variables('Power')

        local function setvar(var, to)
            if var.value ~= to and dz.startTime.secondsAgo > 120 then var.set(to) end
        end

        if voltage.lastUpdate.secondsAgo > 120 then
            setvar(power,'Off')
        else
            setvar(power,'On')
        end
    end
}

Code: Select all

local temperatureDevice = 'Temp+HumOutside -- change to name of your Temperature device
local temperatureTextDevice = 'TempOutside Max' -- change to name of your text device
local temperatureVariable = 'TempOutsideMax' -- change to name of your variable

return
{
    on =
    {
        devices =
        {
            temperatureDevice,
        },
        timer =
        {
           'at 00:03',
        },         -- time to reset variable and text device
    },

   logging =
   {
       level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when everything executes without problems
   },

    execute = function(dz, item)
        temperatureVariable =  dz.variables(temperatureVariable)
        temperatureTextDevice = dz.devices(temperatureTextDevice)

        if item.isTimer then
            temperatureVariable.set(-55)
            temperatureTextDevice.updateText('max temp today: notset yet' .. dz.time.rawTime)
        elseif item.temperature > temperatureVariable.value then
            temperatureVariable.set(dz.utils.round(item.temperature,1))
            temperatureTextDevice.updateText('max temp today: ' .. dz.utils.round(item.temperature,1) .. '° C om ' .. dz.time.rawTime)
        end
    end
}

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: DzVents scripts not working anymore after upgrade

Post by waaren »

freijn wrote: Saturday 30 May 2020 19:45 I had a calculation going wrong.

There must be some hint in the log file. I suspect the round function
The round function failed in some versions when it was feeded with a type string but here it is a number (the temperature attribute is of type number)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
McJohn
Posts: 91
Joined: Wednesday 10 October 2018 17:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Netherlands
Contact:

Re: DzVents scripts not working anymore after upgrade  [Solved]

Post by McJohn »

Thank you so much for the fast reply and the hint of the day:
If you don't seen anything please double check if event system and dzVents are both set to active.
That did the trick!
After a fresh install of Domoticz version Domoticz 2020.2 (build 12067) dzVents is default disabled....
Don't ask me why...

After enabling, all the scripts are working perfect again.

Thanks for your time. :D
Attachments
Screen Shot 2020-05-30 at 20.51.05.png
Screen Shot 2020-05-30 at 20.51.05.png (50.36 KiB) Viewed 1418 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest