Python Plugin: MqttMapper

Python and python framework

Moderator: leecollings

hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

It is working now.

"MQTTsignal": {
"topic": "homeassistant/easee/power",
"type": "243", "EnergyMeterMode": "1", "subtype": "29", "switchtype": "0",
"mapping": {"item": "~*;~0","multiplier": 1000}

Thanks a lot!
Attachments
Screenshot 2025-03-13 134432.png
Screenshot 2025-03-13 134432.png (245.72 KiB) Viewed 771 times
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Happy to heard that!

However, syntax is not the right one (so "EnergyMeterMode": "1" is ignored and may be missing in device). This don't make plugin to crash, but is just ignored.

Right syntax is:

Code: Select all

"MQTTsignal": {
	"topic": "homeassistant/easee/power",
	"type": "243", "subtype": "29", "switchtype": "0",
	"options": {"EnergyMeterMode": "1" },
	"mapping": {"item": "~*;~0","multiplier": 1000}
}
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

Strange that is had a positive effect.

I updated the file and its still fine, again, thanks for the help!
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

Sorry to bother you again, but I have a MQTT value that is not updating:

value in MQTT Explorer:
RunDataCompressorSpeed = {"value": {"value": 30}}

and a Mqtt file:
"RunDataCompressorSpeed": {
"topic": "ebusd/hmu/RunDataCompressorSpeed",
"type": "243", "subtype": "6", "switchtype": "0",
"mapping": {"item": "value/value"}
}

It just updated now, but it seems the frequency is not in line with the MQTT Explorer output. I did change the name, is that of influence?
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

For type 243, sub-type 6 is percent, so value should be in range 0-100. Sub-type 7 (fan) should be better.
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

Hier I am again ... i just cant get it right.
I've used Zigbee2mqtt and I need the value of a lux sensor (and more late on). I've tried, but no succes. Hier my mqtt file and the file i used in mapper.
Screenshot 2025-06-11 170606.png
Screenshot 2025-06-11 170606.png (93.61 KiB) Viewed 422 times
I need the values of the sensor and the water in Ulta-Dongle. Ive tried this but no succes:
{
"T_Outside": {
"topic": "ebusd/Broadcast/Outsidetemp",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": ""}
},

"T_Living": {
"topic": "ebusd/ctlv2/Z1RoomTemp",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": ""}
},

"MQTTrunning": {
"topic": "ebusd/global/running",
"type": "244", "subtype": "73", "switchtype": "0",
"mapping": {"item": "", "default": "0"}
},

"MQTTsignal": {
"topic": "ebusd/global/signal",
"type": "244", "subtype": "73", "switchtype": "0",
"mapping": {"item": "", "default": "0"}
},

"MQTTsignal": {
"topic": "ebusd/hmu/RunDataCompressorSpeed",
"type": "243", "subtype": "6", "switchtype": "0",
"mapping": {"item": ""}
},

"MQTT_water": {
"topic": "Ultra-Dongle/water",
"type": "113", "subtype": "0", "switchtype": "2",
"mapping": {"item": ""}
},
"MQTT_Light_Sens": {
"topic": "zigbee2mqtt/Light_Sens",
"type": "246", "subtype": "1", "switchtype": "0",
"mapping": {"item": "","illuminace": "","",""}
}

}

I'm horrible with this .....
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by waltervl »

@hjzwiers you are not using the standard MQTT auto Discovery for zigbee2mqtt? As for that value should be a lux sensor be created.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

I have auto discovery installed, but its not downloading?

I see the results in the separate website, is it a setting somewhere?

I changed the setting to force homeassistant, then auto discovery sees them. The last one is done (still leaves the other...)

Thanks!
Last edited by hjzwiers on Wednesday 11 June 2025 19:57, edited 1 time in total.
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by waltervl »

hjzwiers wrote: Wednesday 11 June 2025 19:43 I have auto discovery installed, but its not downloading?

I see the results in the separate website, is it a setting somewhere?
Better discuss this in a new topic in the MQTT AD subforum, not here

MQTT AD subforum: viewforum.php?f=82
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

I have solved the water sensor and light sensor!

I have one question remaining. I use the sensors in ebusd as sensors to contol that I still have a connection. These are booleans, which I cant read very well in domotics. I've tried nearly everthing but I can't work it out.
Screenshot 2025-06-13 110507.png
Screenshot 2025-06-13 110507.png (112.08 KiB) Viewed 319 times
Mqttfile:

{
"T_Outside": {
"topic": "ebusd/Broadcast/Outsidetemp",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": ""}
},

"T_Living": {
"topic": "ebusd/ctlv2/Z1RoomTemp",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": ""}
},

"MQTTrunning": {
"topic": "ebusd/global/running",
"type": "244", "subtype": "73", "switchtype": "0",
"mapping": {"item": "", "default": "0"}
},

"MQTTsignal": {
"topic": "ebusd/global/signal",
"type": "244", "subtype": "73", "switchtype": "0",
"mapping": {"item": "", "default": "0", "values": {"false": "0ff", "true" : "On"}}
},

"MQTT_Compressor": {
"topic": "ebusd/hmu/RunDataCompressorSpeed",
"type": "243", "subtype": "6", "switchtype": "0",
"mapping": {"item": ""}
}

}
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Try this:

Code: Select all

{
	"T_Outside": {
		"topic": "ebusd/Broadcast/Outsidetemp",
		"type": "80", "subtype": "5", "switchtype": "0",
		"mapping": {"item": ""}
	},

	"T_Living": {
		"topic": "ebusd/ctlv2/Z1RoomTemp",
		"type": "80", "subtype": "5", "switchtype": "0",
		"mapping": {"item": ""}
	},

	"MQTTrunning": {
		"topic": "ebusd/global/running",
		"type": "244", "subtype": "73", "switchtype": "0",
		"mapping": {"item": "", "default": "0", "values": {"False": "0", "True" : "100"}}
	},

	"MQTTsignal": {
		"topic": "ebusd/global/signal",
		"type": "244", "subtype": "73", "switchtype": "0",
		"mapping": {"item": "", "default": "0", "values": {"False": "0", "True": "100"}}
	},

	"MQTT_Compressor": {
		"topic": "ebusd/hmu/RunDataCompressorSpeed",
		"type": "243", "subtype": "6", "switchtype": "0",
		"mapping": {"item": ""}
	}

}
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

Now what do I use in domoticz to read out that signal?

Further with the temperature readout i have a mqtt server that "switches" between:

Outsidetemp = {"value":{"value":30.125}}
and
Outsidetemp = 30.125

which needs "mapping" : {"item": {"value"/"value"}}
or "mapping" : {"item": ""}

I keep changing it .....
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

As of now, there's no direct way to do it.

But, as general workaround, you may store data into a string, analyze it, and store value with a script into a virtual device.

Code: Select all

"T_OutsideText": {
	"topic": "ebusd/Broadcast/Outsidetemp",
	"type": "243", "subtype": "19", "switchtype": "0",
	"mapping": {"item": "value"}
}
Content of "T_OutsideText" could either be something like:

Code: Select all

xxx.xx
or

Code: Select all

"value": xxx.xx`
You may write a small script that analyze "T_OutsideText" device content, and load another virtual temperature device depending on content (with or without "value":
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

2025-06-13 17:19:14.020 MQTT mapper: Processing 'onMessageCallback' message
2025-06-13 17:19:14.020 MQTT mapper: Calling message handler 'onMessage' on 'module' type object.
2025-06-13 17:19:14.020 MQTT mapper: onMQTTPublish found ebusd/global/signal, Device 'MQTTsignal', message 'True'
2025-06-13 17:19:14.020 MQTT mapper: testValue="False" (str), readValue="True" (str)
2025-06-13 17:19:14.020 MQTT mapper: testValue="True" (str), readValue="True" (str)
2025-06-13 17:19:14.020 MQTT mapper: Setting MQTTsignal to 1/
2025-06-13 17:19:14.020 (MQTTsignal) Updating device from 1:'' to have values 1:''.
2025-06-13 17:19:14.022 MQTT mapper: Processing 'onMessageCallback' message
2025-06-13 17:19:14.022 MQTT mapper: Calling message handler 'onMessage' on 'module' type object.
2025-06-13 17:19:14.022 MQTT mapper: onMQTTPublish found ebusd/global/running, Device 'MQTTrunning', message 'True'
2025-06-13 17:19:14.022 MQTT mapper: testValue="False" (str), readValue="True" (str)
2025-06-13 17:19:14.022 MQTT mapper: testValue="True" (str), readValue="True" (str)
2025-06-13 17:19:14.022 MQTT mapper: Setting MQTTrunning to 1/
2025-06-13 17:19:14.022 (MQTTrunning) Updating device from 1:'' to have values 1:''.

Both values are true, so I would expect them to be 100?
also have the two temperatures that need to be scripted to the readout temperatures ... I don't really have a clue how to start, I have programming skills, but they are very limited. I thought that MqttMapper made the output blocks in domoticz, but for instance I deleted the charger output thinking it would be created, but it wasn't
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

This is a strange thing about Domoticz.

It has nValue to set state, the first part of settings, and a sValue to set other things (including Level, which is from '0' to '100').

Here, on/off switches use only nValue (0=Off, 1=fully On, 2=between 1 and 99, included), but 1 in nValue means '100' in sValue.

I'm trying to make things simpler in next version (or the following) of MqttMapper, replacing 0 by "Off" and 1 (or 100) by "On", to make it clearer for users.

Outside this, does switches work as expected?
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

I have some stuf to thing about. I get all the values from the ebusd, so an alternatieve is present.
I think the sensors work, don't know why, but I switched off the sensor and they went down, pretty amazing.
I think I will clean everything up, now every thing in docker files with dockge. I changed a lot lol
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Just a tip:

If you're making a change in Domoticz device definition (changing type/subtype or options), it could be a good idea to delete corresponding device, and restart MqttMapper (or Domoticz) as changing these characteristics on an existing device may sometimes fail...
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

I was just wondering how to get the values. The script must run within MqttMapper.

This is the current logging:
2025-06-21 17:22:10.925 MQTT mapper: Pushing 'onMessageCallback' on to queue
2025-06-21 17:22:10.925 MQTT mapper: Processing 'onMessageCallback' message
2025-06-21 17:22:10.925 MQTT mapper: Calling message handler 'onMessage' on 'module' type object.
2025-06-21 17:22:10.925 MQTT mapper: onMQTTPublish found ebusd/Broadcast/Outsidetemp, Device 'MQTT mapper - T_Outside', message '{'value': {'value': 30.375}}'
2025-06-21 17:22:10.926 MQTT mapper: Setting MQTT mapper - T_Outside to >{
2025-06-21 17:22:10.926 "value": {"value": 30.375}}<
2025-06-21 17:22:10.926 (MQTT mapper - T_Outside) Updating device from 0:'{
2025-06-21 17:22:10.926 "value": {"value": 30.375}}' to have values 0:'{
2025-06-21 17:22:10.926 "value": {"value": 30.375}}'.

so the value is 30.375, but it is set to 0, also within devices it is set to 0. So where do I make the script?
FlyingDomotic
Posts: 356
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Are you sure device has been set to text ("type": "243", "subtype": "19", "switchtype": "0"), and device recreated ?
Could you check that "T_OutsideText" device is properly displayed into "Utility" tab?
hjzwiers
Posts: 242
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

I know have {"value": {"value": 30.375}} as an item in my list: thanks a lot.

Now the conversion never done that before
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest