Would appreciate some guidance with the following.
I am publishing the following json string over MQTT to my HA server.
‘{“json” : {“source” : “/dev/sda1”, “target” : “/”, “fstype” : “ext4”, “size” : “28G”, “avail” : “20.2G”, “used” : “6.4G”}}’
This is received correctly and I am able to extract the individual values
Client mosqsub|9750-dnsdhcp received PUBLISH (d0, q0, r0, m0, ‘sensor/dnsdhcp/drives’, … (121 bytes))
{“json” : {“source” : “/dev/sda1”, “target” : “/”, “fstype” : “ext4”, “size” : “28G”, “avail” : “20.2G”, “used” : “6.4G”}}
However I would like to concatenate the values and display as two lines, something like the following.
Volume /dev/sda1 to / as ext4
Stats 28G, 20.2G, 6.4G
I have tried the following…
- platform: mqtt
state_topic: "sensor/dnsdhcp/root"
name: "Volume"
qos: 0
value_template: >-
"{{ (value_json['json'].source) }} to {{ (value_json[json].target) }}" as {{ (value_json[json].fstype) }}
But this just produces an output of Uknown, if I just use the following for the value template
`"{{ (value_json['json'].source) }} to"`
It will display “/dev/sda1 to”
I have searched the forums and google for pointers but can’t seem to find anything that helps.
Is it possible to create a value template with concatenated json values on one single line?
Would it be possible to concatenate the two sets of values onto two lines? Or do I need to send the two sets of values as two topics?
Any suggestions greatly welcomed.