How do I get python output in ha

I’m brand new when it comes to python. But I can figure it out if some one wouldn’t mind giving me a little direction here.

I have a python script on the same box as ha that pulls data from nfl(game and player stats along with real time play by play and scores) I’d love to be able to make some automations with this. How can I get the output of this script into ha to be able to use for automations?

Thanks

EDIT: the data is actually going into a postgres db and I’m running queries. The script is just updating the db. So I guess I really need to run queries an get that output in ha.

You can use the Command line Sensor for it.

EDIT: Here’s an example running queries on a mysql db.

trying to have this script in HA but not knowing python. somebody can help setting values of min/max/mean to a sensor not to print as in below script ?

import json
import urllib.request
import pprint
data = urllib.request.urlopen("http://www.meteoromania.ro/wp-json/meteoapi/v2/starea-vremii").read()
output = json.loads(data)


all_temp_values = [float(i["properties"]["tempe"]) for i in output["features"]]
max_result = [i for i in output["features"] if i["properties"]["tempe"] == str(max(all_temp_values))]
min_result = [i for i in output["features"] if i["properties"]["tempe"] == str(min(all_temp_values))]


print("----------------------------Max temperature result---------------------------------------")
pprint.pprint(max_result[0]["properties"])
print("----------------------------Min temperature result---------------------------------------")
pprint.pprint(min_result[0]["properties"])

print("====================================================================")
average = sum(all_temp_values) / len(all_temp_values)
average_rounded = round(average, 1)
print("Temperatura medie in tara este: %.1f grade celsius" % average_rounded)

print("====================================================================")
print("Valoare maxima de %.1f grade se afla in %s" % (float(max_result[0]["properties"]["tempe"]), max_result[0]["properties"]["nume"]))
print("Valoare minima de %.1f grade se afla in %s" % (float(min_result[0]["properties"]["tempe"]), min_result[0]["properties"]["nume"]))
print("====================================================================")
print(max_result[0]["properties"]["nume"] + "==" + max_result[0]["properties"]["tempe"])
print(min_result[0]["properties"]["nume"] + "==" + min_result[0]["properties"]["tempe"])

Posted in wrong thread…