Python Plugin: MqttMapper

Python and python framework

Moderator: leecollings

rocknsalsa
Posts: 6
Joined: Sunday 10 December 2017 19:17
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by rocknsalsa »

waltervl wrote: Thursday 05 September 2024 16:54
rocknsalsa wrote: Thursday 05 September 2024 9:46 @waltervl

Thanks for your comment. :D

Yes you are right, I have effectively all the associated devices created in domoticz and they are reflecting in real-time the real state of the interface.
But the problem is that domoticz sent the device command action (On/Off) in a json format ( "{value : true}" ), whereas the Balboa interface expects a raw value ( "true" ). So it does not work from domoticz to MQTT (Balboa interface).
Therefor I try the Mqtt Mapper.
If you know how to change domoticz behaviour sending a command to MQTT, you are welcome.
Or change Balboa interface that it accepts the JSON format. Perhaps a value template has to be set in the config topic
I had a look at the ruby files of the Balboa application (I am not a all familiar with ruby programming), in particular those associated with MQTT and I didn't saw any "simple" way to change to a json format.
On the other I was hoping thar the MqttMapper plugin would provide this flexibility : MqttMapper config file "mapping" parameter : When empty or ~*, mapping -> item indicates that payload is not in a JSON format".
Hansbit
Posts: 38
Joined: Monday 17 February 2014 15:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by Hansbit »

Xenomes wrote: Friday 23 February 2024 20:29
vco1 wrote: Friday 23 February 2024 10:39 Although the "dirty fix" may resolve the issue (haven't tested this), this behaviour definitely seems to be a bug in the MQTT Mapper plugin. Although I'm not an experienced plugin developer by far, I'll try to see if I can spot the issue.
Good to know: this doesn't happen with at least 2 other plugins I tested. Both based on the legacy framework.
The issue has been resolved in later versions of Domoticz.
This 'dirty fix' worked also for me! Great plugin! Installed this plugin last week and was wondering why it didn't work. After finding this post, the plugin is working, although I get the error in the log:

Code: Select all

Error: GetJSonDevices: exception occurred : 'stoll'
a few times per hour. The log doesn't mention what plugin is causing this, but is start appearing after the installation of Mqtt-Mapper. I'm on 2024.7
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Hansbit wrote: Monday 30 September 2024 14:18 This 'dirty fix' worked also for me! Great plugin! Installed this plugin last week and was wondering why it didn't work. After finding this post, the plugin is working, although I get the error in the log:

Code: Select all

Error: GetJSonDevices: exception occurred : 'stoll'
a few times per hour. The log doesn't mention what plugin is causing this, but is start appearing after the installation of Mqtt-Mapper. I'm on 2024.7
If "dirty fix" was changing plugin name to remove "LAN", the change has been done in last version of plugin.

Concerning "stoll" error in "GetJSonDevices", I'm not culprit, I don't have "GetJSonDevices" or any "stoll" conversion in MqttMapper.

To find where "stoll" error comes from, you can go into domoticz folder (probably ~/domoticz) and pass a

Code: Select all

cat plugins/*/*.py | grep stoll
to find files with this statement.
Hansbit
Posts: 38
Joined: Monday 17 February 2014 15:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by Hansbit »

(The dirty fix was installing an inactive (domoticz-zigbee2mqtt-plugin) plugin)

Solved the 'stoll' issue. This error is generated by Domoticz itself. https://github.com/domoticz/domoticz/issues/6083 This issue explains that the 'stoll'- error occurs when a (for instance a 113-) device is set with an invalid sValue.

When checking my json with the Mqtt-mapper's script dumpMqttMapperValues.py, the following error is found:

Code: Select all

Cali KM teller / dagteller
    MqttMapper: {'topic': 'weconnect/vehicles/WV2xxxxxxxxxxx/trips/longTerm/overallMileage_km', 'type': '113', 'subtype': '0', 'switchtype': '3', 'options': {'ValueQuantity': 'Distance', 'ValueUnits': 'km'}, 'mapping': {'item': ''}}
    API:  Device ID 'weconnect/vehicles/WV2xxxxxxxxxxx/trips/longTerm/overallMileage_km' not found
    Database: Name='MQTT-mapper - Cali KM teller / dagteller', Idx='2189', Type='113|0|3', nValue='0', sValue='', Color='', LastLevel='0'
    MQTT: *** 'weconnect/vehicles/WV2xxxxxxxxxxx/trips/longTerm/overallMileage_km' not seen - No 'retain' flag or don't exist ***
Due to a faulty topic, I think that Mqtt-mapper sets the 113 device with an invalid (empty?) sValue. I adjusted the topic, the dumpMqttMapperValues.py -script is happy again and the domoticz-113-device is updated again and the 'stoll' error disappeared.
Hansbit
Posts: 38
Joined: Monday 17 February 2014 15:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by Hansbit »

Another 'stoll' error and Domoticz crash this evening. Although the json is correct now, and I have set all 113 counter devices with the setting: "mapping": {"item": "", "default": "0"} hoping it would write 0 instead of 'nothing'.

Code: Select all

2024-10-01 22:44:03.500  MQTT-mapper: onMQTTPublish found weconnect/vehicles/WV2xxxxxx/domains/fuelStatus/rangeStatus/primaryEngine/remainingRange_km, Device 'MQTT-mapper - Cali Actieraduis', message ''
2024-10-01 22:44:03.501  MQTT-mapper: Setting MQTT-mapper - Cali Actieraduis to ><
2024-10-01 22:44:03.502  (MQTT-mapper - Cali Actieraduis) Updating device from 740:'740' to have values 0:''.
2024-10-01 22:44:03.507  Error: GetJSonDevices: exception occurred : 'stoll'
... and Domoticz crashed. Could I use another mapping to prevent writing 'nothing' in the sValue of a device?
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Concerning initial nValue/sValue, you have

Code: Select all

"initial": {"nvalue": xxxx}
or
"initial": {"svalue": "yyyy"}
or
"initial": {"nvalue": xxxx, "svalue": "yyyy"}
to give values to use at creation time (do nothing if you add them after device creation). You can specify whatever you want as initial value (but it's a good idea to put something related to the device you have ;-)

Concerning the error in dumpMqttMapperValues, this means that topic "weconnect/vehicles/WV2xxxxxxxxxxx/trips/longTerm/overallMileage_km" doesn't exist, either really (you made an error giving it), or has the "retain" flag not set. In the second case, you may ignore the error, or specify --wait:nn with nn corresponding to number of minutes you want to wait to see a change on that not retained topic.
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

I have a camera surveillance app (using python paho) that is communicating with domoticz v2024.7 via mqtt broker.

The camera sends status to domoticz and receives commands from domoticz via 2 topics.

I have configured MQTTmapper with a devices file (1 text device for status, 1 on/off switch for command):

{
"Pool Camera Status": {
"topic": "Pool/camera_status",
"type": "243", "subtype": "19", "switchtype": "0",
"mapping": {"item": "status"}
},
"Pool Camera Switch": {
"topic": "Pool/cmd",
"type": "244", "subtype": "73", "switchtype": "0",
"set": {"payload": {"command":"#"}},
"mapping": {"item": "command","values": {"OFF": "0", "ON":"100"}}
}
}


The plugin receives the status from the broker but says there is an MQTT protocol error ....

2024-10-04 10:03:37.154 mymqtt: 'HardwareID':'19'
2024-10-04 10:03:37.154 mymqtt: 'HomeFolder':'C:\Program Files (x86)\Domoticz\plugins\domoticz-mqttmapper-plugin-main\'
2024-10-04 10:03:37.154 mymqtt: 'StartupFolder':'C:\Program Files (x86)\Domoticz\'
2024-10-04 10:03:37.158 mymqtt: 'UserDataFolder':'C:\Program Files (x86)\Domoticz\'
2024-10-04 10:03:37.166 mymqtt: 'Database':'C:\Program Files (x86)\Domoticz\domoticz.db'
2024-10-04 10:03:37.167 mymqtt: 'Language':'en'
2024-10-04 10:03:37.167 mymqtt: 'Version':'1.0.46'
2024-10-04 10:03:37.171 mymqtt: 'Author':'Flying Domotic'
2024-10-04 10:03:37.172 mymqtt: 'Name':'mymqtt'
2024-10-04 10:03:37.173 mymqtt: 'Address':'192.168.1.143'
2024-10-04 10:03:37.181 mymqtt: 'Port':'1883'
2024-10-04 10:03:37.183 mymqtt: 'Key':'MqttMapper'
2024-10-04 10:03:37.184 mymqtt: 'Mode1':'mydevices.json'
2024-10-04 10:03:37.191 mymqtt: 'Mode6':'Verbose'
2024-10-04 10:03:37.192 mymqtt: 'DomoticzVersion':'2024.7 (build 16268)'
2024-10-04 10:03:37.193 mymqtt: 'DomoticzHash':'3bff20de4'
2024-10-04 10:03:37.195 mymqtt: 'DomoticzBuildTime':'2024-10-01 14:38:10'
2024-10-04 10:03:37.196 mymqtt: Device count: 2
2024-10-04 10:03:37.197 mymqtt: Device: 1 - ID: 320, Name: 'mymqtt - Pool Camera Status', nValue: 0, sValue: ''
2024-10-04 10:03:37.201 mymqtt: Device: 2 - ID: 321, Name: 'mymqtt - Pool Camera Switch', nValue: 0, sValue: ''
2024-10-04 10:03:37.202 mymqtt: Debug logging mask set to: PYTHON PLUGIN DEVICE CONNECTION MESSAGE
2024-10-04 10:03:37.204 mymqtt: Updating device Pool Camera Status
2024-10-04 10:03:37.204 (mymqtt - Pool Camera Status) Updating device from 0:'' to have values 0:''.
2024-10-04 10:03:37.212 mymqtt: Updating device Pool Camera Switch
2024-10-04 10:03:37.214 (mymqtt - Pool Camera Switch) Updating device from 0:'' to have values 0:''.
2024-10-04 10:03:37.246 mymqtt: MqttClient::__init__
2024-10-04 10:03:37.265 mymqtt: MqttClient::Open
2024-10-04 10:03:37.269 mymqtt: Protocol set to: 'MQTT'.
2024-10-04 10:03:37.271 mymqtt: Transport set to: 'TCP/IP', 192.168.1.143:1883.
2024-10-04 10:03:37.280 mymqtt: Connect directive received, action initiated successfully.
2024-10-04 10:03:37.281 mymqtt: Heartbeat interval set to: 60.
2024-10-04 10:03:37.349 mymqtt: MqttClient::onConnect
2024-10-04 10:03:37.353 mymqtt: Successful connect to: 192.168.1.143:1883
2024-10-04 10:03:37.366 mymqtt: MqttClient::Connect
2024-10-04 10:03:37.378 mymqtt: MQTT CONNECT ID: 'Domoticz_MqttMapper_19_1728029017'
2024-10-04 10:03:37.382 mymqtt: Sending 47 bytes of data
2024-10-04 10:03:37.383 mymqtt: 10 2d 00 04 4d 51 54 54 04 02 00 3c 00 21 44 6f 6d 6f 74 69 .-..MQTT...<.!Domoti
2024-10-04 10:03:37.393 mymqtt: 63 7a 5f 4d 71 74 74 4d 61 70 70 65 72 5f 31 39 5f 31 37 32 cz_MqttMapper_19_172
2024-10-04 10:03:37.394 mymqtt: 38 30 32 39 30 31 37 .. .. .. .. .. .. .. .. .. .. .. .. .. 8029017
2024-10-04 10:03:37.458 mymqtt: Received 4 bytes of data
2024-10-04 10:03:37.459 mymqtt: 20 02 00 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ....
2024-10-04 10:03:37.459 mymqtt: onMQTTConnected
2024-10-04 10:03:37.460 mymqtt: getTopics: '{'Pool/camera_status', 'Pool/cmd'}'
2024-10-04 10:03:37.460 mymqtt: MqttClient::Subscribe
2024-10-04 10:03:37.460 mymqtt: Sending 36 bytes of data
2024-10-04 10:03:37.460 mymqtt: 82 22 00 01 00 12 50 6f 6f 6c 2f 63 61 6d 65 72 61 5f 73 74 ¢....Pool/camera_st
2024-10-04 10:03:37.460 mymqtt: 61 74 75 73 00 00 08 50 6f 6f 6c 2f 63 6d 64 00 .. .. .. .. atus...Pool/cmd.
2024-10-04 10:03:37.523 mymqtt: Received 6 bytes of data
2024-10-04 10:03:37.526 mymqtt: 90 04 00 01 00 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю....
2024-10-04 10:03:37.528 mymqtt: Received 38 bytes of data
2024-10-04 10:03:37.528 mymqtt: 31 24 00 12 50 6f 6f 6c 2f 63 61 6d 65 72 61 5f 73 74 61 74 1$..Pool/camera_stat
2024-10-04 10:03:37.528 mymqtt: 75 73 7b 22 73 74 61 74 75 73 22 3a 20 22 75 70 22 7d .. .. us{"status":."up"}
2024-10-04 10:03:37.528 Error: (ProcessInbound) MQTT protocol violation: Invalid message length 36 for packet type '3' (iQoS:0, topicLen:4608)
2024-10-04 10:03:37.529 Error: (ProcessInbound) MQTT protocol violation, sending DisconnectedEvent to Connection.
2024-10-04 10:03:37.529 mymqtt: onMQTTSubscribed
2024-10-04 10:03:37.529 mymqtt: Disconnect event received for '192.168.1.143:1883'.
2024-10-04 10:03:37.529 mymqtt: MqttClient::onDisonnect Disconnected from: 192.168.1.143:1883
2024-10-04 10:03:37.530 mymqtt: MqttClient::Close
2024-10-04 10:03:37.536 mymqtt: onMQTTDisconnected




I have no idea what to do now.
I must admit that I am not sure how to correctly create the mqttmapper json file.
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
FlyingDomotic
Posts: 360
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 error seems not to be related to configuration (nor MqttMapper), but more receiving an invalid MQTT message from MQTT broker.

Which broker are you using?
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

I am using eclipse mosquitto V2.0.18 on windows 64bit on the domoticcz production system.
The broker is working on the domoticz production system with MQTT auto discovery without a problem and communicating with the development server for mqtt AD without a problem.
The 'status' message in the log looks well formatted to me (but i am not an mqtt protocol expert)
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Looking at Domoticz code (PluginProtocol.cpp, line 1602), it seems that topic length sent by broker is invalid (4608). Getting deeper in received message, it seems that the length field is missing from received message (and start of topic is used as topic length, giving the error). You can convince your self having a look at

Code: Select all

2024-10-04 10:03:37.460 mymqtt: 82 22 00 01 00 12 50 6f 6f 6c 2f 63 61 6d 65 72 61 5f 73 74 ¢....Pool/camera_st
2024-10-04 10:03:37.460 mymqtt: 61 74 75 73 00 00 08 50 6f 6f 6c 2f 63 6d 64 00 .. .. .. .. atus...Pool/cmd.
... where you see some dots between status and Pool/cmd, which contains the length, while

Code: Select all

2024-10-04 10:03:37.528 mymqtt: 31 24 00 12 50 6f 6f 6c 2f 63 61 6d 65 72 61 5f 73 74 61 74 1$..Pool/camera_stat
2024-10-04 10:03:37.528 mymqtt: 75 73 7b 22 73 74 61 74 75 73 22 3a 20 22 75 70 22 7d .. .. us{"status":."up"}
... doesn't contains the topic null ending value and length field between Pool/camera_Status and ["status":."up"]
Normally, the second line should be something like:

Code: Select all

2024-10-04 10:03:37.528 mymqtt: 75 73 00 00 10 7b 22 73 74 61 74 75 73 22 3a 20 22 75 70 22 7d .. .. us...{"status":."up"}
That said, it could be interesting to confirm the error using any MQTT scanning tool (like MQTT-Explorer) and see if/what kind of error is reported.

Another test you can do is to run dumpMqttMapperValues.py (in MqttMapper plugin folder), and again see what kind of error we may have.

Do you have access to sending code (probably in camera)? Is there a way to update firmware?
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

Hi
This is strange. The camera app is mine and uses the python paho client to send the status to the broker

mqttpayload=json.dumps({"status": "up"})
(rc, msgid) = mqttclient.publish(camera_name+'/camera_status', payload=mqttpayload, qos=1,retain=True)

mqtt explorer.png
mqtt explorer.png (118.4 KiB) Viewed 1138 times
Because it looked OK in MQTT explorer I assumed it was sent OK by the application
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Even stranger: you send message with QoS=1, and MqttExplorer gives a QoS=0...

What's the output of dumpMqttMapperValues.py?

What the result if you add --wait=2 in dumpMqttMapperValues command line and try to restart camera, at least to send a new message?
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

Hi
Here is the plugin log when the value changes with mqttmappervalues output. I am going to upgrade the mqtt broker to 2.0.19 to see if there is any difference.

2024-10-05 08:45:26.078 mymqtt: Reconnecting
2024-10-05 08:45:26.079 mymqtt: MqttClient::Open
2024-10-05 08:45:26.080 mymqtt: Protocol set to: 'MQTT'.
2024-10-05 08:45:26.080 mymqtt: Transport set to: 'TCP/IP', 192.168.1.143:1883.
2024-10-05 08:45:26.081 mymqtt: Connect directive received, action initiated successfully.
2024-10-05 08:45:26.137 mymqtt: MqttClient::onConnect
2024-10-05 08:45:26.137 mymqtt: Successful connect to: 192.168.1.143:1883
2024-10-05 08:45:26.138 mymqtt: MqttClient::Connect
2024-10-05 08:45:26.138 mymqtt: MQTT CONNECT ID: 'Domoticz_MqttMapper_19_1728110726'
2024-10-05 08:45:26.138 mymqtt: Sending 47 bytes of data
2024-10-05 08:45:26.138 mymqtt: 10 2d 00 04 4d 51 54 54 04 02 00 3c 00 21 44 6f 6d 6f 74 69 .-..MQTT...<.!Domoti
2024-10-05 08:45:26.138 mymqtt: 63 7a 5f 4d 71 74 74 4d 61 70 70 65 72 5f 31 39 5f 31 37 32 cz_MqttMapper_19_172
2024-10-05 08:45:26.138 mymqtt: 38 31 31 30 37 32 36 .. .. .. .. .. .. .. .. .. .. .. .. .. 8110726
2024-10-05 08:45:26.198 mymqtt: Received 4 bytes of data
2024-10-05 08:45:26.199 mymqtt: 20 02 00 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ....
2024-10-05 08:45:26.199 mymqtt: onMQTTConnected
2024-10-05 08:45:26.199 mymqtt: getTopics: '{'Pool/cmd', 'Pool/camera_status'}'
2024-10-05 08:45:26.199 mymqtt: MqttClient::Subscribe
2024-10-05 08:45:26.200 mymqtt: Sending 36 bytes of data
2024-10-05 08:45:26.200 mymqtt: 82 22 00 01 00 08 50 6f 6f 6c 2f 63 6d 64 00 00 12 50 6f 6f ¢....Pool/cmd...Poo
2024-10-05 08:45:26.200 mymqtt: 6c 2f 63 61 6d 65 72 61 5f 73 74 61 74 75 73 00 .. .. .. .. l/camera_status.
2024-10-05 08:45:26.259 mymqtt: Received 6 bytes of data
2024-10-05 08:45:26.260 mymqtt: 90 04 00 01 00 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю....
2024-10-05 08:45:26.260 mymqtt: Received 40 bytes of data
2024-10-05 08:45:26.260 mymqtt: 31 26 00 12 50 6f 6f 6c 2f 63 61 6d 65 72 61 5f 73 74 61 74 1&..Pool/camera_stat
2024-10-05 08:45:26.261 mymqtt: 75 73 7b 22 73 74 61 74 75 73 22 3a 20 22 64 6f 77 6e 22 7d us{"status":."down"}
2024-10-05 08:45:26.261 Error: (ProcessInbound) MQTT protocol violation: Invalid message length 38 for packet type '3' (iQoS:0, topicLen:4608)
2024-10-05 08:45:26.261 Error: (ProcessInbound) MQTT protocol violation, sending DisconnectedEvent to Connection.


Starting dumpMqttMapperValues V1.3.0
Reading mydevices.json
Waiting for changes for 2 minutes
Pool Camera Status
MqttMapper: {'topic': 'Pool/camera_status', 'type': '243', 'subtype': '19', 'switchtype': '0', 'mapping': {'item': 'status'}}
API: Name='mymqtt - Pool Camera Status', Idx='320', Type='General||', Data='', Color='', Level=''
Database: Name='mymqtt - Pool Camera Status', Idx='320', Type='243|19|0', nValue='0', sValue='', Color='', LastLevel='0'
MQTT: 'Pool/camera_status'='{"status": "down"}'
Pool Camera Switch
MqttMapper: {'topic': 'Pool/cmd', 'type': '244', 'subtype': '73', 'switchtype': '0', 'set': {'payload': {'command': '#'}}, 'mapping': {'item': 'command', 'values': {'OFF': '0', 'ON': '100'}}}
API: Name='mymqtt - Pool Camera Switch', Idx='321', Type='Light/Switch||', Data='Off', Color='', Level='0'
Database: Name='mymqtt - Pool Camera Switch', Idx='321', Type='244|73|0', nValue='0', sValue='', Color='', LastLevel='0'
MQTT: *** 'Pool/cmd' not seen - No 'retain' flag or don't exist ***
Error: Device '142'/'chauffe' and '135'/'chauffe' are both nammed 'Calypso Split Interface_Away Mode' - Problems likely to occur!
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

Hi again
Upgraded broker-- no change.

Changed the devices json file to have only the command device and then tried turning the switch on. Same problem!

2024-10-05 09:47:41.328 Status: mymqtt: Initialized version 1.0.46, author 'Flying Domotic'
2024-10-05 09:47:41.335 mymqtt: 'HardwareID':'19'
2024-10-05 09:47:41.338 mymqtt: 'HomeFolder':'C:\Program Files (x86)\Domoticz\plugins\domoticz-mqttmapper-plugin-main\'
2024-10-05 09:47:41.340 mymqtt: 'StartupFolder':'C:\Program Files (x86)\Domoticz\'
2024-10-05 09:47:41.340 mymqtt: 'UserDataFolder':'C:\Program Files (x86)\Domoticz\'
2024-10-05 09:47:41.341 mymqtt: 'Database':'C:\Program Files (x86)\Domoticz\domoticz.db'
2024-10-05 09:47:41.348 mymqtt: 'Language':'en'
2024-10-05 09:47:41.351 mymqtt: 'Version':'1.0.46'
2024-10-05 09:47:41.353 mymqtt: 'Author':'Flying Domotic'
2024-10-05 09:47:41.359 mymqtt: 'Name':'mymqtt'
2024-10-05 09:47:41.362 mymqtt: 'Address':'192.168.1.143'
2024-10-05 09:47:41.365 mymqtt: 'Port':'1883'
2024-10-05 09:47:41.367 mymqtt: 'Key':'MqttMapper'
2024-10-05 09:47:41.375 Status: PluginSystem: 3 plugins started.
2024-10-05 09:47:41.376 mymqtt: 'Mode1':'mydevices.json'
2024-10-05 09:47:41.380 mymqtt: 'Mode6':'Verbose'
2024-10-05 09:47:41.382 mymqtt: 'DomoticzVersion':'2024.7 (build 16268)'
2024-10-05 09:47:41.383 mymqtt: 'DomoticzHash':'3bff20de4'
2024-10-05 09:47:41.383 mymqtt: 'DomoticzBuildTime':'2024-10-01 14:38:10'
2024-10-05 09:47:41.388 mymqtt: Device count: 1
2024-10-05 09:47:41.388 mymqtt: Device: 1 - ID: 320, Name: 'mymqtt - Pool Camera Switch', nValue: 0, sValue: ''
2024-10-05 09:47:41.389 mymqtt: Debug logging mask set to: PYTHON PLUGIN DEVICE CONNECTION MESSAGE
2024-10-05 09:47:41.396 mymqtt: Updating device Pool Camera Switch
2024-10-05 09:47:41.397 (mymqtt - Pool Camera Switch) Updating device from 0:'' to have values 0:''.
2024-10-05 09:47:41.406 mymqtt: MqttClient::__init__
2024-10-05 09:47:41.407 mymqtt: MqttClient::Open
2024-10-05 09:47:41.409 mymqtt: Protocol set to: 'MQTT'.
2024-10-05 09:47:41.411 mymqtt: Transport set to: 'TCP/IP', 192.168.1.143:1883.
2024-10-05 09:47:41.413 mymqtt: Connect directive received, action initiated successfully.
2024-10-05 09:47:41.414 mymqtt: Heartbeat interval set to: 60.
2024-10-05 09:47:41.475 mymqtt: MqttClient::onConnect
2024-10-05 09:47:41.475 mymqtt: Successful connect to: 192.168.1.143:1883
2024-10-05 09:47:41.479 mymqtt: MqttClient::Connect
2024-10-05 09:47:41.480 mymqtt: MQTT CONNECT ID: 'Domoticz_MqttMapper_19_1728114461'
2024-10-05 09:47:41.481 mymqtt: Sending 47 bytes of data
2024-10-05 09:47:41.482 mymqtt: 10 2d 00 04 4d 51 54 54 04 02 00 3c 00 21 44 6f 6d 6f 74 69 .-..MQTT...<.!Domoti
2024-10-05 09:47:41.482 mymqtt: 63 7a 5f 4d 71 74 74 4d 61 70 70 65 72 5f 31 39 5f 31 37 32 cz_MqttMapper_19_172
2024-10-05 09:47:41.483 mymqtt: 38 31 31 34 34 36 31 .. .. .. .. .. .. .. .. .. .. .. .. .. 8114461
2024-10-05 09:47:41.554 mymqtt: Received 4 bytes of data
2024-10-05 09:47:41.555 mymqtt: 20 02 00 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ....
2024-10-05 09:47:41.555 mymqtt: onMQTTConnected
2024-10-05 09:47:41.556 mymqtt: getTopics: '{'Pool/cmd'}'
2024-10-05 09:47:41.556 mymqtt: MqttClient::Subscribe
2024-10-05 09:47:41.556 mymqtt: Sending 15 bytes of data
2024-10-05 09:47:41.557 mymqtt: 82 0d 00 01 00 08 50 6f 6f 6c 2f 63 6d 64 00 .. .. .. .. .. ®....Pool/cmd.
2024-10-05 09:47:41.656 mymqtt: Received 5 bytes of data
2024-10-05 09:47:41.673 mymqtt: 90 03 00 01 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю...
2024-10-05 09:47:41.681 mymqtt: Received 29 bytes of data
2024-10-05 09:47:41.687 mymqtt: 31 1b 00 08 50 6f 6f 6c 2f 63 6d 64 7b 22 63 6f 6d 6d 61 6e 1...Pool/cmd{"comman
2024-10-05 09:47:41.700 mymqtt: 64 22 3a 20 22 4f 4e 22 7d .. .. .. .. .. .. .. .. .. .. .. d":."ON"}
2024-10-05 09:47:41.704 Error: (ProcessInbound) MQTT protocol violation: Invalid message length 27 for packet type '3' (iQoS:0, topicLen:2048)
2024-10-05 09:47:41.705 Error: (ProcessInbound) MQTT protocol violation, sending DisconnectedEvent to Connection.
2024-10-05 09:47:41.712 mymqtt: onMQTTSubscribed
2024-10-05 09:47:41.725 mymqtt: Disconnect event received for '192.168.1.143:1883'.
2024-10-05 09:47:41.725 mymqtt: MqttClient::onDisonnect Disconnected from: 192.168.1.143:1883
2024-10-05 09:47:41.725 mymqtt: MqttClient::Close
mqtt explorer.png
mqtt explorer.png (49.51 KiB) Viewed 1113 times
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

What's the output of dumpMqttMapperValues.py?

What the result if you add --wait=2 in dumpMqttMapperValues command line and try to restart camera, at least to send a new message?
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

Hi
that was in my previous message before the on/off switch test
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Sorry, I missed it...

If you effectively sent a message to "'Pool/cmd" during the 2 minutes of wait of dumpMqttMapperValues.py, then we have a problem, as message has not been seen (or discarded) by Paho MQTT.

To help debugging, am I wrong if I say that you're sending commands through "Pool/cmd" and get camera state through "Pool/camera_status"?

And that the error message you got with Domoticz is at time you send a {"command": "ON"} to "Pool/cmd" with Mqtt Explorer?

Reading back previous messages, it seems that the C code you gave showing status update is running well. Does it also write to cmd?

And more generally speaking, do you have other code being able to send something to "Pool/cmd"?

FYI, as of now, it could be (one of) the program that writes to "Pool/cmd" that causes the problem.
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

The camera app only sends status updates to the status topic.
Domoticz is expected to send commands to the camera when the domoticz switch is turned off/on.

The log is when I tried to turn ON the domoticz switch which then seems to send an mqtt message to the broker which is sent to the app(succesfully) and also back to to domoticz. When domoticz received the ON message it has the protocol violation.
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
FlyingDomotic
Posts: 360
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: Python Plugin: MqttMapper

Post by FlyingDomotic »

Crystal clear!

I checked configuration file, that seems to be correct.

What happens when you click on Domoticz button? Do you have any error?

As plugin will probably crash when starting it, you may delete "Pool/cmd" topic with Mqtt-Explorer.
peterchef
Posts: 37
Joined: Sunday 03 January 2016 17:49
Target OS: Windows
Domoticz version: 2024.4
Location: France
Contact:

Re: Python Plugin: MqttMapper

Post by peterchef »

Hi,
i have done the following ...

1. Upgraded mqtt mapper to latest version
2. Set a minimal devices file

{
"Pool Camera Switch": {
"topic": "Pool/cmd",
"type": "244", "subtype": "73", "switchtype": "0",
"set": {"payload": {"command":"#"}},
"mapping": {"item": "command","values": {"OFF": "0", "ON":"100"}}
}
}

3. Stopped the camera app so that it cannot send or receive mqtt messages
4. Deleted all mqtt broker messages for pool
5. Restarted domoticz
5. Enabled plugin
6. Clicked on domoticz switch
7. PROTOCOL VIOLATION




2024-10-07 10:04:09.134 Status: mymqtt: Initialized version 1.0.48, author 'Flying Domotic'
2024-10-07 10:04:09.134 Status: EventSystem: Queue thread started...
2024-10-07 10:04:09.136 mymqtt: 'HardwareID':'19'
2024-10-07 10:04:09.149 mymqtt: 'HomeFolder':'C:\Program Files (x86)\Domoticz\plugins\domoticz-mqttmapper-plugin-main\'
2024-10-07 10:04:09.151 mymqtt: 'StartupFolder':'C:\Program Files (x86)\Domoticz\'
2024-10-07 10:04:09.152 mymqtt: 'UserDataFolder':'C:\Program Files (x86)\Domoticz\'
2024-10-07 10:04:09.152 mymqtt: 'Database':'C:\Program Files (x86)\Domoticz\domoticz.db'
2024-10-07 10:04:09.153 mymqtt: 'Language':'en'
2024-10-07 10:04:09.153 mymqtt: 'Version':'1.0.48'
2024-10-07 10:04:09.162 mymqtt: 'Author':'Flying Domotic'
2024-10-07 10:04:09.162 mymqtt: 'Name':'mymqtt'
2024-10-07 10:04:09.179 mymqtt: 'Address':'192.168.1.143'
2024-10-07 10:04:09.179 mymqtt: 'Port':'1883'
2024-10-07 10:04:09.179 mymqtt: 'Key':'MqttMapper'
2024-10-07 10:04:09.179 mymqtt: 'Mode1':'mydevices.json'
2024-10-07 10:04:09.180 mymqtt: 'Mode6':'Verbose'
2024-10-07 10:04:09.180 mymqtt: 'DomoticzVersion':'2024.7 (build 16268)'
2024-10-07 10:04:09.181 mymqtt: 'DomoticzHash':'3bff20de4'
2024-10-07 10:04:09.182 mymqtt: 'DomoticzBuildTime':'2024-10-01 14:38:10'
2024-10-07 10:04:09.182 mymqtt: Device count: 1
2024-10-07 10:04:09.182 mymqtt: Device: 1 - ID: 320, Name: 'mymqtt - Pool Camera Switch', nValue: 0, sValue: ''
2024-10-07 10:04:09.183 mymqtt: Debug logging mask set to: PYTHON PLUGIN DEVICE CONNECTION MESSAGE
2024-10-07 10:04:09.184 mymqtt: Updating device Pool Camera Switch
2024-10-07 10:04:09.184 (mymqtt - Pool Camera Switch) Updating device from 0:'' to have values 0:''.
2024-10-07 10:04:09.194 mymqtt: MqttClient::__init__
2024-10-07 10:04:09.196 mymqtt: MqttClient::Open
2024-10-07 10:04:09.198 mymqtt: Protocol set to: 'MQTT'.
2024-10-07 10:04:09.200 mymqtt: Transport set to: 'TCP/IP', 192.168.1.143:1883.
2024-10-07 10:04:09.202 mymqtt: Connect directive received, action initiated successfully.
2024-10-07 10:04:09.203 mymqtt: Heartbeat interval set to: 60.
2024-10-07 10:04:09.226 Status: PluginSystem: 3 plugins started.
2024-10-07 10:04:09.265 mymqtt: MqttClient::onConnect
2024-10-07 10:04:09.267 mymqtt: Successful connect to: 192.168.1.143:1883
2024-10-07 10:04:09.279 mymqtt: MqttClient::Connect
2024-10-07 10:04:09.284 mymqtt: MQTT CONNECT ID: 'Domoticz_MqttMapper_19_1728288249'
2024-10-07 10:04:09.294 mymqtt: Sending 47 bytes of data
2024-10-07 10:04:09.295 mymqtt: 10 2d 00 04 4d 51 54 54 04 02 00 3c 00 21 44 6f 6d 6f 74 69 .-..MQTT...<.!Domoti
2024-10-07 10:04:09.295 mymqtt: 63 7a 5f 4d 71 74 74 4d 61 70 70 65 72 5f 31 39 5f 31 37 32 cz_MqttMapper_19_172
2024-10-07 10:04:09.295 mymqtt: 38 32 38 38 32 34 39 .. .. .. .. .. .. .. .. .. .. .. .. .. 8288249
2024-10-07 10:04:09.348 mymqtt: Received 4 bytes of data
2024-10-07 10:04:09.348 mymqtt: 20 02 00 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ....
2024-10-07 10:04:09.349 mymqtt: onMQTTConnected
2024-10-07 10:04:09.349 mymqtt: getTopics: '{'Pool/cmd'}'
2024-10-07 10:04:09.350 mymqtt: MqttClient::Subscribe
2024-10-07 10:04:09.350 mymqtt: Sending 15 bytes of data
2024-10-07 10:04:09.351 mymqtt: 82 0d 00 01 00 08 50 6f 6f 6c 2f 63 6d 64 00 .. .. .. .. .. ®....Pool/cmd.
2024-10-07 10:04:09.443 mymqtt: Received 5 bytes of data
2024-10-07 10:04:09.444 mymqtt: 90 03 00 01 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю...
2024-10-07 10:04:09.445 mymqtt: Received 29 bytes of data
2024-10-07 10:04:09.446 mymqtt: 31 1b 00 08 50 6f 6f 6c 2f 63 6d 64 7b 22 63 6f 6d 6d 61 6e 1...Pool/cmd{"comman
2024-10-07 10:04:09.446 mymqtt: 64 22 3a 20 22 4f 4e 22 7d .. .. .. .. .. .. .. .. .. .. .. d":."ON"}
2024-10-07 10:04:09.447 Error: (ProcessInbound) MQTT protocol violation: Invalid message length 27 for packet type '3' (iQoS:0, topicLen:2048)
2024-10-07 10:04:09.448 Error: (ProcessInbound) MQTT protocol violation, sending DisconnectedEvent to Connection.
2024-10-07 10:04:09.448 mymqtt: onMQTTSubscribed
2024-10-07 10:04:09.449 mymqtt: Disconnect event received for '192.168.1.143:1883'.
2024-10-07 10:04:09.449 mymqtt: MqttClient::onDisonnect Disconnected from: 192.168.1.143:1883
2024-10-07 10:04:09.449 mymqtt: MqttClient::Close
2024-10-07 10:04:09.449 mymqtt: onMQTTDisconnected
2024-10-07 10:04:09.450 mymqtt: Deallocating connection object '192.168.1.143' (192.168.1.143:1883).
2024-10-07 10:04:22.957 Status: mymqtt: Stop directive received.
2024-10-07 10:04:22.961 Status: mymqtt: Exiting work loop.
2024-10-07 10:04:23.068 Status: mymqtt: Stopping threads.
2024-10-07 10:04:23.069 Status: mymqtt: Stopped.

mqtt explorer before click.PNG
mqtt explorer before click.PNG (62.56 KiB) Viewed 1069 times
Attachments
mqtt explorer after click.PNG
mqtt explorer after click.PNG (67.36 KiB) Viewed 1069 times
Windows, Domoticz
Aeotec Z-Stick Gen5, Aeotec Multisensor 6, Horstmann HRT4-ZW Thermostat Transmitter, Horstmann ASR-ZW Thermostat Receiver
Zipato Mini Keypad RFID, Everspring AN157 Plug
Post Reply

Who is online

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