Page 1 of 1
Omnik data to openWB with Mqtt
Posted: Friday 21 May 2021 17:05
by Pvhpsb
I would like to send my Omnik data "Countertoday" and "Usage" with MQTT publish to my openWB (Charging station), but I am not very familiar with Dzvents. Please help.
This need openWb
Per MQTT zu schreiben:
openWB/set/pv/1/W PV-Leistung in Watt, int, negativ
openWB/set/pv/1/WhCounter Erzeugte Energie in Wh, float, nur positiv
Output Omnik/PVoutput
- Spoiler: show
Code: Select all
{
"ActTime" : 1621608438,
"AstrTwilightEnd" : "01:19",
"AstrTwilightStart" : "01:56",
"CivTwilightEnd" : "22:19",
"CivTwilightStart" : "04:57",
"DayLength" : "15:56",
"NautTwilightEnd" : "23:19",
"NautTwilightStart" : "03:56",
"ServerTime" : "2021-05-21 16:47:18",
"SunAtSouth" : "13:38",
"Sunrise" : "05:40",
"Sunset" : "21:36",
"app_version" : "2021.1",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CounterToday" : "2.160 kWh", *************************************************
"CustomImage" : 0,
"Data" : "6459.180 kWh",
"Description" : "192.168.178.12",
"EnergyMeterMode" : "",
"Favorite" : 0,
"HardwareDisabled" : false,
"HardwareID" : 4,
"HardwareName" : "Zonne Panelen",
"HardwareType" : "PVOutput (Input)",
"HardwareTypeVal" : 30,
"HaveTimeout" : false,
"ID" : "00000001",
"LastUpdate" : "2021-05-21 16:45:23",
"Name" : "Zonne Panelen",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "kWh",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "General",
"TypeImg" : "current",
"Unit" : 1,
"Usage" : "983 Watt", ****************************************
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "12"
}
],
"status" : "OK",
"title" : "Devices"
}
Re: Omnik data to openWB with Mqtt
Posted: Friday 21 May 2021 19:59
by waaren
Pvhpsb wrote: Friday 21 May 2021 17:05
I would like to send my Omnik data "Countertoday" and "Usage" with MQTT publish to my openWB (Charging station), but I am not very familiar with Dzvents.
- What is the type / subtype of this device as seen on the devices tab?
- What is your domoticz version?
- Can the domoticz user execute the mosquitto client mosquitto_pub?
Re: Omnik data to openWB with Mqtt
Posted: Friday 21 May 2021 21:42
by Pvhpsb
1 = 12 Zonne Panelen 00000001 1 Zonne Panelen General kWh 6461.300 kWh - - 2021-05-21 21:35:22
2 = Version: 2021.1
Build Hash: 8547c5b7e
Compile Date: 2021-04-17 17:29:11
dzVents Version: 3.1.7
Python Version: 3.8.6 (default, Jan 27 2021, 15:42:20) [GCC 10.2.0]
3 = Yes i can send publisch messages
Thanks for the quick response.
Re: Omnik data to openWB with Mqtt
Posted: Friday 21 May 2021 23:01
by waaren
Pvhpsb wrote: Friday 21 May 2021 21:42
Yes i can send publisch messages
Could look like below
Code: Select all
local scriptVar = 'solar2omnik'
return
{
on =
{
devices =
{
'Zonne Panelen',
},
shellCommandResponses =
{
scriptVar,
}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
if item.isDevice then
local MQTTBase = "mosquitto_pub " -- or full qualified program name
local omnikLeistung = MQTTBase ..' -m ' .. (item.actualWatt * -1) .. ' -t openWB/set/pv/1/W '
local omnikErzeugt = MQTTBase .. ' -m '.. item.WhTotal .. ' -t openWB/set/pv/1/WhCounter '
dz.executeShellCommand(
{
command = omnikLeistung .. '; ' .. omnikErzeugt,
callback = scriptVar,
timeout = 10,
})
elseif item.isShellCommandResponse then
if item.statusCode == 0 then
dz.log('commands processed OK',dz.LOG_DEBUG)
else
dz.log('commands processed NOK',dz.LOG_ERROR)
dz.log(item,dz.LOG_DEBUG)
end
end
end
}
Re: Omnik data to openWB with Mqtt
Posted: Saturday 22 May 2021 16:30
by Pvhpsb
Thanks i test it soon.
Re: Omnik data to openWB with Mqtt
Posted: Saturday 22 May 2021 20:48
by Pvhpsb
After changing line 27 I get the correct value in "openWB"
local omnikLeistung = MQTTBase ..' -m ' .. math.floor(item.actualWatt + 0.5) .. ' -t openWB/set/pv/1/W '
Line 28 indicates in "openWB" the total yield "Data" and not the daily yield "CounterToday"
Thank you very much for now.
Re: Omnik data to openWB with Mqtt
Posted: Sunday 23 May 2021 1:53
by waaren
Pvhpsb wrote: Saturday 22 May 2021 20:48
Line 28 indicates in "openWB" the total yield "Data" and not the daily yield "CounterToday"
So I guess changing line 28 from
Code: Select all
local omnikErzeugt = MQTTBase .. ' -m '.. item.WhTotal .. ' -t openWB/set/pv/1/WhCounter '
to
Code: Select all
local omnikErzeugt = MQTTBase .. ' -m '.. item.counterToday .. ' -t openWB/set/pv/1/WhCounter '
should fix that ?
Re: Omnik data to openWB with Mqtt [Solved]
Posted: Sunday 23 May 2021 20:41
by Pvhpsb
That's the solution, thank you again.