Page 19 of 26
Re: Python Plugin: MqttMapper
Posted: Thursday 10 July 2025 16:26
by waltervl
@FlyingDomotic your help requested in this topic please
viewtopic.php?p=327147#p327147
Error MQTT mapper: Duplicate xxxxxx node/key
Re: Python Plugin: MqttMapper
Posted: Thursday 10 July 2025 21:30
by Varazir
Is it just me or more who get confused with the mix of English and French?
It would better to have 2 different readme files.
Second it's hard to follow when we don't have an source output from MQTT.
So you can see how the source looks like and how the JSON output looks like.
I'm thinking using this mod along with What's up Docker MQTT integration,
this is the JSON payload
https://gist.github.com/varazir/ecac2f5 ... 2a09cfc057
How it looks like in MQTT Explorer
I'm not sure what to do but something like this
Code: Select all
{
"Dockge Status": {
"topic": "wud/container/docker/dockge-dockge-1",
"type": "244",
"subtype": "73",
"switchtype": "11",
"mapping": {
"item": "status",
"default": "1",
"values": {
"close": "0"
}
}
},
"Dockge Update": {
"topic": "wud/container/docker/dockge-dockge-1",
"type": "244",
"subtype": "73",
"switchtype": "11",
"mapping": {
"item": "update_available",
"default": "false",
"values": {
"close": "0"
}
}
}
}
Re: Python Plugin: MqttMapper
Posted: Friday 11 July 2025 1:02
by FlyingDomotic
Re: Python Plugin: MqttMapper
Posted: Friday 11 July 2025 9:52
by FlyingDomotic
Varazir wrote: Thursday 10 July 2025 21:30
Is it just me or more who get confused with the mix of English and French?
It would better to have 2 different readme files.
Second it's hard to follow when we don't have an source output from MQTT.
So you can see how the source looks like and how the JSON output looks like.
I'm thinking using this mod along with What's up Docker MQTT integration,
this is the JSON payload
https://gist.github.com/varazir/ecac2f5 ... 2a09cfc057
How it looks like in MQTT Explorer
I'm not sure what to do but something like this
Code: Select all
{
"Dockge Status": {
"topic": "wud/container/docker/dockge-dockge-1",
"type": "244",
"subtype": "73",
"switchtype": "11",
"mapping": {
"item": "status",
"default": "1",
"values": {
"close": "0"
}
}
},
"Dockge Update": {
"topic": "wud/container/docker/dockge-dockge-1",
"type": "244",
"subtype": "73",
"switchtype": "11",
"mapping": {
"item": "update_available",
"default": "false",
"values": {
"close": "0"
}
}
}
}
Analysis is good.
The only thing that won't work is mapping default and values.
Default value is related to Domoticz device. Here, 244/73/11 is a door switch, having internally 2 values (as per
https://wiki.domoticz.com/Developing_a_ ... vice_Types): "Statuses: Open: nValue = 1, Closed: nValue = 0).
So default should be either 0 or 1.
Concerning mapping values, first part of each item is MQTT message content.
So, for "Dockge Status", which seems to have a "status": "running", you should write something like "default": 0, "values": {"running": 1}
For "Dockge Update", which seems false or true, you may write ("default": 1, values: {"false": 0}
An additional remark: You have the same topic more than once (here "wud/container/docker/dockge-dockge-1"). You avoid a duplicate error message, it's a good practice to add a "key" item, that should be unique into file, and probably significant for you.
Here is an example of file that may work:
Code: Select all
{
"Dockge Status": {
"topic": "wud/container/docker/dockge-dockge-1",
"key": "wud/container/docker/dockge-dockge-1-status",
"type": "244", "subtype": "73", "switchtype": "11",
"mapping": {"item": "status", "default": "0", "values": {"running": "1"}}
},
"Dockge Update": {
"topic": "wud/container/docker/dockge-dockge-1",
"key": "wud/container/docker/dockge-dockge-1-update",
"type": "244", "subtype": "73", "switchtype": "11",
"mapping": {"item": "update_available", "default": "1", "values": {"false": "0"}}
}
}
Re: Python Plugin: MqttMapper
Posted: Friday 11 July 2025 11:23
by Varazir
FlyingDomotic wrote: Friday 11 July 2025 9:52
Analysis is good.
The only thing that won't work is mapping default and values.
Default value is related to Domoticz device. Here, 244/73/11 is a door switch, having internally 2 values (as per
https://wiki.domoticz.com/Developing_a_ ... vice_Types): "Statuses: Open: nValue = 1, Closed: nValue = 0).
So default should be either 0 or 1.
Concerning mapping values, first part of each item is MQTT message content.
So, for "Dockge Status", which seems to have a "status": "running", you should write something like "default": 0, "values": {"running": 1}
For "Dockge Update", which seems false or true, you may write ("default": 1, values: {"false": 0}
An additional remark: You have the same topic more than once (here "wud/container/docker/dockge-dockge-1"). You avoid a duplicate error message, it's a good practice to add a "key" item, that should be unique into file, and probably significant for you.
Here is an example of file that may work:
Code: Select all
{
"Dockge Status": {
"topic": "wud/container/docker/dockge-dockge-1",
"key": "wud/container/docker/dockge-dockge-1-status",
"type": "244", "subtype": "73", "switchtype": "11",
"mapping": {"item": "status", "default": "0", "values": {"running": "1"}}
},
"Dockge Update": {
"topic": "wud/container/docker/dockge-dockge-1",
"key": "wud/container/docker/dockge-dockge-1-update",
"type": "244", "subtype": "73", "switchtype": "11",
"mapping": {"item": "update_available", "default": "1", "values": {"false": "0"}}
}
}
Thanks then I understand better,
The example worked, I need to fix the device I want, wasn't the correct one.
so Item = JSON key, correct ?
What happens if you have more then one of the same key ? lets say like this ?
Code: Select all
{
"status": "On",
"running": {
"status": "Running"
}
}
"default" is just what you use, nothing to do with the source data, and "values" used to match the value of the key,
So I could have something like this:
Code: Select all
"values": {
"false": "0",
"true": "1"
}
Re: Python Plugin: MqttMapper
Posted: Friday 11 July 2025 11:48
by Varazir
This worked as I liked, now I just need to add the others but it's copy and paste, change the name of the array, topic and key
Code: Select all
{
"Dockge Status": {
"topic": "wud/container/docker/dockge-dockge-1",
"key": "wud/container/docker/dockge-dockge-1-status",
"type": "244",
"subtype": "73",
"switchtype": "0",
"mapping": {
"item": "status",
"default": "0",
"values": {
"running": "100"
}
}
},
"Dockge Update": {
"topic": "wud/container/docker/dockge-dockge-1",
"key": "wud/container/docker/dockge-dockge-1-update",
"type": "244",
"subtype": "73",
"switchtype": "0",
"mapping": {
"item": "update_available",
"default": "0",
"values": {
"false": "0",
"true": "100"
}
}
}
}
I see it picks up the name of the HW I have set on the name device, something I can change ?
Would be cool if I could define the icon's I like to use as well.
Re: Python Plugin: MqttMapper
Posted: Friday 11 July 2025 22:23
by FlyingDomotic
Varazir wrote: Friday 11 July 2025 11:23
What happens if you have more then one of the same key ? lets say like this ?
Code: Select all
{
"status": "On",
"running": {
"status": "Running"
}
}
First one "status": "On" is "item": "status", second one "status": "Running" is "item": "running/status"
Varazir wrote: Friday 11 July 2025 11:23
"default" is just what you use, nothing to do with the source data, and "values" used to match the value of the key,
So I could have something like this:
Code: Select all
"values": {
"false": "0",
"true": "1"
}
Default is "if all else fails value", meaning that if item value can be selected into "values", we'll use this default value without sending error.
If there's no default value and item value can't be found into "values", MqttMapper will send an error and not update device.
Re: Python Plugin: MqttMapper
Posted: Friday 11 July 2025 22:28
by FlyingDomotic
Varazir wrote: Friday 11 July 2025 11:48
I see it picks up the name of the HW I have set on the name device, something I can change ?
Would be cool if I could define the icon's I like to use as well.
Icons that can be changed (meaning not forced by Domoticz like temperature) are generic to any Domoticz device.
You may change them after creating device using "Modify" button, and changing icon. Procedure is not linked to MqttMapper.
Re: Python Plugin: MqttMapper
Posted: Thursday 17 July 2025 20:35
by eddieb
playing around with MqttMapper made me really happy today ...
But,
is it possible to set the device icon in the config.json file ?
same for "Protected" ?
I only found examples of some options like LevelOffHidden
Code: Select all
"options": {"SelectorStyle":"0", "LevelOffHidden": "true", "LevelNames":"Off|normal"},
but where can I find more "options"
Re: Python Plugin: MqttMapper
Posted: Thursday 17 July 2025 21:00
by FlyingDomotic
Icons have their own life in Domoticz.
Some devices (like switches) icons can be set into device parameters.
If you don't want to use default (or use a different) one, you have to do it with a script.
Here's is a script I use to change device icons for a selector:
Code: Select all
return {
active = true,
on = {devices = {"mySelector"}},
execute = function(dz, item)
local icons = {
[0] = 140, -- Off
[10] = 137,-- Auto
[20] = 138,-- Manuel
[30] = 139,-- Vide
}
item.setIcon(icons[item.level])
end
}
Before creating it, you have find (or create) incons and install them into Domoticz, to get their id ("setup" > "more options" > "custom icons")
Re: Python Plugin: MqttMapper
Posted: Thursday 17 July 2025 23:00
by waltervl
You see in python plugins that the plugin author sets a specific own custom created icon that is attached to one ore more of the plugin managed devices.
So if the custom icon zip file is attached to the MQTTmapper plugin one could create some config option to add that custom icon to a MQTTmapper managed device.
See for example the omnik inverter plugin.
https://github.com/sincze/Domoticz-Omni ... Web-Plugin
Re: Python Plugin: MqttMapper
Posted: Friday 18 July 2025 8:02
by eddieb
tnx for the suggestions but this is not what I am looking for ...
a list of all "options" that can be used in MqttMapper.json while creating a device ...
that is not documented on the MqttMapper documentation and would be very nice to have.
Re: Python Plugin: MqttMapper
Posted: Friday 18 July 2025 9:36
by waltervl
Re: Python Plugin: MqttMapper
Posted: Friday 18 July 2025 11:58
by FlyingDomotic
waltervl wrote: Thursday 17 July 2025 23:00
You see in python plugins that the plugin author sets a specific own custom created icon that is attached to one ore more of the plugin managed devices.
So if the custom icon zip file is attached to the MQTTmapper plugin one could create some config option to add that custom icon to a MQTTmapper managed device.
See for example the omnik inverter plugin.
https://github.com/sincze/Domoticz-Omni ... Web-Plugin
I had a look to the omnik plugin , we can effectively create icons and affect them to device at creation time. However, this works only for simple devices (like on/off or open/close). Should you want to use it with a selector or change icon depending on device value, like temperature or humidity, (it seems to me that) you have to use an external script.
Re: Python Plugin: MqttMapper
Posted: Friday 18 July 2025 12:15
by waltervl
There is also the device create option Image to select an existing icon already in the database. So if the user wants to set a different icon at creation than the default this could be implemented in MQTTmapper. He should the do the getcustomiconset api call first to find the correct icon number to use. From the python plugin wiki:
Image Optional.
Set the image number to be used with the device. Only required to override the default.
All images available by JSON API call "/json.htm?type=command¶m=getcustomiconset"
Code: Select all
Domoticz.Device(Name="Volume", Unit=3, Type=244, Subtype=73, Switchtype=7, Image=8).Create()
Re: Python Plugin: MqttMapper
Posted: Friday 18 July 2025 15:31
by FlyingDomotic
eddieb wrote: Friday 18 July 2025 8:02
a list of all "options" that can be used in MqttMapper.json while creating a device ...
that is not documented on the MqttMapper documentation and would be very nice to have.
The list already exists in documentation at paragraph
https://github.com/FlyingDomotic/domoti ... rtial-list
I just updated it to integrate some missing values.
Re: Python Plugin: MqttMapper
Posted: Saturday 19 July 2025 6:22
by eddieb
tnx, this addition to the documentation is exactly what I was looking for.
I hoped that flags like "Protected" and "icon type" for a switch where setable but they are not (yet) in the list.
Re: Python Plugin: MqttMapper
Posted: Saturday 19 July 2025 8:41
by FlyingDomotic
"Options" are given "as is" to Domoticz. To add some, changes are to be done into Domoticz, not into plugin ...
Concerning "icon", you may add them to Domoticz manually, and either let it manage it directly for on/off or open/close switches, or write a small script to set different icons depending on device value (have a look to the example I posted).
Re: Python Plugin: MqttMapper
Posted: Wednesday 23 July 2025 21:30
by eddieb
I have the following json description
Code: Select all
"Modes": {
"topic": "myhome/topic/Modes",
"type": "244", "subtype": "62", "switchtype": "18",
"options": {"SelectorStyle":"0", "LevelOffHidden": "true", "LevelNames":"Off|normal|turbo|quiet"},
"mapping": {"item": "", "default": "0", "values": {"Off": "0", "normal": "10", "turbo": "20", "quiet": "30"} },
"set": {"topic": "myhome/topic/set/Modes", "retain": false}
},
which gives me

- Screenshot 2025-07-23 at 21.26.21.png (37.72 KiB) Viewed 2652 times
that is exactly what I want and it works as I expect.
Code: Select all
python checkJsonFiles.py --trace
checkJsonFiles V25.6.24-1 - Use --trace to get details
Input file(s)->['*.json']
Information analysing V1.0 file Haier.json
Warning: switchType should be 0, not 18 for type 244, sub type 62 for Modes
If I change the definition I get a different switch but not what I need ...
Of course I am the one doing something wrong, or is it the syntax checker ?
Re: Python Plugin: MqttMapper
Posted: Wednesday 23 July 2025 22:04
by FlyingDomotic
Just replace "switchtype": "18" by "switchtype": "0" in .json file...