Ahoy Dtu and Hoymiles HM-xxx integration

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
User avatar
mgerhard74
Posts: 40
Joined: Friday 28 July 2017 18:28
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Austria, Upperaustria
Contact:

Ahoy Dtu and Hoymiles HM-xxx integration

Post by mgerhard74 »

Hello,
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
hymiles_domo.png
hymiles_domo.png (32.63 KiB) Viewed 6007 times

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
}
Any ideas to run this script more than every minute? Maybe in LUA?
Amis is the Smartmeter value.

Gerhard
Domoticz improves my photovoltaik ownconsumption (Rpi3, wifi plugs) - PV 6,5kWp (Fronius Symo inverter) - 10kWh PV batterie - Nissan Leaf2 (40kWh) and Kia eNiro (64kWh)
belzig
Posts: 11
Joined: Saturday 23 April 2022 22:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by belzig »

infinite loop with

os.execute("sleep 15")

But im not sure, if it realy makes sense:

AHOY-DTU sends commands instantly to the inverter, but the inverter only accepts commands within 30 sec to 90 sec.
Every command is fire and forget.
If the smartmeter`s sampling rate is higher than 30 sec than this rate is the lower limit.

A lower inverval then 60 sec is probably completely useless
belzig
Posts: 11
Joined: Saturday 23 April 2022 22:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by belzig »

I wrote a shell-script to read my fronius-inverter`s datalogger.
The script reads the power values and then sends the delta to my hm-300 to compensate the base load in the night.
hm-300 is connected to an 25,6 V battery.

prerequisites:
- Deep-Standy of Fronius-inverter has to be disabled ( Settings -> Fronius Solar WEB -> Logging during nighttime enabled)
- mqtt (mosquitto) has to be configured.
- HM-300 is not switched on or off by the script, you have to do this by
on:

Code: Select all

/usr/bin/mosquitto_pub  -t "inverter/ctrl/power/0" -m "1"
off:

Code: Select all

/usr/bin/mosquitto_pub  -t "inverter/ctrl/power/0" -m "0"

The script is an endless loop which can run stand-alone without domoticz, but it also can be integrated to domoticz-init script by
placing it as

Code: Select all

/home/pi/domoticz/script/smphm3.sh
and adding

Code: Select all

nohup /home/pi/domoticz/script/smphm3.sh > /var/log/smph3.log 2>&1
to

Code: Select all

 /etc/init.d/domoticz.sh
Domotics can start the loop in dzventscripts by

Code: Select all

os.execute("/usr/bin/touch /tmp/smphm3_unlock")
and pause the loop by.

Code: Select all

os.execute("/usr/bin/rm /tmp/smphm3_unlock")
Perhaps someone might find it usefull.

Code: Select all

#!/bin/bash
Limit=100
MLimit=0
LastRun=0
MaxPower=215
LastLimit=100
ldct=0
LimitAgg=0
Fronius_IP=1.2.3.4

DATUM=$(date +%d.%m.%y" "%H:%M:%S)
Lock=/tmp/smphm3_unlock 
/usr/bin/mosquitto_pub  -t inverter/ctrl/limit_nonpersistent_absolute/0 -m $Limit
echo "$DATUM /usr/bin/mosquitto_pub  -t inverter/ctrl/limit_nonpersistent_absolute/0 -m $Limit"

while true ; do
DATUM=$(date +%d.%m.%y" "%H:%M:%S)
	
 while [ -e $Lock ] ; do
DATUM=$(date +%d.%m.%y" "%H:%M:%S)


lSMpower=$(/usr/bin/curl -s --connect-timeout 1 "http://$Fronius_IP/solar_api/v1/GetMeterRealtimeData.cgi?Scope=Device&DeviceId=0&DataCollection=CommonInverterData" |grep PowerReal_P_Sum |awk -F ":" '{ print $2 }'|awk -F "," '{ print $1 }' |awk -F "." '{ print $1 }')

lSMPower=$((lSMpower))

Limit=$(($LastLimit+$lSMpower-2))

	if [ $Limit -ge $MaxPower ]
	then
	 Limit=$MaxPower
	fi

	if [ $Limit -lt 10  ]
	then
		Limit=10
        fi	

limitdiff=$(($Limit-$LastLimit))
powerdiff=$(($lSMPower-$LastRun))

     LimitAgg=$(($LimitAgg+$Limit)) 
     ldct=$(($ldct+1))
     MLimit=$(($LimitAgg/$ldct))
    
  if [ $LastLimit -eq 215 -a $Limit -ne 215 ]
    then
	    Limit=$((($Limit+$MLimit+10)/2))
 fi	   


    echo "$DATUM P:$lSMPower L:$Limit LD:$limitdiff PD:$powerdiff LDct:$ldct LAg:$LimitAgg ML:$MLimit"

if [ $limitdiff -ge 5 -o $limitdiff -le -5   ]
then

 if [   $powerdiff -ge 20 -o $powerdiff -le -10  ]
  then
	#echo "Powerdiff" $powerdiff
	
	       	echo "/usr/bin/mosquitto_pub  -t inverter/ctrl/limit_nonpersistent_absolute/0 -m $Limit"
		/usr/bin/mosquitto_pub  -t inverter/ctrl/limit_nonpersistent_absolute/0 -m $Limit
		
		LimitAgg=0
		ldct=0
	
  LastLimit=$((Limit))
  LastRun=$((lSMpower))

  else 
     echo "powerdiff low" $powerdiff
  fi

else
    echo "Limitdiff low" $limitdiff
fi
   
   
 if [ $ldct -ge 10 ]
    	then
	if [ $lSMPower -ge 20 -o $lSMPower -lt 0 ]
	   then

		Limit=$(($LimitAgg/$ldct))
		 echo "/usr/bin/mosquitto_pub  -t inverter/ctrl/limit_nonpersistent_absolute/0 -m $Limit"
		/usr/bin/mosquitto_pub  -t inverter/ctrl/limit_nonpersistent_absolute/0 -m $Limit
		LimitAgg=0
		ldct=0
		LastLimit=$Limit
	fi
 fi    
 sleep 10
 done
 echo "$DATUM smphm3 locked. Please set $Lock"
 sleep 120
done


ld56
Posts: 2
Joined: Saturday 22 April 2023 18:42
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by ld56 »

Hi! This was exactly was I had in mind for months :)
I've bought a HM-350 and I'm starting to play with it and a small battery which I will upgrade later.
I currently have a few problems with AhoyDTU and setting the power limit in the HM-350.

Is this kind of power limit works really well? Do you have a least 10w precision in the setting?
This power limit is great because I would not need a current limiter between the battery and the HM :)
ld56
Posts: 2
Joined: Saturday 22 April 2023 18:42
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by ld56 »

I've started to describe my full solar energy storage in this blog post, google this: DIY Solar battery storage and night injection (or check the link in profile)
User avatar
SESTH
Posts: 5
Joined: Saturday 12 November 2016 23:23
Target OS: Raspberry Pi / ODroid
Domoticz version: V2023.1
Location: Germany
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by SESTH »

Thanks, that was exactly what I needed. I had to update the script for the current AhoyDTU © 2023, GIT SHA: 15ec6a0 :: 0.6.9.

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 = assert(loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()    -- For Linux
   
commandArray = {}
    jsondata    = assert(io.popen('curl "http://mh-solar-01/api/record/live"'))
    device = jsondata:read('*all')
    jsondata:close()
    --data = JSON:decode(device).inverter[1].name
    --print('Devicename ' .. data)
    
    data = JSON:decode(device)
    --print(JSON:encode_pretty(data.inverter[1][15]))
    print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][15].val)
    
    if (data ~= nil) then
        commandArray[1] = {['UpdateDevice'] = 218 .. "|0|" ..tonumber(data.inverter[1][15].val)}
    else
        commandArray[1] = {['UpdateDevice'] = 218 .. "|0|" .. 0 }
    end
return commandArray
Regards, Thomas
Raspberry Pi 3B + 4, RFXtrx433
Banana Pi M1, RFLink
User avatar
oeildefeu
Posts: 8
Joined: Saturday 28 December 2013 15:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: France
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by oeildefeu »

Hello,
based on your script I updated them to fit my expectations :) thanks to you !
It follow the temperature of the onduler, the production and power.

Code: Select all

JSON = assert(loadfile "scripts/lua/JSON.lua")()
   
commandArray = {}
    local url_AhoyDTU = "http://192.168.0.70/api/record/live"
    local idx_temp = 827
    local idx_counter = 828
    local power = 0
    local Energy = 0
    local debug = false
    
    jsondata    = assert(io.popen('curl "'..url_AhoyDTU..'"'))
    device = jsondata:read('*all')
    jsondata:close()
    data = JSON:decode(device)
    if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][15].val) end
    power = tonumber(data.inverter[1][15].val)
    if debug then print ('Hoymiles Inverter 0 [Temp Celcius]: ' .. data.inverter[1][19].val) end
    temperature = tonumber(data.inverter[1][19].val)
    if debug then print ('Hoymiles Inverter 0 [Energy_total kWh]: ' .. data.inverter[1][22].val) end
    Energy = tonumber(data.inverter[1][22].val)*1000
    if (power ~= nil and Energy > 0) then
        commandArray[2] = {['UpdateDevice'] = idx_temp .. '|0|' .. temperature}
        commandArray[3] = {['UpdateDevice'] = idx_counter .. "|0|" .. power .. ";" .. Energy}
    else
        commandArray[1] = {['UpdateDevice'] = idx_counter .. "|0|" .. 0 }
    end
return commandArray
Raspberry Pi 3 - Raspbian + Razberry (OpenZwave) + RFXtrx433
belzig
Posts: 11
Joined: Saturday 23 April 2022 22:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by belzig »

New version of the script for 2 HM-300, with new syntax for AHOY-DTU 0.6.9

Code: Select all

#!/bin/bash
Limit=215
MLimit=0
LastRun=0
MaxPower=215
LastLimit=231
ldct=0
LimitAgg=0
Fronius_IP=1.2.3.4
INo=0
DATUM=$(date +%d.%m.%y" "%H:%M:%S)
Lock=/tmp/smphm3_unlock
RealMPow=231
/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/$INo -m $Limit"W"
echo "$DATUM /usr/bin/mosquitto_pub  -t inverter/ctrl/limit/$INo -m ${Limit}W"
sleep 5
INo=1
/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/$INo -m $Limit"W"
echo "$DATUM /usr/bin/mosquitto_pub  -t inverter/ctrl/limit/$INo -m ${Limit}W"
sleep 5

while true ; do
DATUM=$(date +%d.%m.%y" "%H:%M:%S)
 while [ -e $Lock ] ; do
 sleep 10
	 DATUM=$(date +%d.%m.%y" "%H:%M:%S)

#/usr/bin/curl -s --connect-timeout 1 "http://192.168.102.80/cm?cmnd=status%208" |awk -F"," '{ print $6}' |awk -F": " '{ print $2 }'

#cat  /tmp/smartmeter.out |grep PowerReal_P_Sum |awk -F ":" '{ print $2 }'|awk -F "," '{ print $1 }' |awk -F "." '{ print $1 }'

lSMpower=$(/usr/bin/curl -s --connect-timeout 1 "http://$Fronius_IP/solar_api/v1/GetMeterRealtimeData.cgi?Scope=Device&DeviceId=0&DataCollection=CommonInverterData" |grep PowerReal_P_Sum |awk -F ":" '{ print $2 }'|awk -F "," '{ print $1 }' |awk -F "." '{ print $1 }')
#lSMpower=$(expr lSMpower)

#echo "Cons" $lSMpower
lSMPower=$((lSMpower))

Limit=$(((($LastLimit+$LastLimit+$lSMpower-4)/2)))
#Limit=$((($Limit+LastLimit)
	if [ $Limit -ge $MaxPower ]
	then
	 Limit=$MaxPower
	fi

	if [ $Limit -lt 10 ]
	then
		Limit=10
        fi	
if [ $LastLimit -eq $RealMPow ]
	then
  	   LastLimit=$MaxPower
fi  

limitdiff=$(($Limit-$LastLimit))
powerdiff=$(($lSMPower-$LastRun))

     LimitAgg=$(($LimitAgg+$Limit)) 
     ldct=$(($ldct+1))
     MLimit=$(($LimitAgg/$ldct))
    
  if [ $LastLimit -eq $MaxPower -a $Limit -ne $MaxPower ]
    then
	    Limit=$((($Limit+$MLimit+10)/2))
 fi	   


    echo "$DATUM P:$lSMPower L:$Limit LD:$limitdiff PD:$powerdiff LDct:$ldct LAg:$LimitAgg ML:$MLimit"
#power=$(($power+1))
if [ $limitdiff -ge 5 -o $limitdiff -le -5   ]
then

 if [   $powerdiff -ge 20 -o $powerdiff -le -10  ]
  then
	#echo "Powerdiff" $powerdiff
	
		echo "/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/0 -m $Limit W  "
		/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/0 -m $Limit"W"
                sleep 5	       	
		echo "/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/1 -m $Limit W  "
		/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/1 -m $Limit"W"
		
		LimitAgg=0
		ldct=0
	
  #ldct=0
  LastLimit=$((Limit))
  LastRun=$((lSMpower))
  
	if [ $Limit -eq $MaxPower ]
	then
	 LastLimit=$RealMPow
	fi

  else 
     echo "powerdiff low" $powerdiff
  fi

else
    echo "Limitdiff low" $limitdiff
   ## ldct=$(($ldct+1))
fi
 # LastLimit=$((Limit))
 # LastRun=$((lSMpower))
#echo "P:$lSMPower L:$Limit LD:$limitdiff PD:$powerdiff LDct:$ldct"
   
   
 if [ $ldct -ge 10 ]
    	then
	if [ $lSMPower -ge 20 -o $lSMPower -lt 0 ]
	   then

		Limit=$(($LimitAgg/$ldct))
		echo "/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/0 -m $Limit W  "
		/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/0 -m $Limit"W"
		
		sleep 5
		echo "/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/1 -m $Limit W  "
		/usr/bin/mosquitto_pub  -t inverter/ctrl/limit/1 -m $Limit"W"
		LimitAgg=0
		LimitAgg=0
		ldct=0
		LastLimit=$Limit
    	#LastLimit=300
	fi
 fi    

 done
 echo "$DATUM smphm3 locked. Please set $Lock"
 LastLimit=231
 sleep 90 
done
C4coer
Posts: 8
Joined: Tuesday 27 March 2018 19:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by C4coer »

hello everyone,
it's perfect for me.
thank you for the share
C4coer
Posts: 8
Joined: Tuesday 27 March 2018 19:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by C4coer »

hello everbody
I would like to retrieve the current production of each panel and the yield, i.e. indexes 3, 9 and 24, but how to integrate them into the script:
JSON = assert(loadfile "scripts/lua/JSON.lua")()

commandArray = {}
local url_AhoyDTU = "http://192.168.0.74/api/record/live"
local idx_temp = 310
local idx_counter = 312
local power = 0
local Energy = 0
local debug = false

jsondata = assert(io.popen('curl "'..url_AhoyDTU..'"'))
device = jsondata:read('*all')
jsondata:close()
data = JSON:decode(device)
if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][15].val) end
power = tonumber(data.inverter[1][15].val)
if debug then print ('Hoymiles Inverter 0 [Temp Celcius]: ' .. data.inverter[1][19].val) end
temperature = tonumber(data.inverter[1][19].val)
if debug then print ('Hoymiles Inverter 0 [Energy_total kWh]: ' .. data.inverter[1][22].val) end
Energy = tonumber(data.inverter[1][22].val)*1000
if (power ~= nil and Energy > 0) then
commandArray[2] = {['UpdateDevice'] = idx_temp .. '|0|' .. temperature}
commandArray[3] = {['UpdateDevice'] = idx_counter .. "|0|" .. power .. ";" .. Energy}
else
commandArray[1] = {['UpdateDevice'] = idx_counter .. "|0|" .. 0 }
end
return commandArray


-------------
I created for example an additional counter, but the values ​​are mixed:
local idx_counter1 = 313

and

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][3].val) end
power = tonumber(data.inverter[1][3].val)

......
commandArray[1] = {['UpdateDevice'] = idx_counter .. "|0|" .. power .. ";" .. Energy}

thank you for your help
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by jvdz »

What isn't working yet with the posted script?
Can you share an example Json data so we can test/debug your script?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
C4coer
Posts: 8
Joined: Tuesday 27 March 2018 19:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by C4coer »

I think I found my mistake, what do you think?
if not for performance, I'll see.

------------------------------

JSON = assert(loadfile "scripts/lua/JSON.lua")()

commandArray = {}
local url_AhoyDTU = "http://192.168.0.74/api/record/live"
local idx_temp = 310
local idx_counter = 312
local idx_panel1 = 313
local idx_panel2 = 314
local power = 0
local Energy = 0
local debug = false

jsondata = assert(io.popen('curl "'..url_AhoyDTU..'"'))
device = jsondata:read('*all')
jsondata:close()
data = JSON:decode(device)

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][15].val) end
power = tonumber(data.inverter[1][15].val)

if debug then print ('Hoymiles Inverter 0 [Temp Celcius]: ' .. data.inverter[1][19].val) end
temperature = tonumber(data.inverter[1][19].val)

if debug then print ('Hoymiles Inverter 0 [Energy_total kWh]: ' .. data.inverter[1][22].val) end
Energy = tonumber(data.inverter[1][22].val) * 1000

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][3].val) end
power1 = tonumber(data.inverter[1][3].val)

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][9].val) end
power2 = tonumber(data.inverter[1][9].val)


if (power ~= nil and Energy > 0) then
commandArray[2] = {['UpdateDevice'] = idx_temp .. '|0|' .. temperature}
commandArray[3] = {['UpdateDevice'] = idx_counter .. "|0|" .. power .. ";" .. Energy}
commandArray[4] = {['UpdateDevice'] = idx_panel1 .. "|0|" .. power1 .. ";" .. Energy}
commandArray[5] = {['UpdateDevice'] = idx_panel2 .. '|0|' .. power2 .. ";" .. Energy}
else
commandArray[1] = {['UpdateDevice'] = idx_counter .. "|0|" .. 0}



end

return commandArray
C4coer
Posts: 8
Joined: Tuesday 27 March 2018 19:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by C4coer »

included the performance of the micro inverter

JSON = assert(loadfile "scripts/lua/JSON.lua")()

commandArray = {}
local url_AhoyDTU = "http://192.168.0.74/api/record/live"
local idx_temp = 310
local idx_counter = 312
local idx_panel1 = 313
local idx_panel2 = 314
local idx_rendement = 315
local power = 0
local Energy = 0
local debug = false

jsondata = assert(io.popen('curl "'..url_AhoyDTU..'"'))
device = jsondata:read('*all')
jsondata:close()
data = JSON:decode(device)

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][15].val) end
power = tonumber(data.inverter[1][15].val)

if debug then print ('Hoymiles Inverter 0 [Temp Celcius]: ' .. data.inverter[1][19].val) end
temperature = tonumber(data.inverter[1][19].val)

if debug then print ('Hoymiles Inverter 0 [Energy_total kWh]: ' .. data.inverter[1][22].val) end
Energy = tonumber(data.inverter[1][22].val) * 1000

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][3].val) end
power1 = tonumber(data.inverter[1][3].val)

if debug then print ('Hoymiles Inverter 0 [Watt]: ' .. data.inverter[1][9].val) end
power2 = tonumber(data.inverter[1][9].val)

if debug then print ('Hoymiles Inverter 0 [%]: ' .. data.inverter[1][24].val) end
rend = tonumber(data.inverter[1][24].val)



if (power ~= nil and Energy > 0) then
commandArray[2] = {['UpdateDevice'] = idx_temp .. '|0|' .. temperature}
commandArray[3] = {['UpdateDevice'] = idx_counter .. "|0|" .. power .. ";" .. Energy}
commandArray[4] = {['UpdateDevice'] = idx_panel1 .. "|0|" .. power1 .. ";" .. Energy}
commandArray[5] = {['UpdateDevice'] = idx_panel2 .. '|0|' .. power2 .. ";" .. Energy}
commandArray[6] = {['UpdateDevice'] = idx_rendement .. '|0|' .. rend}
else
commandArray[1] = {['UpdateDevice'] = idx_counter .. "|0|" .. 0}



end

return commandArray
User avatar
psubiaco
Posts: 194
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by psubiaco »

Very nice info about Hoymiles inverter and integration in Domoticz. Thanks.
About scripting, I'm familiar only with LUA, where you can trigger a script by device change.
The idea is to change hoymiles immission limit as soon as the grid power meter is read.
Many examples available at https://github.com/CreasolTech/domoticz_lua_scripts (check file named script_device_*.lua)
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
C4coer
Posts: 8
Joined: Tuesday 27 March 2018 19:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by C4coer »

Hello, I hadn't seen your question, can you be more clear?
C4coer
Posts: 8
Joined: Tuesday 27 March 2018 19:07
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by C4coer »

psubiaco wrote: Wednesday 18 October 2023 12:24 Very nice info about Hoymiles inverter and integration in Domoticz. Thanks.
About scripting, I'm familiar only with LUA, where you can trigger a script by device change.
The idea is to change hoymiles immission limit as soon as the grid power meter is read.
Many examples available at https://github.com/CreasolTech/domoticz_lua_scripts (check file named script_device_*.lua)
Hello, I hadn't seen your question, can you be more clear?
belzig
Posts: 11
Joined: Saturday 23 April 2022 22:47
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by belzig »

If you want to integrate Ahoy-DTU version 8.1.40 you have to change the script as follows
--------------------------------------------------

Code: Select all

  jsondata    = assert(io.popen('curl --connect-timeout 5 "http://YOUR_DTU_IP/api/inverter/id/0"'))
    device = jsondata:read('*all')
    jsondata:close()
    --data = JSON:decode(device).inverter[1].name
    --print('Devicename ' .. data)

    data = JSON:decode(device)
    --print(JSON:encode_pretty(data.inverter[1][15]))
-- print ('Hoymiles Inverter 1 [Voltage]: ' .. data.ch[2][1])
--  print ('Hoymiles Inverter 1 [Current]: ' .. data.ch[2][2])
--  print ('Hoymiles Inverter 1 [Power:] ' .. data.ch[2][3])

---------change 11 12 13 to your device Idx)
    if (data ~= nil) then
     commandArray[1] = {['UpdateDevice'] = 11  .. "|0|" ..tonumber(data.ch[2][1])}
     commandArray[2] = {['UpdateDevice'] = 12 .. "|0|" ..tonumber(data.ch[2][2])}
     commandArray[3] = {['UpdateDevice'] = 13  .. "|0|" ..tonumber(data.ch[2][3])}
     
--------------------------
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Ahoy Dtu and Hoymiles HM-xxx integration

Post by waltervl »

It seems that Ahoy-DTU supports HA MQTT discovery protocol so an easy integration with Domoticz MQTT Auto Discover should be possible.
for example an issue regarding this: https://github.com/lumapu/ahoy/issues/1613
I could not really find proper Ahoy documentation on this.

Domoticz Wiki on MQTT Autodiscover https://wiki.domoticz.com/MQTT#Add_hard ... Gateway%22
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