Python Plugin: MqttMapper

Python and python framework

Moderator: leecollings

Post Reply
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 »

Having the same script (just updating device idx), I got :

Code: Select all

 2024-02-04 21:40:00.442 Test MQTT: Setting Test MQTT - HBVK - Ventilator snelheid ref to >25.0<
2024-02-04 21:40:00.442 (Test MQTT - HBVK - Ventilator snelheid ref) Updating device from 0:'20.0' to have values 0:'25.0'.
2024-02-04 21:40:00.291 Status: dzVents: Info: ------ Start internal script: Script #1:, trigger: "every minute"
2024-02-04 21:40:00.359 Status: dzVents: Info: ------ Finished Script #1
2024-02-04 21:40:00.359 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2024-02-04 21:40:00.504 Status: LUA: Device based event fired on 'Test MQTT - HBVK - Ventilator snelheid ref_Utility', value '25.0'
2024-02-04 21:40:00.504 Status: LUA: Device based event fired on 'Test MQTT - HBVK - Ventilator snelheid ref', value '25.0' 
I still don't understand with a "onDeviceModified" event fires, as this should occur only when device's settings (not values) are changed.

Do you have anything else modifying this device?
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 »

Superpjeter wrote: Sunday 04 February 2024 21:44 However when I use it with another setpoint device not related to MqttMapper the dzvents script is working fine
This also works for me, but as previously said, I didn't understand why a "onDeiceModified" event is generated, as this is this event that generates reverting to previous settings.
Superpjeter
Posts: 11
Joined: Wednesday 29 August 2018 14:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by Superpjeter »

Ok, if it is working for you then it must be something on my system somewhere.
I use the latest stable Domoticz V2024.4
I can use the Lua script anyhow.
Thanks for your time
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'm not with the same version, I'm waiting a bit for things to stabilize on new versions as I'm relying on Domoticz to manage useful things in my house, and I do care about WAF ;-)

However, I made some changes to avoid the side effect you have. Could you update plugin and tell me if this solved the issue?
Superpjeter
Posts: 11
Joined: Wednesday 29 August 2018 14:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by Superpjeter »

It is working fine now.
Thank you very much.
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by pwhooftman »

I am struggling to understand the mqtt syntax and could really use some help. The examples at the mqttmapper github page lack some real payload examples for me to understand how to map the mqtt payload to domotiz devices.

This is the payload of the grottserver which spits out information about my Growatt inverter:

Code: Select all

{"device": "RX04020003", "time": "2024-02-17T11:52:04", "buffered": "no", "values": {"datalogserial": "AH24030766", "pvserial": "RX04020003", "pvstatus": 1, "pvpowerin": 5278, "pv1voltage": 2858, "pv1current": 9, "pv1watt": 2572, "pv2voltage": 3007, "pv2current": 9, "pv2watt": 2706, "pvpowerout": 5056, "pvfrequentie": 4999, "pvgridvoltage": 2374, "pvgridcurrent": 7, "pvgridpower": 1661, "pvgridvoltage2": 2345, "pvgridcurrent2": 7, "pvgridpower2": 1641, "pvgridvoltage3": 2356, "pvgridcurrent3": 7, "pvgridpower3": 1649, "pvenergytoday": 10, "pvenergytotal": 498842, "totworktime": 263661315, "pvtemperature": 224, "pvipmtemperature": 0, "epv1today": 5, "epv1total": 254644, "epv2today": 5, "epv2total": 254255, "epvtotal": 508899}}
Suppose i want to map one value "pv1voltage" to a Domoticz electricity 'usage' device, i setup this plugin.py:

Code: Select all

{
        "PV1 voltage": {
                "topic": "energy/growatt",
                "type": "248", "subtype": "1", "switchtype": "0",
                "mapping": {"item": "pv1voltage;~"}
        }
}
This gives me a 'AttributeError: 'NoneType' object has no attribute 'Name'' in the log. I think it's because this tries to map the entire payload (with 20-some values) to one attribute of the domoticz device.
But how do i construct the 'mapping' that only the pv1voltage is taken out of the payload? And if i want to extract more values from the payload string and map it to different Domoiticz devices, how do i?

Thank for any hints, just missing that crucial understanding to get further
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
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 »

Doc is always a nightmare: for those writing it, as it's hard to put everything in understandable form, for those reading it, as it's hard to try to understand what has been written ;-)

In our case, reformatting JSON may help. Here's the same payload, indented:

Code: Select all

	"device": "RX04020003",
	"time": "2024-02-17T11:52:04",
	"buffered": "no",
	"values": {
		"datalogserial": "AH24030766",
		"pvserial": "RX04020003",
		"pvstatus": 1,
		"pvpowerin": 5278,
		"pv1voltage": 2858,
		"pv1current": 9,
		"pv1watt": 2572,
		"pv2voltage": 3007,
		"pv2current": 9,
		"pv2watt": 2706,
		"pvpowerout": 5056,
		"pvfrequentie": 4999,
		"pvgridvoltage": 2374,
		"pvgridcurrent": 7,
		"pvgridpower": 1661,
		"pvgridvoltage2": 2345,
		"pvgridcurrent2": 7,
		"pvgridpower2": 1641,
		"pvgridvoltage3": 2356,
		"pvgridcurrent3": 7,
		"pvgridpower3": 1649,
		"pvenergytoday": 10,
		"pvenergytotal": 498842,
		"totworktime": 263661315,
		"pvtemperature": 224,
		"pvipmtemperature": 0,
		"epv1today": 5,
		"epv1total": 254644,
		"epv2today": 5,
		"epv2total": 254255,
		"epvtotal": 508899
	}
}
As you can see, item "pv1voltage" is not at first level, but after "values". It's name should be "value/pv1voltage" to find it. See "Item deeper in JSON message / L'item est enfoui dans le message JSON" in plugin doc.

Then, as per Domoticz's documentation (https://www.domoticz.com/wiki/Developin ... vice_Types), voltage device is type=243, subtype=8. Expected data (https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s) is voltage in floating (or integer) representation. Visibly, returned JSON data gives voltage in 1/10 of Volt, so you need to divide it by 10 to get correct Volt value. See "With multiplier / Avec Multiplicateur" in plugin doc.

Giving that, let's try with

Code: Select all

{
        "PV1 voltage": {
                "topic": "energy/growatt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pv1voltage", "multiplier": 0.1}
        }
}
Now, should you want to extract more values from the same topic, you may use the "key" keyword into definition. see "One topic/Multiple devices / Un topic/Plusieurs dispositifs" in plugin doc.

For example, adding current (type243, subtype 23), example will become:

Code: Select all

{
        "PV1 voltage": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1voltage",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pv1voltage", "multiplier": 0.1}
        },
        "PV1 current": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1current",
                "type": "243", "subtype": "23", "switchtype": "0",
                "mapping": {"item": "values/pv1current"}
        }
}
Adding frequency is a bit more complicated, as there's no frequency device in Domoticz. However, there's a custom counter (type 243, subtype 31). Axis name can be specified in options (see "Device options (partial) list / Liste (partielle) des options" in plugin doc). As described, options specifies the multiplier (here frequency is given with 2 decimals, as 4999 in you example, so we must multiply by 0.01), and unit is Hz, so options should be 0.01;Hz.

New example becomes:

Code: Select all

{
        "PV1 voltage": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1Volt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pv1voltage", "multiplier": 0.1}
        },
        "PV1 current": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1Amp",
                "type": "243", "subtype": "23", "switchtype": "0",
                "mapping": {"item": "values/pv1current"}
        },
        "PV1 frequency": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pvHz",
                "type": "243", "subtype": "31", "switchtype": "0",
                "options": {"Custom":"0.01;Hz"},
                "mapping": {"item": "values/pvfrequentie"}
        }
}
Few words about energy devices, as you may want to use them if you understand keywords meaning in JSON file. Globally speaking, they need (at least) 2 values : instantaneous consumption (in W) and global consumption (since device initialization), in Wh (even if data is shown in KWh in Domoticz).

It seems you have daily and total data in your JSON data. Don't use daily but total data (Domoticz will compute daily delta at midnight).

Hope this helps
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by pwhooftman »

Thank you very much! I came to conclusien pv1voltage being on a sublevel of values while you were writing your reply! It's so obvious once one understands :-) And thanks for the extra examples!
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by pwhooftman »

A tip for others who run into this problem: if you delete a device which was created automatically by MqqtMapper and expect MqttMapper to recreate it for you, that won't happen: an error wil be logged in Domoticz every time MqttMapper tries to run. Restart Domoticz after deleting a device created by MqttMapper, and it will recreate the device(s) and everything will work again.
Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
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.

As most of the other plugins, MqttMapper creates devices when started. It the use them. If you delete them, you have to restart MqttMapper plugin (or Domoticz which will, in turn, start it).

That said, should you change something into JSON configuration file, plugin will try to apply changes on existing device. You'll see then if Domoticz accepts or not the changes. In latter case, you may have to delete "old" device before restarting plugin, to create a new one.
pikassent
Posts: 16
Joined: Saturday 03 December 2022 16:26
Target OS: Linux
Domoticz version: 2024.4b
Location: Spain
Contact:

Re: Python Plugin: MqttMapper

Post by pikassent »

Hi FlyingDomotic,

I'm trying to manage an alert sensor via MqttMapper plugin without success. Do you know if could be possible using a config like:

Code: Select all

{
    "MqttMapperStove": {
        "topic": "tele/stove/STATE",
        "type": "243", "subtype": "22", "switchtype": "0",
        "mapping": {"item": "alert"}
    }
} 
and payloads like:

Code: Select all

{ "alert": "4;Disconnected" }
{ "alert": "0;Off" }
{ "alert": "2;Starting" }
{ "alert": "1;On" }'
{ "alert": "3;..." }
....
I didn't find how to map both nValue+sValue into the alert sensor

Thanks in advance

PS: See this post for reference
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 »

Hello,

According to https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s

Code: Select all

Alert sensor
/json.htm?type=command&param=udevice&idx=IDX&nvalue=LEVEL&svalue=TEXT
    IDX = id of your device (This number can be found in the devices tab in the column "IDX")
    Level = (0=gray, 1=green, 2=yellow, 3=orange, 4=red)
    TEXT = Text you want to display
 
This means that you should provide both level (in nValue) and text (in sValue).

Unless I do a very specific decoding for the alert sensor, the simplest way is perhaps to write the paylod into a string sensor (eventually hidden with a "$" in name's first position), and write a small script that split then data around ";" and use dzVents to send both values into an alert sensor.

So let's try:

In MqttMqpper JSON configuration file:

Code: Select all

{
    "$MqttMapperStoveState": {
        "topic": "tele/stove/STATE",
        "type": "243", "subtype": "19", "switchtype": "0",
        "mapping": {"item": "alert"}
    }
} 
Create a virtual alert device, give "Stone state" as name.

Create a dzVents script like this:

Code: Select all

return {
	on = {devices = {'$MqttMapperStoveState'}},
	execute = function(domoticz, device)
		local severity, text = device.sValue:match("([^;]+);([^;]+)") -- Split using ';'
		print('MqttMapperStove - Device ' .. device.name .. ', severity: '..severity..', text: '..text)
		domoticz.devices('Stove state').update(tonumber(severity), text)
	end
}
Test it.

Normally, a change in MQTT topic should trigger MqttMapper, which in turn will set $MqttMapperStoveState text device to received value, and script will get this value, split it, and store it the right way into the "Stove status" device.
pikassent
Posts: 16
Joined: Saturday 03 December 2022 16:26
Target OS: Linux
Domoticz version: 2024.4b
Location: Spain
Contact:

Re: Python Plugin: MqttMapper

Post by pikassent »

Hi,

Thanks a lot for your answer.
FlyingDomotic wrote: Sunday 18 February 2024 14:13 Hello,
[...]
Unless I do a very specific decoding for the alert sensor [...]
I'll stay tunned for that
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 »

pikassent wrote: Sunday 18 February 2024 17:56
FlyingDomotic wrote: Sunday 18 February 2024 14:13 Hello,
[...]
Unless I do a very specific decoding for the alert sensor [...]
I'll stay tunned for that
Not so sure it'll happen. It would mean that system generating the alert already coded it with Domoticz severity, which (IMHO) is something rare.
pwhooftman
Posts: 75
Joined: Monday 11 November 2013 18:04
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by pwhooftman »

With a big thanks to FlyingDomotic , and for future reference: this is my payload from a Growatt inverter (Growatt mqtt messages produced by Grottserver) and contents of MqttMapper.json (including messages from my Itho ventialtion unit:

I set the 243-29 device (electric + counter) to 'calculated' in Domoticz.

Code: Select all

{
  "device": "RX04020003",
  "time": "2024-02-19T17:23:51",
  "buffered": "no",
  "values": {
    "datalogserial": "AH24030766",
    "pvserial": "RX04020003",
    "pvstatus": 0,
    "pvpowerin": 0,
    "pv1voltage": 3127,
    "pv1current": 0,
    "pv1watt": 0,
    "pv2voltage": 3127,
    "pv2current": 0,
    "pv2watt": 0,
    "pvpowerout": 0,
    "pvfrequentie": 4997,
    "pvgridvoltage": 2337,
    "pvgridcurrent": 0,
    "pvgridpower": 0,
    "pvgridvoltage2": 2270,
    "pvgridcurrent2": 0,
    "pvgridpower2": 0,
    "pvgridvoltage3": 2301,
    "pvgridcurrent3": 0,
    "pvgridpower3": 0,
    "pvenergytoday": 19,
    "pvenergytotal": 498898,
    "totworktime": 263797336,
    "pvtemperature": 155,
    "pvipmtemperature": 0,
    "epv1today": 10,
    "epv1total": 254673,
    "epv2today": 10,
    "epv2total": 254284,
    "epvtotal": 508957
  }
}

Code: Select all

{
        "Growatt PV1 voltage": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1Volt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pv1voltage", "multiplier": 0.1}
        },
        "Growatt PV1 current": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1Amp",
                "type": "243", "subtype": "23", "switchtype": "0",
                "mapping": {"item": "values/pv1current", "multiplier": 0.1}
        },
        "Growatt PV2 voltage": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv2Volt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pv2voltage", "multiplier": 0.1}
        },
        "Growatt PV2 current": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv2Amp",
                "type": "243", "subtype": "23", "switchtype": "0",
                "mapping": {"item": "values/pv2current", "multiplier": 0.1}
        },
        "Growatt grid voltage 1": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1gridVolt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pvgridvoltage", "multiplier": 0.1}
        },
        "Growatt grid voltage 2": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv2gridVolt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pvgridvoltage2", "multiplier": 0.1}
        },
        "Growatt grid voltage 3": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv3gridVolt",
                "type": "243", "subtype": "8", "switchtype": "0",
                "mapping": {"item": "values/pvgridvoltage3", "multiplier": 0.1}
        },
        "Growatt PV temperature": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pvtemp",
                "type": "80", "subtype": "5", "switchtype": "0",
                "mapping": {"item": "values/pvtemperature", "multiplier": 0.1}
        },
       "Growatt PV1 watt": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv1watt",
                "type": "248", "subtype": "1",
                "mapping": {"item": "values/pv1watt", "multiplier": 0.1}
        },
       "Growatt PV2 watt": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pv2watt",
                "type": "248", "subtype": "1",
                "mapping": {"item": "values/pv2watt", "multiplier": 0.1}
        },
       "Growatt PV watt": {
                "topic": "energy/growatt",
		"key": "energy/growatt/pvpowerout",
                "type": "243", "subtype": "29", 
                "mapping": {"item": "values/pvpowerout;values/pvpowerout", "multiplier": 0.1}
        },
	"Itho Fan": {
                "topic": "itho/ithostatus",
		"key": "itho/ithostat/fanspeed",
                "type": "243", "subtype": "31", "switchtype": "0",
                "options": {"Custom":"1;RPM"},
                "mapping": {"item": "Fan speed (rpm)"}
	}


}


Domoticz v 1.16xx
1X RFXtrx433 USB 433.92MHz Transceiver Firmware version: 71
1X Synology Nas DS918+ DSM 7 (12Gb RAM mod)
User avatar
waltervl
Posts: 5152
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: MqttMapper

Post by waltervl »

pwhooftman wrote: Monday 19 February 2024 17:25 With a big thanks to FlyingDomotic , and for future reference: this is my payload from a Growatt inverter (Growatt mqtt messages produced by Grottserver) and contents of MqttMapper.json (including messages from my Itho ventialtion unit:

I set the 243-29 device (electric + counter) to 'calculated' in Domoticz.
Ideally you wanted to use the "pvenergytotal": 498898 value (or another better value) to show the total Energy created in Domoticz on the 243-29 device. Then you do not have to calculate it by Domoticz.
I do not know of that can be combined in mqttmapper to have the power come from pvpowerout and the energy from pvenergytotal.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
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 »

waltervl wrote: Monday 19 February 2024 17:35 Ideally you wanted to use the "pvenergytotal": 498898 value (or another better value) to show the total Energy created in Domoticz on the 243-29 device. Then you do not have to calculate it by Domoticz.
I do not know of that can be combined in mqttmapper to have the power come from pvpowerout and the energy from pvenergytotal.
To put more than one item into domoticz sValue, have a look at https://github.com/FlyingDomotic/domoti ... eurs-items
hjzwiers
Posts: 163
Joined: Friday 12 January 2018 8:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: MqttMapper

Post by hjzwiers »

I keep getting the following error:

2024-02-23 09:06:31.196 Error: MQTT Mapper: Call to function 'onMessage' failed, exception details:
2024-02-23 09:06:31.197 Error: MQTT Mapper: Traceback (most recent call last):
2024-02-23 09:06:31.197 Error: MQTT Mapper: File "/home/hjz/domoticz/plugins/MqttMapper/plugin.py", line 522, in onMessage
2024-02-23 09:06:31.197 Error: MQTT Mapper: _plugin.onMessage(Connection, Data)
2024-02-23 09:06:31.197 Error: MQTT Mapper: File "/home/hjz/domoticz/plugins/MqttMapper/plugin.py", line 288, in onMessage
2024-02-23 09:06:31.197 Error: MQTT Mapper: self.mqttClient.onMessage(Connection, Data)
2024-02-23 09:06:31.197 Error: MQTT Mapper: File "/home/hjz/domoticz/plugins/MqttMapper/plugin.py", line 149, in onMessage
2024-02-23 09:06:31.197 Error: MQTT Mapper: self.mqttPublishCb(topic, Data['Payload'])
2024-02-23 09:06:31.197 Error: MQTT Mapper: File "/home/hjz/domoticz/plugins/MqttMapper/plugin.py", line 354, in onMQTTPublish
2024-02-23 09:06:31.197 Error: MQTT Mapper: itemValue = self.getPathValue(message, item, '/', None) # Extract value from message
2024-02-23 09:06:31.197 Error: MQTT Mapper: File "/home/hjz/domoticz/plugins/MqttMapper/plugin.py", line 178, in getPathValue
2024-02-23 09:06:31.197 Error: MQTT Mapper: if pathElement not in element:
2024-02-23 09:06:31.197 Error: MQTT Mapper: TypeError: argument of type 'float' is not iterable

I'm trying (not so successful) to read an ebusd sensor temperature value from my MQTT file, I'm almost there but .... "T_Living" is the value I want updated, here is my MqttMapper.json file:

{
"T_Living": {
"topic": "ebusd/ctlv2/z1RoomTemp",
"type": "80", "subtype": "5", "switchtype": "0" ,
"mapping": {"item": "svalue/TEMP", "multiplier": 0.1}
}
}

Please help
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 »

This is probably due to a bad declaration somewhere.

And somewhere could be in "mapping", as I'm not so sure that "ebusd/ctlv2/z1RoomTemp" topic contains a json data with a {"sValue": {"TEMP":20.2}} format.

If topic just contain the raw data, just use

Code: Select all

"mapping": {"item": "", "multiplier": 0.1}
An empty "Item" means that value should be taken directly from topic content, without any kind of analysis.

If this is not the case, it would be nice getting the full topic content, in order to determine the right syntax.

However, I'll make a change in order to put a clearer message in this situation.
vco1
Posts: 16
Joined: Monday 12 September 2016 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python Plugin: MqttMapper

Post by vco1 »

Xenomes wrote: Friday 30 June 2023 22:18 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.
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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest