Page 22 of 26

Re: Python Plugin: MqttMapper

Posted: Tuesday 28 October 2025 19:12
by hjzwiers
Yes I had already upgraded the git file and I'm running from the newest domoticz.

But the trick was from FlyingDomotic, it worked.
I will watch my mqtt file it sometimes changes, for now its fixed! Thanks!

Re: Python Plugin: MqttMapper

Posted: Tuesday 28 October 2025 19:22
by FlyingDomotic
Using

Code: Select all

"item":""
means "load the full message into domoticz device". It's useful when :
  • message contains only one value, in raw format
  • message is something complex, is written "as is" into a domoticz text device, and analyzed by some LUA/dzVents script
If this worked previously, there's a (good) chance that json format/content changed.

Re: Python Plugin: MqttMapper

Posted: Wednesday 29 October 2025 23:26
by JeroenUnimog
Very nice plugin!
Reading a MQTT topic with text into Domoticz works fine.
But I can“t get posting a text back into an MQTT topic to work.

MqttMapper.json:

Code: Select all

{
    "Kilometers_EX40": {
        "topic": "house/kms-rijden",
        "type": "243", "subtype":"19","switchtype":"0",
        "mapping":{"item":"svalue"},
        "set": {"topic": "house/kms-rijden/set", "payload": {"svalue":"#"}, "retain": true}
        }
}
The "set" part is not executing.
I also tried "commands" but without succes.
Any suggestions?
Regards, Jeroen

Re: Python Plugin: MqttMapper

Posted: Friday 31 October 2025 16:45
by hjzwiers
FlyingDomotic wrote: Tuesday 28 October 2025 18:54 If received data is

Code: Select all

{"value":{"value": 30.0}}
then "item" should be

Code: Select all

"item": "value/value"
Sometimes MQTT Explorer shows the file this way, but sometimes is shows it without all the quotation marks, how can I sent this in Explorer of is there a setting in which I can influence the way MQTT file is written?

This causes my readout to fail

Re: Python Plugin: MqttMapper

Posted: Friday 31 October 2025 19:58
by waltervl
The application that writes the MQTT message defines the way the value is sent to MQTT. So you have to check that application. What application is it?

Re: Python Plugin: MqttMapper

Posted: Friday 31 October 2025 20:41
by hjzwiers
The messages are from an ebusd application, I will check it out

Re: Python Plugin: MqttMapper

Posted: Friday 31 October 2025 23:17
by hjzwiers
hjzwiers wrote: Friday 31 October 2025 20:41 The messages are from an ebusd application, I will check it out
I am running it from dockge with the following file:

Code: Select all

services:
  ebusd:
    image: john30/ebusd
    container_name: ebusd
    restart: unless-stopped
    ports:
      - 8888:8888
    environment:
      EBUSD_DEVICE: ens:192.168.2.99:9999
      EBUSD_SCANCONFIG: Full
      EBUSD_MQTTHOST: 192.168.2.71
      EBUSD_MQTTPORT: "1883"
      EBUSD_CONFIGLANG: en
      EBUSD_MQTTINT: /etc/ebusd/mqtt-hassio.cfg
      EBUSD_LOGFILE: /var/log/ebusd.log
networks: {}
I added EBUSD_MQTTJSON: "" to the settings, see if it helps

Re: Python Plugin: MqttMapper

Posted: Friday 31 October 2025 23:24
by waltervl
So if ebusd sometimes sends in the message

Code: Select all

{"value":{"value": 30.0}}
and sometimes

Code: Select all

{value:{value: 30.0}}
Then this seems some bug in ebusd. Do you see this behavior on more messages coming from ebusd?

Re: Python Plugin: MqttMapper

Posted: Saturday 01 November 2025 0:03
by hjzwiers
No, but I actually only readback from ebusd.

I don't see the exact message now, but if it happens i will write it here

I've also added EBUSD_MQTTJSON: "" to the settings, don't know if that will make it more consistent

Re: Python Plugin: MqttMapper

Posted: Saturday 01 November 2025 10:44
by FlyingDomotic
A message like

Code: Select all

{value:{value: 30.0}}
is definitely NOT a valid JSON message.

As said earlier in this thread, should you receive one like this, you should contact people that wrote code generating the message to ask for a valid content (probably easier to tell than to do).

If you can't fix the problem at source, you may always ask MqttMapper to write it "as is" in a Domoticz text device, and write your own LUA/dzVents script to manually decode all flavor of message.

Re: Python Plugin: MqttMapper

Posted: Tuesday 11 November 2025 13:10
by hjzwiers
I think i fixed it with " EBUSD_MQTTJSON: "" " in the settings.

Thanks

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 0:14
by roseen
I have a button (this one: https://www.tindie.com/products/plab/home-buttons/) that supports HA Autodiscover, but I haven't got it to work with the Autodiscover Gateway in Domoticz. So I decided to go bare bones and use MqttMapper instead.

However, the button sends the payload "PRESS" everytime it is pressed.
I would like to set up a switch that gets toggled everytime that message is received.

I have a config that can go from "0" to "1" when I press, but then it will be stuck in "1".
Is it even possible to configure MqttMapper to toggle the switch instead of setting a fixed value?

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 1:14
by FlyingDomotic
As of now, there's no toggle button on Domoticz...

However, what you can do is to create a push-on switch (which indeed is what you have) and write a small script to toggle a virtual switch.

You may eventually find help here if needed.

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 13:06
by roseen
FlyingDomotic wrote: Saturday 22 November 2025 1:14 However, what you can do is to create a push-on switch (which indeed is what you have) and write a small script to toggle a virtual switch.
Yes, I was thinking of how the web API has the option to send the value "toggle" to a switch, and was hoping that the same existed in the plugin API.
https://wiki.domoticz.com/Domoticz_API/ ... tch_on/off

Can you think of a better way to do it than a curl call to the web API?

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 14:15
by roseen
(If I'm spamming the topic, please say so, and I'll go ask elsewhere)

Is there a way to send a command on an incoming message?
Instead of only when the event is triggered from Domoticz?

I have something that works half way:

Code: Select all

{
        "Home Button 1": {
                "topic": "homebuttons/knapp/button_1",
                "type": "244", "subtype": "73", "switchtype": "0",
                "mapping": {"item": ""},
                "commands": {
                        "<default>": {"topic": "domoticz/in", "payload": {"command": "switchlight", "idx": 28, "switchcmd": "Toggle" }, "retain": true}
                }
        }
}
The command works nicely when I click "Home Button 1" in the Domoticz UI, toggling the switch. Now I would like it to be sent on an incoming mqtt message, basically translating from topic "homebuttons/knapp/button_1" to "domoticz/in"...

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 14:46
by FlyingDomotic
Giving a MqttMapper push on button named "PushOn" and a virtual device named "CommandedDevice", write this dzVents script:

Code: Select all

return {
	on = {devices = {'PushOn'}},
	execute = function(domoticz, device)
	    commanded = domoticz.devices("CommandedDevice")
		if commanded.active then
		    commanded.switchOff()
		else
		    commanded.switchOn()
		end
	end
}
Commanded device state will change each time push on button is pressed.

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 16:51
by roseen
FlyingDomotic wrote: Saturday 22 November 2025 14:46 Giving a MqttMapper push on button named "PushOn" and a virtual device named "CommandedDevice", write this dzVents script:
...
That one works perfectly, thanks!

Re: Python Plugin: MqttMapper

Posted: Saturday 22 November 2025 17:01
by FlyingDomotic
We're never protected against chance...

Re: Python Plugin: MqttMapper

Posted: Wednesday 07 January 2026 19:33
by NvBgm
Can anyone help me with the MQTT Mapper?
I've installed the plugin and it works fine. Now I want to import a value from the MQTT broker, which works fine to a certain extent. The correct meter is created.
But I don't get the value; it stays at zero.
In the MQTT Explorer, I see 38 under 'Value'. The value in the MQTT Explorer isn't in JSON format. It should display it with the code below.

Code: Select all

{
    "Waterverbruik": {
        "topic": "p1monitor/watermeter/day/watermeter_consumption_liter",
		"type": "243", "subtype": "33",  "switchtype": "2",
        "mapping": { "item": "" }
    }
}
In the logfile of Domoticz i get:

MqttClient::Subscribe to [{'Topic': 'p1monitor/watermeter/day/watermeter_consumption_liter', 'QoS': 0}]

Look at the end. this is not the value i looking for.. 'QoS': 0

Re: Python Plugin: MqttMapper

Posted: Wednesday 07 January 2026 20:05
by janpep
I found this plugin. Using cam2mqtt in docker and this plugin in Domoticz, I managed to pass "AI person detection" from my camera to Domoticz.
Thanks so much!