Page 1 of 1

Get value from sensor Sun Power

Posted: Friday 17 July 2020 11:09
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

Re: Get value from sensor Sun Power

Posted: Friday 17 July 2020 11:41
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
}

Re: Get value from sensor Sun Power  [Solved]

Posted: Friday 17 July 2020 16:57
by kroonp
Yes, this what I want. Thankx very much!