i build a cheap Ahoy Dtu (13€) which is able to communicate with all Hoymiles HM-xxx PV microinverters.
Ahoy allows to interact with Mqtt and Rest Api standards. There is a documentation at the Ahoy Dtu project page online.
I made a LUA script to read the PV output power: (This is only a demo - feel free to add other data provided by the api)
Code: Select all
--Anlage des virtuellen Sensors Hoymiles: im Browser ausführen
--http://10.0.0.142:8080/json.htm?type=createvirtualsensor&idx=4&sensorname=HOYMILES&sensortype=248
JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
commandArray = {}
jsondata = assert(io.popen('curl "http://10.0.0.156/api/live"'))
device = jsondata:read('*all')
jsondata:close()
--data = JSON:decode(device).inverter[1].name
--print('Devicename ' .. data)
data = JSON:decode(device)
--print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1].ch[1][3])
if (data ~= nil) then
commandArray[1] = {['UpdateDevice'] = 141 .. "|0|" ..tonumber(data.inverter[1].ch[1][3])}
else
commandArray[1] = {['UpdateDevice'] = 141 .. "|0|" .. 0 }
end
return commandArray
A second project on i work is to build a PV storrage batterie with lifepo4 cells and a second Hoymiles microinverter. The Hoymiles microinverter can sent a power limit. So, if my house will consume 50 Watt at night, the Hoymiles gets a xml message to produce only 50 Watt from the 48V 5kWh batteries.
Batteries will be charged by a charger at day from PV.
This DzVents script is also a sample to set the power limit of inverter 0:
Code: Select all
return
{
on =
{
timer = { 'between 10 minutes before sunset and 10 minutes after sunrise' }
},
execute = function(dz)
local Amis = dz.variables('AMIS').value
local HoymilesPower = dz.variables('HoymilesPower').value
local Power = 0
if Amis > 0 then
Power = dz.utils.round (tonumber(HoymilesPower) + (tonumber(Amis) * 0.9),0)
else
Power = dz.utils.round (tonumber(HoymilesPower) - (tonumber(Amis) * -1.1),0)
end
dz.variables('HoymilesPower').set(tostring(Power))
print ('Hoymiles Power set to: '..tostring(Power))
dz.openURL(
{
url = 'http://10.0.0.156/api/ctrl',
method = 'POST',
headers = { ['Content-type'] = 'application/json' },
postData = '{"id":0,"cmd":"limit_nonpersistent_absolute","val":' .. tostring(Power) ..'}',
})
end
}
Amis is the Smartmeter value.
Gerhard