Can't get a value, all others work.

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

Moderator: leecollings

Post Reply
Eternity
Posts: 63
Joined: Saturday 06 December 2014 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Can't get a value, all others work.

Post by Eternity »

I am trying to get the electricity stats from my smart meter.
This script is used as a test to get the values I am looking for:

Code: Select all

return {
      on = { 
        timer = {
           'every 1 minutes'            
        },
    }, 
    execute = function(domoticz, device, timer)
        
-- Get current values of devices
        local vandaagKwhIn          = domoticz.devices('Elektra').counterToday
        local vandaagkKwUit         = domoticz.devices('Elektra').counterDelivToday        



-- Check what values are loaded
        domoticz.log("vandaagKwhIn: " ..   tostring(vandaagKwhIn))
        domoticz.log("vandaagkKwhUit: " .. tostring(vandaagkKwhUit))

       
    end
} 
This is the output:

Code: Select all

2023-04-06 13:27:56.981 Status: [web:8080] Incoming connection from: 192.168.50.35
2023-04-06 13:28:00.103 Status: dzVents: Info: ------ Start internal script: Test:, trigger: "every 1 minutes"
2023-04-06 13:28:00.110 Status: dzVents: Info: vandaagKwhIn: 3.977
2023-04-06 13:28:00.111 Status: dzVents: Info: vandaagkKwhUit: nil
2023-04-06 13:28:00.111 Status: dzVents: Info: ------ Finished Test
One value insists to stay 'nil' but it is not zero, it is 1.024 kWh as can be seen in the device:

Code: Select all

			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "29305.791",
			"CounterDeliv" : "5122.711",
			"CounterDelivToday" : "1.024 kWh",
			"CounterToday" : "3.977 kWh",
			"CustomImage" : 0,
			"Data" : "14536769;14769022;1647808;3474903;0;227",
			"Description" : "",
			"Favorite" : 1,
I also tried it with the devise ID's, but that gives the same 'nil'.
What am I doing wrong?
How do I get that "CounterDelivToday" value?

Thanks!
Last edited by Eternity on Thursday 06 April 2023 16:14, edited 1 time in total.
Synology DS218+
Homey controller
Z-Wave stuff (Fibaro / Aeotec / NEO Coolcam)
Zigbee stuff (Aqara)
HUE lights
Logitech Harmony Ultimate + Hub
IP camera's
willemd
Posts: 631
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Can't get a value, all others work.

Post by willemd »

you assign to vandaagkKwUit, but print in the log vandaagkKwhUit, so this is not the same, there is an extra h in the name
Eternity
Posts: 63
Joined: Saturday 06 December 2014 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Can't get a value, all others work.

Post by Eternity »

Thanks for the reply!

I changed the code to:

Code: Select all

return {
      on = { 
        timer = {
           'every 1 minutes'            
        },
    }, 
    execute = function(domoticz, device, timer)
        
-- Get current values of devices
        local test1 = domoticz.devices('Elektra').counterToday
        local test2 = domoticz.devices('Elektra').counterDelivToday
        
-- Check what values are loaded
        domoticz.log("test1: " ..   tostring(test1))
        domoticz.log("test2: " ..   tostring(test2))
       
    end
} 
but the result is still a 'nil' value:

Code: Select all

2023-04-06 16:15:00.223 Status: dzVents: Info: ------ Start internal script: Test:, trigger: "every 1 minutes"
2023-04-06 16:15:00.232 Status: dzVents: Info: test1: 4.456
2023-04-06 16:15:00.232 Status: dzVents: Info: test2: nil
2023-04-06 16:15:00.232 Status: dzVents: Info: ------ Finished Test
Synology DS218+
Homey controller
Z-Wave stuff (Fibaro / Aeotec / NEO Coolcam)
Zigbee stuff (Aqara)
HUE lights
Logitech Harmony Ultimate + Hub
IP camera's
Kedi
Posts: 569
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Can't get a value, all others work.

Post by Kedi »

It is "counterDeliveredToday"
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
boum
Posts: 135
Joined: Friday 18 January 2019 11:31
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: Can't get a value, all others work.

Post by boum »

Eternity
Posts: 63
Joined: Saturday 06 December 2014 16:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Can't get a value, all others work.

Post by Eternity »

Thats it!

I set it to "counterDeliveredToday"

And that gives the value.

Code: Select all

2023-04-06 17:57:00.246 Status: dzVents: Info: ------ Start internal script: Test:, trigger: "every 1 minutes"
2023-04-06 17:57:00.255 Status: dzVents: Info: test1: 5.84
2023-04-06 17:57:00.255 Status: dzVents: Info: test2: 1.085
2023-04-06 17:57:00.255 Status: dzVents: Info: ------ Finished Test
THANKS FOR THE HELP!
Synology DS218+
Homey controller
Z-Wave stuff (Fibaro / Aeotec / NEO Coolcam)
Zigbee stuff (Aqara)
HUE lights
Logitech Harmony Ultimate + Hub
IP camera's
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests