Hi,
I would like to extract the attributes from a Tinkerforge MQTT sensor.
The sensor has two channels with two different values on the respective channel.
The MQTT payload actually looks quite simple.
The only problem is that the payload is not sent in an array, but the values change every 5 seconds in the JSON message
#payload by start
{"channel": 0, "current": 6879635}
#payload after 5 seconds
{"channel": 1, "current": 4987106}
#payload after 10 seconds
{"channel": 0, "current": 6879541}
#payload after 15 seconds
{"channel": 1, "current": 4987368}
#etc....
How can I split the respective “current” values into individual attributes?
My current config.yaml looks like this.
- name: "Kollektor"
state_topic: "tinkerforge/callback/industrial_dual_0_20ma_v2_bricklet/2191/current"
state_class: "measurement"
device_class: "current"
unit_of_measurement: "mA"
unique_id: "tf_mA_2191"
value_template: '{{ value_json.current }}'
json_attributes_topic: "tinkerforge/callback/industrial_dual_0_20ma_v2_bricklet/2191/current"
force_update: 'true'
device:
identifiers: 'TF mA Eingänge 2191'
name: 'TF mA Eingänge 2191'
manufacturer: 'Tinkerforge'
model: 'industrial_dual_0_20ma_v2_bricklet'
serial_number: '2191'
This is the corresponding MQTT documentation of the Tinkerforge sensor:
https://www.tinkerforge.com/en/doc/Software/Bricklets/IndustrialDual020mAV2_Bricklet_MQTT.html