Hello community,
I have created the following script after coming across an earlier posting which grabs weather information.
The script when run from a terminal using python3 executes fine and outputs the result as expected.
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
from subprocess import PIPE, run
def out(command):
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True, shell=True)
return result.stdout
url = "https://www.accuweather.com/en/au/brisbane/24741/minute-weather-forecast/24741"
my_output = out("wget -q -O- -U 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)' '{}' | awk '/minuteCastForecast = (.*);/' | sed -r 's#.*minuteCastForecast = (.*);#\\1#g'".format(url))
my_json = json.loads(my_output)
print(my_json['summary'])
print(my_json['updated'])
Executing in HA from developer tools gives two errors
“Warning loading script weatheralert.py: Line None: Prints, but never reads ‘printed’ variable.”
Is the issue with the print command? I have another script which presents the same issue.
Thanks.