According to this doc:
https://home-assistant.io/hassio/run_local/
The command_line platform for sensor should not work in hass.io
I recently moved from hassbian to hass.io and this example that extracts the amount of rainfall from a WEB site, to my amazement, still works!
In sensors.yaml:
- platform: command_line
name: Yesterday Rainfall
unit_of_measurement: "mm"
scan_interval: 10800
command: "python3 /config/getrain.py"
In getrain.py:
!/usr/bin/python3.4
import urllib.request
import urllib.parse
import re
import xml.etree.ElementTree as ET
from urllib import request
#Now I can make the API call.
id_request = urllib.request.urlopen('http://dd.weatheroffice.ec.gc.ca/citypage_weather/xml/BC/s0000141_e.xml')
#Let's now read this baby in XML format!
id_pubmed = id_request.read()
root = ET.fromstring(id_pubmed)
# Find the data I want
#elements are numbered with integers. Uncomment to see order of elements
#for child in root:
#print(child.tag,child.attrib)
#This is yesterday's rainfall in mm.
print(root[8][2].text)
This was a lot easier than the other methods offered in the above doc. No add-ons or MQTT involvement.
I was able to debug the python code in the IDLE environment on my Windows 10 PC and just copy it to the /config directory in hass.io
Have I found a security hole to get this working or just a simpler way to run a local python script?