Most basic question ever


I’m almost embarrassed to ask this question but I can’t seem to get my head around the xxx amount of platforms / sensors. I’m sorry but the cookbook examples are just too much for a beginner of home-assistant … .

I want to run a python script commanded by home-assistant and am just looking for a box in my interface how to display the output of this script.
I suppose I need to do something with hass.states but don’t get the concept how such an output (string unless some conversion is needed) gets displayed on the interface.

Referring to simple basic examples works as well …

thanks …

Maybe this?

I think if you want to get the output of a python script on the front end, you should add some lines to the script to update the state of a HA sensor. I prefer just to publish the output to a mqtt topic and then setup a mqtt sensor in HA and finally put that sensor on your front end.

If you just want to run a python script as from a shell, you need

But you could use one of the command line components if you want to actuall control something

cool, did not make that link :slight_smile:, I will try to figure out the mqtt sensors and post my solution.

so, this mqtt trick indeed seems to work rather well:
if I add this to my configuration.yaml

  username: stijn
  password: *********
  discovery: true

  - platform: yr
  - platform: mqtt
    state_topic: sensor/thermostat/fubar #sensor/thermostat/fubar
    name: "time thermostat"

if I start a python script from the terminal it updates the sensor (using hassbian)

import subprocess
import schedule
import time

def thermostat_read():
    #cp =["date"],shell=True,stdout=subprocess.PIPE)
    cp =["ebusctl read Time"],shell=True,stdout=subprocess.PIPE)
    msg1="mosquitto_pub -h localhost -t sensor/thermostat/fubar -u stijn -P **** -m "

    cp =[msg1+time_read],shell=True,stdout=subprocess.PIPE)

while True:

So far so good. Now, of course I want to start/stop this script from the user interface. However if I add this shell_command, no buttons / switches etc. show up in the interface.
It doesn’t seem like adding and removing sensors happens very reliably in the interface but normally after restarts or reboots I get an updated sensor list at least, but not this time … .

  thermostat: python3 /home/homeassistant/.homeassistant/python_scripts/

any advice?