Hi there,
I’m triyng to configure MQTT sensors and got problems with attributes.
I carefully read documentation to create attributes and extract value, but even the provided examples does not work: when extracting attibute I got message
“WARNING (MainThread) [homeassistant.components.mqtt.mixins] Erroneous JSON: None”
and attribute not shown.
- platform: mqtt
name: "RSSI"
state_topic: "home/sensor1/infojson"
unit_of_measurement: "dBm"
value_template: "{{ value_json.RSSI }}"
json_attributes_topic: "home/sensor1/attributes"
json_attributes_template: "rssi:{{ state_attr('sensor.rssi', 'ClientName') }}"
Node Red flow used to send data
[{"id":"f182e1bb.b82e2","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"b26bcb3.d9d0838","type":"inject","z":"f182e1bb.b82e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":579,"y":96,"wires":[["bf2f028b.5716a","e50ef35.d428a1"]]},{"id":"bf2f028b.5716a","type":"function","z":"f182e1bb.b82e2","name":"StatePayload","func":"msg.topic=\"home/sensor1/infojson\"\nmsg.payload={\"ClientName\": \"Client\", \"IP\": \"IP\", \"MAC\": \"MAC\", \"RSSI\": \"17\", \"HostName\": \"Host\", \"ConnectedSSID\": \"SSID\"}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":759,"y":96,"wires":[["77979987.c56388","7860a32b.9414cc"]]},{"id":"77979987.c56388","type":"mqtt out","z":"f182e1bb.b82e2","name":"Send conf for volume","topic":"","qos":"0","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"66e1f27a.12f31c","x":1099,"y":76,"wires":[]},{"id":"e3b60056.3a483","type":"mqtt out","z":"f182e1bb.b82e2","name":"","topic":"","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"66e1f27a.12f31c","x":1019,"y":176,"wires":[]},{"id":"e50ef35.d428a1","type":"function","z":"f182e1bb.b82e2","name":"AttributesPayload","func":"msg.topic=\"home/sensor1/attributes\"\nmsg.payload={\"ClientName\": \"NOM du client\", \"IP\": \"IP\", \"MAC\": \"MAC\", \"RSSI\": \"RSSI\", \"HostName\": \"Host\", \"ConnectedSSID\": \"SSID\"}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":779,"y":176,"wires":[["e3b60056.3a483","cba5637b.5e836"]]},{"id":"7860a32b.9414cc","type":"debug","z":"f182e1bb.b82e2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1069,"y":136,"wires":[]},{"id":"cba5637b.5e836","type":"debug","z":"f182e1bb.b82e2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1069,"y":236,"wires":[]},{"id":"66e1f27a.12f31c","type":"mqtt-broker","name":"MQTT","broker":"192.168.1.32","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"/douche","birthQos":"0","birthRetain":"false","birthPayload":"{\"Hello\"}","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
I could create one sensor by attributes but I have about 10th and like to use attributes instead of state, ultimately I’d like doing it using MQTT discovery, but one step after the other, I’d like first understand why it does not work and how is should configure manually.
Any helps appreciated;