Zigbee2mqtt: configuration variable "json_attributes" is deprecated, replace with "json_attributes_topic"

Created on 11 Jan 2019  路  38Comments  路  Source: Koenkk/zigbee2mqtt

I replaced all my json_attributes with json_attributes_topic and I still get a bunch of those errors in my ha log.
I think those errors are thrown by the autodiscovered devices which most probably still use json_attributes.

Am I right? How to fix this. Will there be an update soon?

https://community.home-assistant.io/t/json-attributes-topic-json-attributes-deprecated/90652

Most helpful comment

@Koenkk PRs now submitted to home-assistant:
home-assistant/home-assistant#20190 (MQTT cover)
home-assistant/home-assistant#20191 (MQTT light)
home-assistant/home-assistant#20192 (MQTT switch)

Edit: The PRs have been merged, this will land in Home-assistant 0.87

All 38 comments

If I understand correctly json_attributes_topic is more than only a name change. What exactly did you change?

You are right. I use an example to clarify that:

old:

- platform: "mqtt" 
  name: zigbee_cube_bat
  state_topic: "zigbee2mqtt/Zigbee Cube"
  value_template: "{{ value_json.battery | round(0) }}"
  device_class: battery 
  json_attributes: 
    - "linkquality"

new:

- platform: "mqtt" 
  name: zigbee_cube_bat
  state_topic: "zigbee2mqtt/Zigbee Cube"
  value_template: "{{ value_json.battery | round(0) }}"
  device_class: battery 
  json_attributes_topic: "zigbee2mqtt/Zigbee Cube"

So it looks like with this it isn't possible any more to chose which attributes you want to add, because this will add all of the attributes. Even the one that is already chosen for the value_template.

Yes, what happens with the battery in this case? Is that also added as a json attribute? (because it's also the value of the sensor itself)

The state of the battery will be shown as state and as an attribute.

I added a picture here:
https://community.home-assistant.io/t/json-attributes-topic-json-attributes-deprecated/90652

I liked the solution before better, but it seems like we have to live with that (because json_attributes is deprecated)

Yes, it even get's worse when you think of e.g. the xiaomi weather sensor, which has 4 sensors (humidity, temperature, pressure, battery). All these 4 sensors will have the humidity, temperature, pressure and battery as a json attribute.

@emontnemery could you perhaps clarify why this change was made?

That's really annoying. Hopefully there will be a satisfying solution.

By the way: I remember another topic about binary_sensors and json_attributes. Json_attributes where not supported by binary_sensors. With json_attributes_topic now it looks like this is added. Maybe this is the reason for the change?
https://www.home-assistant.io/components/binary_sensor.mqtt/

how do i fix this i have zigbee2mqtt with autodiscovery so i dont have the yaml

Fixed in the dev branch, can we close this issue?

Looks like this fix only deletes the Jason attributes?
Am I right? This would mean attributes are gone? Not really a step forward, right?

@Koenkk I opened a PR to add support for json_attributes to MQTT binary sensor, and balloob (Home Assistant owner) requested to instead add support for a json_attributes_topic and also do the same change to MQTT sensor.
The difference is that json_attributes_topic doesn't allow cherry picking the keys in the JSON dict,
Apparently this had been discussed several times before in the hass community, and my PR was the last drop.

Edit: I saw this has already been fixed by now, I'm sorry for the slow response.. :)

@emontnemery thanks for letting us know

@h4nc it has been replaced with json_attributes_topic

@Koenkk can't see that it has been replaced here:
https://github.com/Koenkk/zigbee2mqtt/commit/6912f8108d034b5233b00e834180a7cdf66b339c
This only looks like it was removed.

@emontnemery so cherrypicking will not be available any more? Are there plans to readd this?

@h4nc its added dynamically based on the type https://github.com/Koenkk/zigbee2mqtt/commit/6912f8108d034b5233b00e834180a7cdf66b339c#diff-0c056233b68fd3653afb296f98947c8fR516

Do you know how long it usually takes to get this changes to the hassio addon?

Same issue here with hassio , hope the changes will be made as soon as posible . Great job Koenkk .

@Koenkk would it be useful to have json_attrubutes_topic enabled also for other platforms than sensor and binary_sensor?

@emontnemery yes! E.g. lights also have a linkquality which is currently not shown.

@h4nc @jonydebu please use the latests -edge hassio addon.

@Koenkk Can you list the platforms you need it for, and I'll try to get it done within the next couple of weeks. Another way would be to create a sensor only with the additional statistics and link it with the real device through device.identifier. I.e. for each device create a real entity (switch, light, sensor) and an additional sensor entity only with the stats.

@emontnemery light, switch, cover

@Koenkk I'm afraid if i switch to etch I will have to reconfigure all my sensors again. I'm not sire about that. This would be a lot of work (many sensors). Is there an easy way to switch?

EDIT: Done. Installed Edge. Stopped "normal" addon. And works as before. Did not have to reconfig sensors (it stores the config in the same folder).

@Koenkk PRs now submitted to home-assistant:
home-assistant/home-assistant#20190 (MQTT cover)
home-assistant/home-assistant#20191 (MQTT light)
home-assistant/home-assistant#20192 (MQTT switch)

Edit: The PRs have been merged, this will land in Home-assistant 0.87

I use Hassio Supervisor 142 with HA v. 0.85.1
it show me "configuration variable "json_attributes" is deprecated, replace with "json_attributes_topic""
I suppose I have to wait a upgrade of zigbee2mqtt to solve the problem...

This is already solved in edge (dev addon).

You can easily switch to edge or wait for an update.

must I replace addon zigbee2mqtt with zigbee2mqtt-edge?

yes, i did this some days ago.

1) stop zigbee2mqtt
2) copy your config (in zigbee2mqtt addon)
3) install zigbee2mqtt-edge
4) paste your config in zigbee2mqtt-edge
5) start zigbee2mqtt-edge
6) everything should work as before

don't forget to disable autostart of zigbee2mqtt

Thank you for all the good work!

When will this patch be be available in the stable branch?

@hawaltie when zigbee2mqtt 1.1 is released, expected end of the month.

Thanx. Then I'll just have to be patient.

I have these errors in my homeassistant logs too. I'm running latest HA (docker, 0.87.0), latest zigbee2mqtt (docker, 1.1.1-arm32v6 ) and latest z-stack firmware (CC2531ZNP-Prod_20190109.zip). I don't have any files with "json_attributes" so i'm kinda lost. I just tried the arm32v6-dev zigbee2mqtt docker image but I still have these errors.
Any idea's?
Thanks

@lassieee you should clear the retained messages from your MQTT broker.

Thanks @Koenkk . I ended up deleting mosquitto.db and all my troubles went away :-)
Thank you very much for this awesome project 馃

@Koenkk I'm a bit confused with this. Could you clarify whether we need to do something when we see warning messages like this
[homeassistant.components.mqtt.sensor] configuration variable "json_attributes" is deprecated, replace with "json_attributes_topic"
pop up in HA log file?
I really tried to understand the conclusions here but I'm not sure.
I would appreciate it if you clarified this.
Thanks

@marcgarciamarti you need to clear the retained MQTT messages. (e.g. for mosquitto: https://community.openhab.org/t/clearing-mqtt-retained-messages/58221)

@lassieee @Koenkk I also deleted the mosquitto database file. But now I get these error messages in mosquitto addon logs:

1552246264: |-- aclcheck(zepixir, zigbee2mqtt/+/+/+/set, 4) CACHEDAUTH: 0
1552246264: |-- mosquitto_auth_acl_check(..., client id not available, zepixir, zigbee2mqtt/+/+/+/get, MOSQ_ACL_WRITE)

Zigbee2mqtt addon logs says it is connected to the server. But nothing of my zigbee devices automations works. The devices are also unavailable in homeassistant integrations under mqtt.

Anything you experienced?

Did you restart zigbee2mqtt afterwards?

@Koenkk yes, tried to restart the zigbee2mqtt (edge version), and restartet my intel nuc 2 times without luck. I could find the new mosquitto.db file after I reinstalled the mosquitto add-on.

Can you provide the zigbee2mqtt log when it publishes MQTT messages?

@Koenkk the problem was with the update of mosquitto addon from v4 to v4.1. No problem with v4.

Was this page helpful?
0 / 5 - 0 ratings