123
(Taras)
May 4, 2019, 7:24pm
21
It needs to write to ‘standard output’. In other words, if you are at the Linux command line and execute your script, it’s output should appear on the command line (‘standard output’).
Here’s an example of a command line sensor calling a python script:
I’m running the following Python command-line script:
sensor:
- platform: command_line
name: sma test
command: "python3 /config/python_scripts/sma.py"
scan_interval: 5
with following dict string as it’s output:
{ u'timestamp': u'2018-01-17 22:46:57',
u'ac_power': 15,
u'daily_yield': 277,
u'total_yield': 596969 }
Creating sensors with coresponding values:
sensor:
- platform: template
sensors:
sma_power:
value_template: "{{ states.sensor.sma_test.state…
Here’s an example using shell script but it’s the same principal.
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 upti…