Page 1 of 1

Solax data

Posted: Wednesday 08 March 2023 1:14
by hnogueira
Hi all:

some users have been looking (as myself) for a way to get Solax data into Domoticz. there's some plugins, but also a easy way via Dzvents.
bellow code I use.

Helder Nogueira

Re: Solax data

Posted: Wednesday 08 March 2023 1:14
by hnogueira
-- Script to retrieve real-time data from a Solax solar inverter and update a Domoticz device

return {
-- Define triggers for the script
on = {
timer = { 'every 2 minutes' },
httpResponses = { 'trigger' }
},

-- Configure logging settings
logging = {
level = domoticz.LOG_INFO,
marker = 'solar-inverter'
},

-- Define the main function of the script
execute = function(domoticz, item)
-- Handle the timer trigger
if item.isTimer then
domoticz.openURL({
url = 'https://www.solaxcloud.com/proxyApp/pro ... xdfgdstgzg',
method = 'GET',
callback = 'trigger'
})
end

-- Handle the HTTP response trigger
if item.isHTTPResponse then
-- Check if the response was successful
if item.ok then
-- Check if the response is in JSON format
if item.isJSON then
-- Extract the relevant data from the response
local inverterData = item.json.result

if inverterData == nil then
-- Log a message indicating failure
domoticz.log('Problemas de comunicação')
domoticz.log(item)
else
-- Update the Domoticz device with the retrieved data
local device = domoticz.devices('Uso Baterias')
device.updateEnergy(inverterData.batPower)
local device = domoticz.devices('Carga baterias')
device.updateText(inverterData.soc.." %")
local device = domoticz.devices('Consumo Casa')
device.updateElectricity(inverterData.acpower)

-- Log a message indicating success
domoticz.log('Data updated successfully', domoticz.LOG_INFO)
end
end
end
end
end
}

Re: Solax data

Posted: Wednesday 08 March 2023 20:21
by waltervl
Thanks, but please edit your post and put your script in code brackets. That makes it much more readable and easier to copy.

Re: Solax data

Posted: Tuesday 14 March 2023 16:48
by masselb
Hey hnogueira,

Thanks for that, I am looking to get solax data in domoticz as well without any exotic stuff which needs config and hours... Question is, when I copy the script I have one device from one Inverter correct? Would it be possible to adjust the script to pull let's say 5 or 6 values from 2 or 3 Inverters? Also, I think the Cloud does not deliver values every 2 mins, one would need to read the data from LAN?

thx,
Bert

Re: Solax data

Posted: Tuesday 14 March 2023 16:53
by waltervl
Did you check the solax plugin viewtopic.php?t=33872

Re: Solax data

Posted: Tuesday 14 March 2023 20:15
by hnogueira

Code: Select all

{-- Script to retrieve real-time data from a Solax solar inverter and update a Domoticz device

return {
-- Define triggers for the script
on = {
timer = { 'every 2 minutes' },
httpResponses = { 'trigger' }
},

-- Configure logging settings
logging = {
level = domoticz.LOG_INFO,
marker = 'solar-inverter'
},

-- Define the main function of the script
execute = function(domoticz, item)
-- Handle the timer trigger
if item.isTimer then
domoticz.openURL({
url = 'https://www.solaxcloud.com/proxyApp/pro ... xdfgdstgzg',
method = 'GET',
callback = 'trigger'
})
end

-- Handle the HTTP response trigger
if item.isHTTPResponse then
-- Check if the response was successful
if item.ok then
-- Check if the response is in JSON format
if item.isJSON then
-- Extract the relevant data from the response
local inverterData = item.json.result

if inverterData == nil then
-- Log a message indicating failure
domoticz.log('Problemas de comunicação')
domoticz.log(item)
else
-- Update the Domoticz device with the retrieved data
local device = domoticz.devices('Uso Baterias')
device.updateEnergy(inverterData.batPower)
local device = domoticz.devices('Carga baterias')
device.updateText(inverterData.soc.." %")
local device = domoticz.devices('Consumo Casa')
device.updateElectricity(inverterData.acpower)

-- Log a message indicating success
domoticz.log('Data updated successfully', domoticz.LOG_INFO)
end
end
end
end
end
}
}

Re: Solax data

Posted: Tuesday 14 March 2023 20:16
by hnogueira
@waltervl, I did and could manage to make it work

Re: Solax data

Posted: Tuesday 14 March 2023 20:17
by hnogueira
waltervl wrote: Tuesday 14 March 2023 16:53 Did you check the solax plugin viewtopic.php?t=33872
yes, could make it to work