Generic empty sensor

I’m trying to populate a sensor from appdaemon automation (only from the automation) and can’t find an appropriate sensor. On the forum, someone suggested that I can create a sensor just by calling set_state() from an appdaemon script and that works but it has a couple of drawbacks:

  1. The sensor disappears with each restart and doesn’t come into existence until the automation writes it.
  2. Customization via customize.yaml doesn’t work due to 1)
  3. The name of the sensor doesn’t conform to the current convention (it has no capital letters)

The closest sensor type that I have found is the command line sensor with a nonsense command that will fail and not replace the current value of the state of the sensor. This works but has the drawback of causing an error event every time the command is tried.

What I’d like to see is a sensor much like command line sensor only it never executes a command. Its initial state would be undefined (shows a “-” in the GUI) and it uses the usual attributes like icon, friendly name, etc. It seems like the documentation for this new sensor would take longer to create than the code since the code could be cloned from some other basic sensor like command line.

Maybe this custom component is something for you?

Thanks! This looks great.

I downloaded the variable.py file from gituhub, created a custom_components folder in my configuration directory, and placed variable.py there. I then added a sample variable component per your tutorial. However, it doesn’t work:

2018-04-29 13:18:46 ERROR (Thread-17) [homeassistant.loader] Unable to find component variable
2018-04-29 13:18:46 ERROR (MainThread) [homeassistant.components] Component not found: variable

My component is:

variable:
  kitchen_door_counter:
    value: 0
    attributes:
      friendly_name: 'Kitchen Door Counter'
      icon: mdi:counter

Not my tutorial. :slightly_smiling_face:
The component works for me very well.
Have you tried copy and pasting the variable.py in raw mode on github?