jq doesnt seem to care. Good for you
sensor:
- platform: command_line
name:
command: curl -s 'http://SMART_METER_IP/inst.json' | jq .type_imp_0
scan_interval: 60
you can do a lot with the command sensor - I query my local transporter wit it.
# https://www.data.gv.at/katalog/dataset/add66f20-d033-4eee-b9a0-47019828e698
# data.wien.gv.at' Lizenz (CC BY 3.0 AT)
# the comand is as following:
# curl -s 'http://www.wienerlinien.at/ogd_realtime/monitor?rbl=******STOP-HERE******&sender=*****API-KEY-HERE*****' | jq '.data.monitors' | jq '.[].lines' | jq '.[].towards, .[].departures.departure' | sed -n '1!p' | jq '.[]' | jq '(.departureTime.countdown)' | tr '\n', ',' | sed -e 's/^/[/' -e 's/,$/]/' | jq '{next: .[0], seccond: .[1], third: .[2], fourth: .[3]}'"
sensor:
- platform: command_line
name: !secret wienerlinien_name_W_I #A
command: !secret wienerlinien_curl_W_I
scan_interval: 59
value_template: '{{ value_json.next }}, {{ value_json.seccond }}, {{ value_json.third }}'
json_attributes:
- next
- seccond
- third
- fourth
example to test (wienerlinien_curl_W_I)
curl -s 'https://raw.githubusercontent.com/Underknowledge/HomeAssistant-and-Jinja-fun/master/example_wienerlinien.json' | jq '.data.monitors' | jq '.[].lines' | jq '.[].towards, .[].departures.departure' | sed -n '1!p' | jq '.[]' | jq '(.departureTime.countdown)' | tr '\n', ',' | sed -e 's/^/[/' -e 's/,$/]/' | jq '{next: .[0], seccond: .[1], third: .[2], fourth: .[3]}'
output
"next": 2,
"seccond": 8,
"third": 10,
"fourth": 15
}
just tested with cat
cat ha_com.json | jq '{next: .label_entree1, seccond: .isousc, third: .conso_hc_w, fourth: .entree_imp3_disabled}'