Page 1 of 1

Little script help please?

Posted: Tuesday 01 December 2020 17:18
by theolsen
Hi all,

I am a complete noob to dzVents and am not a coder by any stretch of the imagination.

I am looking for a way of scripting the following:

Check a dummy device once every minute and if the text does not equal "whatever" then turn off a smart plug.


Any help would be very much appreciated.

Thanks.

Re: Little script help please?

Posted: Tuesday 01 December 2020 17:56
by waaren
theolsen wrote: Tuesday 01 December 2020 17:18 I am looking for a way of scripting the following: Check a dummy device once every minute and if the text does not equal "whatever" then turn off a smart plug.
could look like below example
__________________________________________________________________________________________________________________________
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 =
    {
        timer =
        {
            'every minute',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK to surpress log entries
        marker = 'Whatever',
    },

    execute = function(dz)
        local text = dz.devices('name of your text device').text -- Change between quotes (must be text device)
        local smartPlug = dz.devices('name of you Smartplug') -- Change between quotes (must be a switch type device)

        if text ~= 'whatever' then
            smartPlug.switchOff()
        end
    end
}

Re: Little script help please?  [Solved]

Posted: Tuesday 01 December 2020 18:00
by theolsen
Hey, thanks a million @waaren. And thanks for the link to Get Started.

Much appreciated.