S0 device issues

Moderator: leecollings

Post Reply
HvdW
Posts: 612
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

S0 device issues

Post by HvdW »

rron wrote: Saturday 08 February 2025 13:35 There is some progress when I use your call. Only "Vandaag"is giving a value but not on top. Have I forgotten something?
Here is a test script you can use.
It gets the data from this S0 Pulse Meter.
I tried it at first with a 'normal'script.

Code: Select all

return {
	on = {
		devices = {'YourSwitch'},
		timer = {},
		variables = {},
		scenes = {},
		groups = {},
		security = {},
		httpResponses = {},
		shellCommandResponses = {},
		customEvents = {},
		system = {},
	},
	data = {
	    whToday = { initial = nil },
	    whTotal = { initial = nil },
	    },
	logging = {},
	execute = function(domoticz, triggeredItem)
        domoticz.devices('Laadpaal').dump()
        domoticz.data.whTotal = domoticz.devices('Laadpaal').whTotal -- 3108061.75
        domoticz.data.whToday = domoticz.devices('Laadpaal').whToday
        domoticz.log("domoticz.data.whTotal" .. domoticz.data.whTotal, domoticz.LOG_INFO)
        domoticz.log("domoticz.data.whToday" .. domoticz.data.whToday, domoticz.LOG_INFO)
	end
}
This script returned NIL values.
Using a json call you will receive the data you want to receive.

Code: Select all

return {
    on = {
        devices = {'YourSwitch'},
        timer = {},
        variables = {},
        scenes = {},
        groups = {},
        security = {},
        httpResponses = {'LaadpaalData'}, -- Voeg een HTTP-response handler toe
        shellCommandResponses = {},
        customEvents = {},
        system = {},
    },
    data = {
        whToday = { initial = nil },
        whTotal = { initial = nil },
    },
    logging = {
        level = domoticz.LOG_DEBUG, -- Zet logging op DEBUG voor meer details
        marker = "Laadpaaltest",
    },
    execute = function(domoticz, triggeredItem)
        -- Controleer of de trigger een HTTP-response is
        if triggeredItem.isHTTPResponse then
            -- Log de volledige JSON-response voor debugging
            domoticz.log("Volledige JSON-response: " .. triggeredItem.data, domoticz.LOG_DEBUG)

            -- Verwerk de JSON-response
            local json = triggeredItem.json
            if json and json.result and json.result[1] then
                -- Haal de waarden uit Data en CounterToday
                local data = json.result[1].Data -- Bijvoorbeeld "3108.063 kWh"
                local counterToday = json.result[1].CounterToday -- Bijvoorbeeld "3.882 kWh"

                -- Verwijder de eenheid "kWh" en converteer naar een getal
                domoticz.data.whTotal = tonumber(data:match("%d+%.%d+")) -- Haal alleen het numerieke deel
                domoticz.data.whToday = tonumber(counterToday:match("%d+%.%d+")) -- Haal alleen het numerieke deel

                -- Log de waarden
                domoticz.log("domoticz.data.whTotal: " .. tostring(domoticz.data.whTotal), domoticz.LOG_INFO)
                domoticz.log("domoticz.data.whToday: " .. tostring(domoticz.data.whToday), domoticz.LOG_INFO)
            else
                domoticz.log("Geen geldige JSON-response ontvangen", domoticz.LOG_ERROR)
            end
        else
            -- Als de trigger een apparaat is, stuur dan een JSON-call
            domoticz.openURL({
                url = 'http://192.168.2.100:8383/json.htm?type=devices&rid=2457',
                method = 'GET',
                callback = 'LaadpaalData', -- Gebruik dezelfde naam als de HTTP-response handler
            })
            domoticz.log("JSON-call gestuurd om Laadpaal-gegevens op te halen", domoticz.LOG_INFO)
        end
    end
}
Hope this helps.

BTW
For testing purposes I use a switch device 'YourSwitch' to trigger a script. I used to use 'every 1 minutes' as a trigger but like the switch trigger better.
Bugs bug me.
Kedi
Posts: 575
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Energy Dashboard (Build in)

Post by Kedi »

@HvdW What does this 'stripped' script return?

Code: Select all

return {
	on = {
		devices = {'YourSwitch'},
		},
	execute = function(dz, Item)
	        dz.log("whTotal " .. dz.devices('Laadpaal').whTotal, dz.LOG_INFO)
        	dz.log("whToday " .. dz.devices('Laadpaal').whToday, dz.LOG_INFO)
	end
}
Logic will get you from A to B. Imagination will take you everywhere.
HvdW
Posts: 612
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

S0 meter

Post by HvdW »

Here you go:

Code: Select all

2025-02-22 10:59:32.684 dzVents: Handling events for: "YourSwitch", value: "On"
2025-02-22 10:59:32.684 dzVents: -------- YOUR TEST SCRIPT --------: ------ Start internal script: Your Test Script: Device: "YourSwitch (Dummy)", Index: 599
2025-02-22 10:59:32.686 dzVents: Debug: -------- YOUR TEST SCRIPT --------: Processing device-adapter for Laadpaal: kWh device adapter
2025-02-22 10:59:32.687 Error: dzVents: -------- YOUR TEST SCRIPT --------: An error occurred when calling event handler Your Test Script
2025-02-22 10:59:32.687 Error: dzVents: -------- YOUR TEST SCRIPT --------: ...z/scripts/dzVents/generated_scripts/Your Test Script.lua:29: attempt to concatenate a nil value (field 'whTotal')
2025-02-22 10:59:32.687 dzVents: -------- YOUR TEST SCRIPT --------: ------ Finished Your Test Script
The json call I showed before returns these values.

Code: Select all

2025-02-22 11:02:06.577 dzVents: Laadpaaltest: domoticz.data.whTotal: 3140.213
2025-02-22 11:02:06.577 dzVents: Laadpaaltest: domoticz.data.whToday: 11.976
2025-02-22 11:02:06.578 dzVents: Laadpaaltest: ------ Finished Your Test Script
I have been struggling quite some time wirh this S0 device.
Another observation was that after switching the 'Laadpaal' (Charging Pole/Charging Point) the displayed values in the domoticz sensor changed over a time span of more than a minute from (example) 3500 W to 0 W.
I can imagine that the on-board charger (OBC) doesn't switch off at once, but more than a minute?

My thoughts: The S0 device does fill values in a sensor and an dump() gives values, so why do I receive why these nil values, using value = domoticz.devices('Laadpaal').whTotal?

In the end the step to json resolved the problem.

Still: HOW COME ?!

Sorry for posting this in the Energy Dashboard (Built-in).
Maybe some posts should be placed in an item like S0 meters.
Last edited by HvdW on Saturday 22 February 2025 18:16, edited 1 time in total.
Bugs bug me.
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: S0 device issues

Post by waltervl »

Splitted of the energy dashboard topic.
Not clear for me what the issue with the S0 device is.
When going to the website I read in the comments there is a new firmware that fixes some issues:
https://www.sossolutions.nl/5-kanaals-s ... ter-op-usb

https://www.smartmeterdashboard.nl/blog ... eschikbaar
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5853
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: S0 device issues

Post by waltervl »

What line is giving nil values? The one of persistent data value or the one from the device itself?
The log you showed cannot be the log from the simple script of @Kedi as that has only 9 lines and your log gives an error on line 29.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest