Command_line sensor value_template string help

I have this sensor

sensor:
  - platform: command_line
    name: MoLast
    command: "cat /usr/share/hassio/homeassistant/tmp/last.mo"
    value_template: '{{value_json.val}}'

The value when I cat that file was
F:19/05-1512
but when I failed to render that value to lovelace without a value_template line, I added the json value_template and I json-ified the file contents, grasping at straws. Now it is this
{“val”: “F:19/05-1512”}
Now in the debug log HA isn’t executing it every 60 seconds and the badge and sensor card show nothing. Just this one reference.

2020-05-19 15:14:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.molast, old_state=None, new_state=<state sensor.molast=unknown; friendly_name=MoLast @ 2020-05-19T15:14:15.613677-07:00>>

I just want to cat a file with a string and show the string in the UI, basic stuff. As I get further along with HA, it just brings me to my knees. Thanks

sensor:
  - platform: command_line
    name: MoLast
    command: "cat ./tmp/last.mo"
    value_template: '{{value_json.val}}'

This should works :wink:

1 Like

it does. Genius !