Negative Value Smart meter P1

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

Moderator: leecollings

Post Reply
Johan1974
Posts: 37
Joined: Monday 04 December 2017 20:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Negative Value Smart meter P1

Post by Johan1974 »

Hello,
I want to switch a relay when more power is generated than 900 watts and it switches off again when 200 watts are supplied back.

It works with positive numbers, but not with negative ones (Smart meter)

Code: Select all

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


    execute = function(domoticz,state)
        local Relais                          = domoticz.devices (2157) -- Relais
        local SlimmeMeter               = domoticz.devices (22) -- Slimme meter
                     
        
                if (Relais.state == 'Off' and SlimmeMeter.actualWatt < -900 ) then 
                Relais.switchOn()
            end
            
                if (Relais.state == 'On' and SlimmeMeter.actualWatt > -200 ) then
                Relais.switchOff()
            end
        
        
         
        
    end
}
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Negative Value Smart meter P1

Post by waltervl »

Try to log the values so you are sure you are getting the values from Domoticz you are expecting. What you see on the screen is not always what dzvents is reporting.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
willemd
Posts: 649
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Negative Value Smart meter P1

Post by willemd »

In the code shown it will switch ON when actualWatt for example -1000, -1100, -1200 etc. and switch OFF when for example -100,0, 100 etc.

Is that what you want?

Should the second statement maybe be "> 200" instead of "> -200" ?

Check you number signs and the > and < operators.
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Negative Value Smart meter P1

Post by waltervl »

No, what I mean is add log statements in you script to show in the log what dzvents is doing eg add the following line just below
local SlimmeMeter = domoticz.devices (22) -- Slimme meter

Code: Select all

domoticz.log('SlimmeMeter.actualWatt = ' .. SlimmeMeter.actualWatt, domoticz.LOG_INFO)
In the domoticz log file this log statement should be shown and then you see what dzvents is reading. Then you can check what value to switch on.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
HvdW
Posts: 612
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: Negative Value Smart meter P1

Post by HvdW »

Make it LOG_DEBUG, set logging to LOG_DEBUG and when you are satisfied later on set logging to LOG_ERROR.
Bugs bug me.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests