Solax data

Moderator: leecollings

Post Reply
hnogueira
Posts: 25
Joined: Saturday 28 November 2015 12:10
Target OS: Windows
Domoticz version:
Contact:

Solax data

Post 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
hnogueira
Posts: 25
Joined: Saturday 28 November 2015 12:10
Target OS: Windows
Domoticz version:
Contact:

Re: Solax data

Post 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
}
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Solax data

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
masselb
Posts: 24
Joined: Friday 06 September 2019 11:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Solax data

Post 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
User avatar
waltervl
Posts: 5846
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Solax data

Post by waltervl »

Did you check the solax plugin viewtopic.php?t=33872
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
hnogueira
Posts: 25
Joined: Saturday 28 November 2015 12:10
Target OS: Windows
Domoticz version:
Contact:

Re: Solax data

Post 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
}
}
hnogueira
Posts: 25
Joined: Saturday 28 November 2015 12:10
Target OS: Windows
Domoticz version:
Contact:

Re: Solax data

Post by hnogueira »

@waltervl, I did and could manage to make it work
hnogueira
Posts: 25
Joined: Saturday 28 November 2015 12:10
Target OS: Windows
Domoticz version:
Contact:

Re: Solax data

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest