Python Plugin: MqttMapper

Python and python framework

Moderator: leecollings

WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Attachment:
Attachments
screenshot.1.jpg
screenshot.1.jpg (182.71 KiB) Viewed 1455 times
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
Kedi
Posts: 537
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Python Plugin: MqttMapper

Post by Kedi »

Fill in the type and click on "Aanpassen"
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: MqttMapper

Post by Xenomes »

Thanks for this great plugin!!
I used it to connect my Reolink doorbell with three switch/status to Domoticz with the uses of Cam2MQTT

For the used code see:
Spoiler: show

Code: Select all

{
    "Visitor": {
        "topic": "cam2mqtt/camera/reolink_cam_1/event/onvif/visitor",
        "type": "244", "subtype": "73", "switchtype": "0",
        "mapping": {"item": "", "default": "0", "values": {"off": "0", "on": "1"}}
    },
    "Motion": {
        "topic": "cam2mqtt/camera/reolink_cam_1/event/onvif/motion",
        "type": "244", "subtype": "73", "switchtype": "0",
        "mapping": {"item": "", "default": "0", "values": {"off": "0", "on": "1"}}
    },
    "Status": {
        "topic": "cam2mqtt/camera/reolink_cam_1/status",
        "type": "244", "subtype": "73", "switchtype": "0",
        "mapping": {"item": "", "default": "0", "values": {"offline": "0", "online": "1"}}
    }
}
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Kedi wrote: Thursday 29 June 2023 20:46 Fill in the type and click on "Aanpassen"
Thats what I did several times.
But the type and settings don't get saved.
So there is in hardware an item without hardware selection and without any settings.
Thats the problem.
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
Kedi
Posts: 537
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: Python Plugin: MqttMapper

Post by Kedi »

Did you try to delete the hardware and create it again?
And is the file mqttmapper.json present and valid?
Logic will get you from A to B. Imagination will take you everywhere.
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: MqttMapper

Post by Xenomes »

WBeulink wrote: Thursday 29 June 2023 20:19Attachment:
Sorry to break in, i saw you issue first i mind was a Bullseye or python 3.9.2 issue so i fire up my test system and updated to the latest version of Bullseye and Python and i was correct my test system shows the same problem a empty 'Type:'. I don't have a solution for you yet.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
User avatar
Xenomes
Posts: 379
Joined: Tuesday 27 November 2018 19:05
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Python Plugin: MqttMapper

Post by Xenomes »

I think you found a bug!
If you put a other plugin in the plugin folder that uses DomoticzEX framework the value of Type: of the Mapper plugin is visible.
So a dirty fix is:

Code: Select all

cd ~/domoticz/plugin
git clone https://github.com/stas-demydiuk/domoticz-zigbee2mqtt-plugin.git
sudo systemctl restart domoticz.service
You don't have to use the plugin as you see the plugin works.

Ps. the beta latest build 15372 has also the issue.
HP T630 (32GB SSD/8GB Mem) - Ubuntu 22.04.4 LTS (64Bit) - Domoticz 2024.7 with Machinon theme - RFLink - KaKu - Sonoff - Tasmota - Shelly - MQTT2Zigbee - OpenTherm Gateway - Tinytuya - IR Blaster - P1 Smart Meter - NPN Watermeter - Google Assistant
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Thanks for your answer.
The "dirty trick" works!
But when I upgraded Bulseye afterwards the upgrade complete broke Domoticz.
Domoticz can't open port 8080 anymore. Other problem. Not this topic
So I decided to go back to Buster.
Fresh install and complete upgrade.
However i found that I still had to do the "dirty trick" to see hardware type and settings of the plugin.
So: maybe not Bulseye then. Domoticz stable without problems on Buster now.
See attachement:

Also as you see: adding extra folder wit second version of plugin (rename plugin key in plugin.py) adds the possibility to connect to second broker.
Nice!

Hope this will help ..
Willem
Attachments
screenshot.3.jpg
screenshot.3.jpg (183.71 KiB) Viewed 1319 times
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Question about a "thermostatic setpoint" in Domotic via this plugin.

I managed to create a thermostatic setpoint device in DZ via this plugin.
Correct device and correct reading and display of value of setpoint in DZ.
But I can't figure out how to change the setpoint from DZ.

I get in the logfile: Error: MQTT mapper: No mapping for MQTT mapper - Raam SetPoint heat

Value in DZ doesn't change and nothing send.

I have this in my .json file:

"Raam SetPoint cool": {
"topic": "homeassistant/Raam/67/0/setpoint/11",
"type": "242", "subtype": "1", "switchtype": "0",
"set": {"topic": "homeassistant/Raam/67/0/setpoint/11/set", "payload": {"value":"#"}},
"mapping": {"item": "value"}
}

I'am on plugin version: version="1.0.12"

Anyone with help on this??
Willem
Attachments
screenshot.4.jpg
screenshot.4.jpg (182.46 KiB) Viewed 1320 times
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
FlyingDomotic
Posts: 303
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Amazing, as French user was integrating a setPoint device 2 days ago, and find a bug, which is fixed in last version.
Could you please upgrade MqttMqpper and try again?
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Just now I found version 1.0.13
Updated friday to 1.0.12
Updated to 13 and it works!
Great.
Willem
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Still playing around with this plugin.
version 1.0.13 Got some created devices working in DZ. But:
Found a problem. Or maybe I'am doing things wrong.
It has to do with a payload in JSON format and using 2 values from that in one device ...
See part of JSON-file

Working:
"Minisensor-1H": {
"topic": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1384BF6E8",
"type": "81", "subtype": "1", "switchtype": "0",
"mapping": {"item": "hum"}
},
Working also:
"Minisensor-1T": {
"topic": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1384BF6E8",
"key": "Minisensor-1T",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": "tempc"}
},
Not working (device is created but never receives any data):
"topic": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1384BF6E8",
"key": "Minisensor-1TH",
"type": "82", "subtype": "1", "switchtype": "0",
"mapping": {"item": "tempc;hum"}
}

key's used because it's one topic for all three devices.
That works OK!

Any idea?

Willem
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

I have to correct. The device icon doesn't show data. But the device log does!
screenshot.5.jpg
screenshot.5.jpg (102.3 KiB) Viewed 1265 times
screenshot.6.jpg
screenshot.6.jpg (99.06 KiB) Viewed 1265 times
Strange.
Willem
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

What to do in mapping if the JSON read from the topic is hierachic?
Like this one:
{
"Time": "2023-07-19T22:10:16",
"AM2301": {
"Temperature": 24.5,
"Humidity": 77.1,
"DewPoint": 20.2
},
"TempUnit": "C"
}
Last edited by WBeulink on Wednesday 19 July 2023 23:55, edited 2 times in total.
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
FlyingDomotic
Posts: 303
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Structure you're using is made for merging 2 different MQTT topics in the same Domoticz device.

In your case, all data needed to load Domoticz device is present in the same topic. Could you try:

Code: Select all

	"Minisensor-1": {
	"topic": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1384BF6E8",
	"type": "82", "subtype": "1", "switchtype": "0",
        "mapping": {"item": "Temperature;Humidity"}
}
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

But the JSON is not flat.
So I need something like:

"mapping": {"item": "AM2301/Temperature;AM2301/Humidity"}

to adress the values properly.

I have this in domoticz log as error:
2023-07-20 00:06:16.904 Error: MQTT mapper: Can't find >Temperature< in >{'Time': '2023-07-19T23:06:16', 'AM2301': {'Temperature': 24.4, 'Humidity': 77.6, 'DewPoint': 20.2}, 'TempUnit': 'C'}<
2023-07-20 00:05:16.953 Error: MQTT mapper: Can't find >Humidity< in >{'Time': '2023-07-19T23:05:16', 'AM2301': {'Temperature': 24.4, 'Humidity': 77.5, 'DewPoint': 20.2}, 'TempUnit': 'C'}<
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
FlyingDomotic
Posts: 303
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

You're right, I didn't saw the AM2301 in the message. Does

Code: Select all

"mapping": {"item": "AM2301/Temperature;AM2301/Humidity"}
work?
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

No. Doesn't work. Alas.
Of cause it's possible to do things like this in Node Red.
But nice thing of this plugin is that maybe we can do things like this without Node Red.
I'am afraid it takes some programming effort to add this functionality.
But maybe .....
Willem
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
FlyingDomotic
Posts: 303
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

I made it work with:

Code: Select all

	"Minisensor-1": {
		"topic": "home/OpenMQTTGateway_ESP32_BLE/BTtoMQTT/A4C1384BF6E8",
		"type": "82", "subtype": "1", "switchtype": "0",
		"mapping": {"item": "AM2301/Temperature;AM2301/Humidity;~0"}
	}
Problem was related to the missing ;~0 at end of data.
WBeulink
Posts: 23
Joined: Monday 21 December 2020 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.1
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by WBeulink »

Confirm. Works! Thanks.
So ~0 is third item of svalue in DZ?
As expected by this device in DZ?

In that case both of my problems are solved.
Confirmd.
See above .....

Willem
Last edited by WBeulink on Friday 21 July 2023 23:40, edited 1 time in total.
--
RP4 - Buster/BullsEye - Domoticz 2023.2 - Z-Wave JS UI
Willem
--
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest