closed: sent data via MQTTPush results in integer vaue iso float

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Post Reply
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

closed: sent data via MQTTPush results in integer vaue iso float

Post by BartSr »

Hi!
I am using sent data via mqtt to HA
THe value e.g. gas meter shows in Domoticz 1165.118 but in mqtt exporer I only see 1165.
Is there a way to sent 1165.118 via MQTT or must I create a dummy device which shows gasvalue*1000?
-Bart
Last edited by BartSr on Wednesday 06 November 2024 16:54, edited 1 time in total.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by waltervl »

I do not use MQTT so limited knowledge here.
What do you see when you ask the data through json API eg

Code: Select all

/json.htm?type=command&param=getdevices&rid=IDX
I see the float value as data so I would expect that MQTT would send that too

Code: Select all

"app_version" : "2024.7",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "235.495",
			"CounterToday" : "0.394 m3",
			"CustomImage" : 0,
			"Data" : "235.495",
			"Description" : "",
			"Favorite" : 1,
			"HardwareDisabled" : false,
			"HardwareID" : 3,
			"HardwareName" : "Nefit Easy",
			"HardwareType" : "Nefit Easy HTTP server over LAN interface",
			"HardwareTypeVal" : 68,
			"HaveTimeout" : false,
			"ID" : "0001",
			"LastUpdate" : "2024-10-14 18:20:42",
			"Name" : "CV Gasverbruik",
			"Notifications" : "false",
			"PlanID" : "12",
			"PlanIDs" : 
			[
				12
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Gas",
			"SwitchTypeVal" : 1,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 2,
			"Used" : 1,
			"XOffset" : "374",
			"YOffset" : "426",
			"idx" : "8",
			"price" : "0.3940"
		}
	],
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by BartSr »

Device in Domoticz says:
today 0.000
total 1165.130

this is returned after comand : http://192.168.2.100:8080/json.htm?type ... es&rid=762

Code: Select all

{
	"ActTime" : 1729111058,
	"AstrTwilightEnd" : "20:38",
	"AstrTwilightStart" : "06:18",
	"CivTwilightEnd" : "19:20",
	"CivTwilightStart" : "07:36",
	"DayLength" : "10:36",
	"NautTwilightEnd" : "19:59",
	"NautTwilightStart" : "06:57",
	"ServerTime" : "2024-10-16 22:37:38",
	"SunAtSouth" : "13:28",
	"Sunrise" : "08:10",
	"Sunset" : "18:46",
	"app_version" : "2024.7 (build 16285)",
	"result" : 
	[
		{
			"AddjMulti" : 1.0,
			"AddjMulti2" : 1.0,
			"AddjValue" : 0.0,
			"AddjValue2" : 0.0,
			"BatteryLevel" : 255,
			"Counter" : "1165.130",
			"CounterToday" : "0.000 m3",
			"CustomImage" : 0,
			"Data" : "1165.130",
			"Description" : "",
			"Favorite" : 1,
			"HardwareDisabled" : false,
			"HardwareID" : 10,
			"HardwareName" : "P1",
			"HardwareType" : "P1 Smart Meter USB",
			"HardwareTypeVal" : 4,
			"HaveTimeout" : false,
			"ID" : "0001",
			"LastUpdate" : "2024-10-16 22:35:30",
			"Name" : "Gas",
			"Notifications" : "false",
			"PlanID" : "3",
			"PlanIDs" : 
			[
				3
			],
			"Protected" : false,
			"ShowNotifications" : true,
			"SignalLevel" : "-",
			"SubType" : "Gas",
			"SwitchTypeVal" : 1,
			"Timers" : "false",
			"Type" : "P1 Smart Meter",
			"TypeImg" : "counter",
			"Unit" : 2,
			"Used" : 1,
			"XOffset" : "481",
			"YOffset" : "660",
			"idx" : "762",
			"price" : "0.0000"
		}
	],
	"status" : "OK",
	"title" : "Devices"
}


and this is what MQTT explorere says.

Code: Select all

domoticz
out = { "Battery" : 255, "LastUpdate" : "2024-10-16 22:45:30", "RSSI" : 12, "description" : "", "dtype" : "P1 Smart Meter", "hwid" : "10", "id" : "0001", "idx" : 762, "name" : "Gas", "nvalue" : 0, "org_hwid" : "10", "stype" : "Gas", "svalue1" : "1165130", "unit" : 2 }
As you can see it's an integer what's listed. So I presume this must be devided by 1000 to get correct value (m3)
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by waltervl »

So the question and conclusion (Domoticz is sending only the integer part) you started with is incorrect. You get the whole value in integer but in a different Unit of measure (Wh instead of kWh)
Then indeed you have to divide it with the same divider as set in your counter settings (in your case 1000)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by BartSr »

Walter, I updated the post as I forgot to show the result of this value as sent by Domoticz. It seems you missed that (my bad).
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by waltervl »

BartSr wrote: Monday 14 October 2024 16:37 Hi!
I am using sent data via mqtt to HA
THe value e.g. gas meter shows in Domoticz 1165.118 but in mqtt exporer I only see 1165.
Is there a way to sent 1165.118 via MQTT or must I create a dummy device which shows gasvalue*1000?
-Bart
This is what you wrote Which seems incorrect as in mqtt explorer you would have seen value 1165118 as you described later.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by BartSr »

Walter, 1165118 was received from Gridcounter. That value goes in Domoticz. When I send that value via Domoticz (settings>more options>send data>Mqtt) it sends 1165.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by waltervl »

here you say something different. So you have to be clear:

Code: Select all

domoticz
out = { "Battery" : 255, "LastUpdate" : "2024-10-16 22:45:30", "RSSI" : 12, "description" : "", "dtype" : "P1 Smart Meter", "hwid" : "10", "id" : "0001", "idx" : 762, "name" : "Gas", "nvalue" : 0, "org_hwid" : "10", "stype" : "Gas", "svalue1" : "1165130", "unit" : 2 }
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by BartSr »

Walter, don't know what happened after I thought to have updated one of my posts it wasnot. Maybe forgot to submit again.
Having said this pls note: that when I send that value via Domoticz (settings>more options>send data>Mqtt) it sends 1165.
Can't copy a screenshot because the value is only visible in MQTT explorer once a value has changed. This did not happen for a few days as I didnot use gas.
Whereas I expect that hereunder is the result of P1 connection
domoticz
out = { "Battery" : 255, "LastUpdate" : "2024-10-16 22:45:30", "RSSI" : 12, "description" : "", "dtype" : "P1 Smart Meter", "hwid" : "10", "id" : "0001", "idx" : 762, "name" : "Gas", "nvalue" : 0, "org_hwid" : "10", "stype" : "Gas", "svalue1" : "1165130", "unit" : 2 }
So value sent out by Domoticz don't mention the decimal part.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by BartSr »

@waltervl

Walter I was able to catch both the value from P1 meter (hardware ID 10 as well as the value sent by Domoticz. You can see that the decimal part is left. Is this how it should be?
gas.jpg
gas.jpg (22.86 KiB) Viewed 501 times
gas2.jpg
gas2.jpg (14.66 KiB) Viewed 501 times

-Bart
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by waltervl »

Domoticz/out is the normal standard MQTT out topic. I don't know how you created the DomoHome/762 topic.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by BartSr »

@Waltervl

Maybe there are more possibilities to get what you want but than still the question remains why MQTT sent via domoticz no complete value.
You asked how I got the DomoHome/762 topic.
See downbelow the screeshots.
menu.jpg
menu.jpg (146.9 KiB) Viewed 481 times
Attachments
mqtt.jpg
mqtt.jpg (157.56 KiB) Viewed 481 times
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTT results in integer vaue iso float

Post by waltervl »

OK, then I would submit a ticket at the Github repository that when using the MQTTPush function, data values are sent differently than the normal MQTT Hardware gateway. And show the difference as shown in your previous post.

As a workaround you could use the Domoticz/out message to send the data to HA.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTTPush results in integer vaue iso float

Post by BartSr »

I never submitted a ticket. How to do?
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: sent data via MQTTPush results in integer vaue iso float

Post by waltervl »

Click on new button on page https://github.com/domoticz/domoticz/issues and follow the instructions.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BartSr
Posts: 347
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.3
Location: Netherlands
Contact:

Re: sent data via MQTTPush results in integer vaue iso float

Post by BartSr »

thanks Walter
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 espeasy
MQTT
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest