So I am trying to run a script that returns the time of last boot (I know there’s a system monitor platform and resource that returns that but I don’t like the format and it comes in as a state not an attribute so I can’ reformat it)
I have this:
sensor:
# Up since
- platform: command_line
name: System Uptime
command: /config/uptimemeas.sh
scan_interval: 60
# Last Boot
- platform: command_line
name: Last Boot
command: /config/lastboot.sh
scan_interval: 600
The uptimemeas.sh works but the lastboot.sh one does not.
I’ve been looking at the Jinja manual and can’t see how to do it and as I said I have not used scripts. Doing it with the linux script was exactly what I wanted but the docker container doesn’t give me that command option which is pretty weird actually. Runs on the host but not in the docker container. Actually I probably should check in a console in the container in Portainer to be sure…
So I can create the script and then presumably an automation to run it on startup… but how do I parse the state of the sensor to the script in an automation?