I’ve been using entity-controller for a while, and have been really stretching it beyond what it was designed to do. I’ve built my own jinja templating system and have written a lot of macros.
You can see some of the crazy stuff I’ve been building here: home-assistant-config/packages at main · ndbroadbent/home-assistant-config · GitHub
I wrote a script that compiles all of my .yaml.jinja
templates, and this runs as a systemctl service that watches my config directory. So whenever I make a change to a .yaml.jinja
file, it gets compiled into a .yaml
file. And if something goes wrong, the error logs show up in my text editor. It’s pretty handy!
One of the most useful things about this workflow is that I can add assertions to catch any missing entity_ids. When running the compilation script manually, I also run the watchman.report
service to do a final check for any missing entities, and print the results. (I highly recommend Watchman. I found a lot of broken automations and Node-RED flows that I didn’t know about.)
Anyway, I’ve had to come up with some crazy workarounds to get entity-controller doing what I want it to do. For example, creating “change” sensors for doors and lights that only turn on for a few seconds (generated automatically from a template.) This means that all of my entity controllers can be configured as “duration” sensors.
I recently set up ESPresence and have placed ESP32s in rooms all around my house, so I have room presence detection working with our phones and watches. So now I feel like things are about to get really crazy.
I really want to start setting this up in a more declarative way. I’ve assigned entities and devices to “Areas” in Home Assistant, and I want to be able to use this information to automatically set up all the automations, entity controllers, and presence rules.
A minimal example of what I would like to be able to do:
- The following devices are all assigned to the
Nathan's Office
area in Home Assistant:Nathan’s Office Lights
Nathan's Office Motion Sensor
Nathan's Office Door Contact Sensor
Nathan's Office Heater Thermostat
- The
Nathan's Office
room is configured in ESPresence
So there should be enough information here to set up all my automations and timers without any further configuration, just by looking at the areas and devices that are already configured in Home Assistant.
Examples:
- If
Nathan's Office
is occupied, then leave the lights and thermostat on - If the room is unoccupied for ~5 minutes, then turn off the lights and the thermostat
- If a motion or door sensor is triggered, start a 30 minute timer. Motion sensors are typically a lot faster than presence detection, so these should turn on the lights, and then the presence detection can override it later once the device is detected.
These are some pretty basic rules that apply to every room in my house. So I could keep going with my crazy Jinja templates, but I’m wondering if there’s a simple solution I’m missing. entity-controller is missing a lot of things:
- A way to reload the controllers or configure them in a UI without needing to restart Home Assistant (this gets really slow and painful when you’re making a lot of changes.)
- More flexibility with different types of sensors. Doors aren’t handled quite right (open and close events should both turn on the lights)
- Proper support for the case where a user wants entity-controller to have absolute control over everything. It was designed with a “blocking” feature that I found really annoying. This only makes sense if you have limited sensors and no presence detection, but we never use the light switches anymore. I added a way to disable blocking and force the entity controller to activate, but it required a lot of hacks and workarounds.
- Built-in support for presence detection, so that it’s aware of rooms and people moving around a house and can intelligently turn things off or keep things on.
Any suggestions?