New MQTT Binding Home Assistant Discovery

Hey there!

I am currently migrating my items to the new mqtt binding. I wanted to add my tasmota V6.6 (sonoff.bin; SetOption19 1) with the Homeassistant Discovery Support. I am able to add them through paper ui.

But it looks like this:

With the mqtt v1 binding i was using JSONPATH to transform the output accordingly.

Shouldn´t this already be done automagically? How can i achieve this with the actual binding?

Thanks in advance, please keep up the great work!

best wishes
Walter

In order for anybody to help more info is needed!

Which version of the binding are you using? 2.4 stable, 2.5 Milestone 1 or 2 , current snapshot?

How are those channels configured?

What does the log tell you?
Is the required JSONPATH Transformation installed?

I am sorry, i forgot to mention the version…:
openHAB 2.5.0~M3-1 (Milestone Build) running on a rasperry pi 3 with openhabian
following bindings/components are installed:
transformation-jsonpath - 2.5.0.M3 --> so yes, installed
transformation-map - 2.5.0.M3
binding-mqtt - 2.5.0.M3

i am using mosquitto(installed through openhabian-config) because whatever i tried after a reboot the embedded broker has thrown errors and stopped working (other issue)

The channels are configured with simple mode… so linking was done automatically during adding the thing through the paper ui.

regarding the logfile:
There truly seems to be something… Maybe it has sth, to do with JINJA?

2019-09-12 20:07:33.373 [vent.ItemStateChangedEvent] - mqtt_homeassistant_5381F6_5cef27a7_5381F6_5381F6_5FENERGY_5FFactor_sensor changed from {“Time”:“2019-09-12T19:02:32”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}} to {“Time”:“2019-09-12T19:07:33”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}}

2019-09-12 20:07:33.383 [vent.ItemStateChangedEvent] - mqtt_homeassistant_5381F6_5cef27a7_5381F6_5381F6_5FENERGY_5FVoltage_sensor changed from {“Time”:“2019-09-12T19:02:32”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}} to {“Time”:“2019-09-12T19:07:33”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}}

==> /var/log/openhab2/openhab.log <==

2019-09-12 20:07:33.383 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JINJA for pattern {{value_json[‘ENERGY’].Power}} not found!

2019-09-12 20:07:33.393 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JINJA for pattern {{value_json[‘ENERGY’].ReactivePower}} not found!

==> /var/log/openhab2/events.log <==

2019-09-12 20:07:33.397 [vent.ItemStateChangedEvent] - mqtt_homeassistant_5381F6_5cef27a7_5381F6_5381F6_5FENERGY_5FPower_sensor changed from {“Time”:“2019-09-12T19:02:32”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}} to {“Time”:“2019-09-12T19:07:33”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}}

==> /var/log/openhab2/openhab.log <==

2019-09-12 20:07:33.405 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service JINJA for pattern {{value_json[‘ENERGY’].Yesterday}} not found!

==> /var/log/openhab2/events.log <==

2019-09-12 20:07:33.415 [vent.ItemStateChangedEvent] - mqtt_homeassistant_5381F6_5cef27a7_5381F6_5381F6_5FENERGY_5FReactivePower_sensor changed from {“Time”:“2019-09-12T19:02:32”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}} to {“Time”:“2019-09-12T19:07:33”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}}

2019-09-12 20:07:33.423 [vent.ItemStateChangedEvent] - mqtt_homeassistant_5381F6_5cef27a7_5381F6_5381F6_5FENERGY_5FYesterday_sensor changed from {“Time”:“2019-09-12T19:02:32”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}} to {“Time”:“2019-09-12T19:07:33”,“ENERGY”:{“TotalStartTime”:“2019-09-07T19:22:27”,“Total”:0.317,“Yesterday”:0.066,“Today”:0.066,“Period”:0,“Power”:0,“ApparentPower”:0,“ReactivePower”:0,“Factor”:0.00,“Voltage”:0,“Current”:0.000}}

==> /var/log/openhab2/openhab.log <==

2019-09-12 20:07:52.507 [WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: Invalid path ‘$.Vcc’ in ‘{“Time”:“2019-09-12T19:07:52”,“Uptime”:“0T06:18:03”,“Heap”:15,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“OFF”,“Wifi”:{“AP”:2,“SSId”:“xxxx-wlan2”,“BSSId”:“00:25:9C:14:36:EF”,“Channel”:11,“RSSI”:40,“LinkCount”:1,“Downtime”:“0T00:00:10”}}’

2019-09-12 20:07:52.512 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload ‘{“Time”:“2019-09-12T19:07:52”,“Uptime”:“0T06:18:03”,“Heap”:15,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“OFF”,“Wifi”:{“AP”:2,“SSId”:“xxxx-wlan2”,“BSSId”:“00:25:9C:14:36:EF”,“Channel”:11,“RSSI”:40,“LinkCount”:1,“Downtime”:“0T00:00:10”}}’ not supported by type ‘NumberValue’

Thanks for your help!!!

The simple mode does create items for each channel automatically, of interest is how this channel is setup.
I guess no transformation is requested at all! Please post the setup of the channels on PaperUI , especially the incoming value transformation.

they look like this:

image
Channel: BlitzWolf0002 ENERGY ApparentPower
Object ID:5381F6_ENERGY_ApparentPower
Json Configuration: {“name”:“BlitzWolf0002 ENERGY ApparentPower”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_ApparentPower”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:" “,“val_tpl”:”{{value_json[‘ENERGY’].ApparentPower}}"}

and a few more:
image
Channel: BlitzWolf0002 ENERGY Today
Object ID: 5381F6_ENERGY_Today
Json Configuration: {“name”:“BlitzWolf0002 ENERGY Today”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Today”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“kWh”,“val_tpl”:"{{value_json[‘ENERGY’].Today}}"}

image
Channel: BlitzWolf0002 ENERGY Current
Object ID: 5381F6_ENERGY_Current
Json Configuration: {“name”:“BlitzWolf0002 ENERGY Current”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Current”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“A”,“val_tpl”:"{{value_json[‘ENERGY’].Current}}"}

image
Channel Name: BlitzWolf0002
Object ID: 5381F6_RL_1
Json Configuration: {“name”:“BlitzWolf0002”,“cmd_t”:"~cmnd/POWER",“stat_t”:"~tele/STATE",“val_tpl”:"{{value_json.POWER}}",“pl_off”:“OFF”,“pl_on”:“ON”,“avty_t”:"~tele/LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_RL_1”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/”}

This is the view from the Paper UI


Should i provide more information? Hope thats sufficient for the moment!

Best regards and thanks for your encouragement!

Sorry, I do not use Home Assisteant Dicovery, so I am of no help on this topic. I hope someone jumps in.

Thats from the log of the Sonoff Device after SetOption19 1:

05:21:37 MQT: homeassistant/sensor/5381F6_ENERGY_Total/config = {“name”:“BlitzWolf0002 ENERGY Total”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Total”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“kWh”,“val_tpl”:"{{value_json[‘ENERGY’].Total}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_Yesterday/config = {“name”:“BlitzWolf0002 ENERGY Yesterday”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Yesterday”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“kWh”,“val_tpl”:"{{value_json[‘ENERGY’].Yesterday}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_Today/config = {“name”:“BlitzWolf0002 ENERGY Today”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Today”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“kWh”,“val_tpl”:"{{value_json[‘ENERGY’].Today}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_Power/config = {“name”:“BlitzWolf0002 ENERGY Power”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Power”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“W”,“val_tpl”:"{{value_json[‘ENERGY’].Power}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_ApparentPower/config = {“name”:“BlitzWolf0002 ENERGY ApparentPower”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_ApparentPower”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:" “,“val_tpl”:”{{value_json[‘ENERGY’].ApparentPower}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_ReactivePower/config = {“name”:“BlitzWolf0002 ENERGY ReactivePower”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_ReactivePower”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:" “,“val_tpl”:”{{value_json[‘ENERGY’].ReactivePower}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_Factor/config = {“name”:“BlitzWolf0002 ENERGY Factor”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Factor”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:" “,“val_tpl”:”{{value_json[‘ENERGY’].Factor}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_Voltage/config = {“name”:“BlitzWolf0002 ENERGY Voltage”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Voltage”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“V”,“val_tpl”:"{{value_json[‘ENERGY’].Voltage}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_ENERGY_Current/config = {“name”:“BlitzWolf0002 ENERGY Current”,“stat_t”:"~SENSOR",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“uniq_id”:“5381F6_ENERGY_Current”,“device”:{“identifiers”:[“5381F6”]},"~":“sonoff/tele/”,“unit_of_meas”:“A”,“val_tpl”:"{{value_json[‘ENERGY’].Current}}"} (retained)
05:21:38 MQT: homeassistant/sensor/5381F6_status/config = {“name”:“BlitzWolf0002 status”,“stat_t”:"~HASS_STATE",“avty_t”:"~LWT",“pl_avail”:“Online”,“pl_not_avail”:“Offline”,“json_attributes_topic”:"~HASS_STATE",“unit_of_meas”:" “,“val_tpl”:”{{value_json[‘RSSI’]}}",“uniq_id”:“5381F6_status”,“device”:{“identifiers”:[“5381F6”],“name”:“BlitzWolf0002”,“model”:“Gosund SP1 v23”,“sw_version”:“6.6.0(release-sonoff)”,“manufacturer”:“Tasmota”},"~":“sonoff/tele/”} (retained)

as far as it seems to me the binding just took the JSON Config from the HASS Discovery Announcement as it (probably) should. But for some reason (probably not implemented by the new mqtt binding) the JSON is not interpreted as it should be.

Would be great if i could get this one to work. I have a lot of tasmota devices to migrate.

thanks in advance

I just went through much this issue as well - you had the answer in bold. JINJA transformation service required.

Install it under Add Ons - Transformations.

Thank you for that advise! I am going to give that one a look. Looks pretty much like the solution :slight_smile: