Moving everything to the new command_line structure and something that has worked now doesn’t. I’m reading statistics from my unifi controller using this:
- sensor:
name: udm_unifios
command: !secret udm_unifios
value_template: |-
{% set json = value_json.data[0] %}
{{ json["system-stats"].cpu }}|
{{ json.temperatures[1].value | round(1) }}|
{{ json["system-stats"].mem }}|
{{ ((json.storage[1].used / json.storage[1].size) * 100) | round(1) }}|
{{ json.internet }}|
{{ json.startup_timestamp | timestamp_local }}|
{{ json.displayable_version }}|
{{ json.upgradable }}
scan_interval: 120
And it does not like the line:
{% set json = value_json.data[0] %}
I’m getting this error:
Error loading /config/configuration.yaml: while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/include/command_line.yaml”, line 18, column 8
Does the value_template work differently in the command_line integration or am I just completely wrong in assuming it ever worked?
P.S. Tested and receiving valid JSON:
{
"meta": {
"rc": "ok"
},
"data": [
{
"port_table": [
{
"port_idx": 1,
"speed_caps": 1048623,
"op_mode": "switch",
"forward": "all",
"attr_no_edit": true,
"autoneg": true,
"enable": true,
"flowctrl_rx": false,
"flowctrl_tx": false,
"full_duplex": true,
"is_uplink": true,
"jumbo": false,
etc