Get value from sensor Sun Power  [Solved]

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

Moderator: leecollings

Post Reply
kroonp
Posts: 43
Joined: Friday 17 July 2020 11:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Get value from sensor Sun Power

Post by kroonp »

Hello, i'm new in this forum.
I am can't this script not working. Please help

My device:
Buienradar Son 00000201 1 Sun Power General Custom Sensor 435 watt/m2


My script

Code: Select all

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

        sensor = { 'Sun Power'}
    },

        execute = function(domoticz, sensor)
          if (domoticz.sensor('Sun Power').kWh > 220) then
            domoticz.devices('Keuken').switchOn()
            domoticz.log('Hey! I am ON sunpower!')
          else
            domoticz.devices('Naast tv').switchOff()
         
            domoticz.log('Hey! I am off sunpower!')
          end
        end
}
What is wrong in the script.
Thanks in advance
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Get value from sensor Sun Power

Post by waaren »

kroonp wrote: Friday 17 July 2020 11:09 I am can't this script not working. Please help
Can you try this?

Code: Select all

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

    logging =
    {
        level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is OK
        marker = 'Sun power',
    },

    execute = function(domoticz)
        local sunPower = tonumber(domoticz.devices('Sun Power').state)
        
        if sunPower > 220 then
            domoticz.devices('Keuken').switchOn()
            domoticz.log('Hey! I am ON sunpower!', domoticz.LOG_DEBUG)
        else
            domoticz.devices('Naast tv').switchOff()
            domoticz.log('Hey! I am off sunpower!', domoticz.LOG_DEBUG)
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
kroonp
Posts: 43
Joined: Friday 17 July 2020 11:03
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Get value from sensor Sun Power  [Solved]

Post by kroonp »

Yes, this what I want. Thankx very much!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest