Home Assistant commiseration thread

demultiplexer

Ars Praefectus
5,041
Subscriptor
I'm getting extremely fed up with doing stuff in Home Assistant and I can't be the only one to be maddened by everything in it. It's such a dogshit system under the hood, I just don't understand how anybody thought any of this was a good idea.

It uses three completely different, incompatible and all terrible programming languages to achieve stuff. You can do stuff with YAML, Jinja3 Templates and Python. But none of it is straightforward, no no no. YAML isn't hard, right? How hard could it be? Well, it gets a whole lot harder if you use completely random, nonsensical names for your interfaces. An interface is not an interface, it is a platform. An API isn't an API, it's a platform. Wait, what? Multiple different things are named the same?

Want to set up multiple actions in yaml? Guess how you enumerate them? Do you use an array? Do you just use dashes for each item? No, no, noo.... you put an 's' after the platform name. Just setting up a single automation across all of your home assistant?

automation:
[put your stuff here]

Need to have more than one?

automations:
- automation 1:
[stuff 1]
- automation 2:
[stuff 2]

Oh and you thought this was universal? Nooooo no no no no no why the fuck do you even think any of this is consistent. Only 3 out of like two dozen default platforms support this syntax. The rest uses an entirely differently named platform to enumerate multiple actions. Because of course.

But hey, now you need to do some math or formatting in your automations? You usually do. There's a native python engine in... wait a second, no, we can't have nice things in HA. Why use a fully functional, debuggable, logically consistent programming language most people already know if you can use Jinja! A templating engine. What's a templating engine? Well, it's a dogshit fucking horrible way to do anything that nobody should ever use and should die in a fire, that's what it is. Sometimes it's sort of like python if you squint. But most of the time it's just the weirdest shit in the world. It supports variables you can set! But oh wait, you don't just want a number or string? You need an array? What in the world should anybody need arrays for? No, let's just not support that. It supports for loops. Well, only a very tiny subset of for loops, it doesn't do foreach or really any true iteration. There are no while loops. Oh but despite requiring a separate keyword to assign values, it still requires a double == for comparisons even though there is no contextual confusion. The best thing? Even though nobody uses templates and it's arcane, incomplete and inscrutable bullshit, there is no debugger! There is nothing to check your work. Made a mistake, or even not a mistake but you're just ingesting data that isn't formatted the way you expected or anything like that? Enjoy getting TemplateSyntaxError: expected token 'end of statement block'. Where? Somewhere in all of your code. Line number: start of your code. No position. No hints. Just write your code 100% perfectly the first time.

But Python does exist! You can write what is called an integration in Home Assistant. Integrations do not integrate into home assistant. Obviously. They're apps. Written in Python! That should be easy to do oh no wait, why make things obvious if you can require literally 5kB of boilerplate across multiple files, including a yaml file which definitely isn't python, just to start? And then have no IDE, no autocomplete, no debugging in test (yes, we're debugging in production, people!), no deployment framework, nothing.

Did I mention Home Assistant itself is web-based and runs, obviously, on javascript and CSS for its frontend? You think you can access any of that? No of course not, because why should you make things easy. Enjoy your misaligned visual elements! Try fiddling with yaml and python to somehow propagate all of that to fix UI bugs!

Anyway, I'm going to build some LEGO now. Anybody else need to vent?
 

w00key

Ars Tribunus Angusticlavius
8,879
Subscriptor
Sounds about right. Want a chart that doesn't look completely shit? Well it's an integration.

Templating, Jinja used for html with placeholders is fine, anything else should be provided in the context already. But used as view controller, like HA, oh hell no.

The debugging issue is also a HA footgun, in Django/Jinja, you get proper stack traces and exceptions with tracebacks, I even recently let Claude generate a SQL repeated query analyzer that pierces through this (transpiled template to Python to bytecode have mismatched line numbers/signature) and maps the call sites back to templates with accurate line numbers, if some template causes select one row in a loop issue.


Seems like it's popular and best of the competition - not that hard as most are closed source appliances/devices, but still rather shit. Sad, but it's a way too chonker project to rewrite / redo even with infinite tokens to burn.
 
Yep if you're writing your own blueprints you're pretty far out in the weeds. It used to be you needed to mess with YAML just to have a dashboard at all. Then 2 years ago, you needed YAML for a nice-looking dashboard. Now it's all customizable and drag and drop and really quite easy to use overall. It's incredibly impressive how much HA has improved since I started using it.
 
  • Like
Reactions: Scotttheking

wxfisch

Ars Scholae Palatinae
975
Subscriptor++
Maybe its because I am not a programmer and don't try to do anything outside of modifying my main YAML config or use the UI, but HA works pretty well for what I need and the nomenclature of Integrations makes sense from the standpoint of a user (its something that integrates a device or service into our HA ecosystem). I guess like most things it depends on your point of view.

That isn't to say HA is without faults, I find its UI automation engine to be nearly impossible to use for anything but the simplest tasks and use Node-RED for most of my automations (though vexingly I find Node-RED to be difficult to use for most of my very simple automations). Also, for new users the learning curve is still steep, partly because home automation is still a fractured and niche thing but also because HA has never done a good job at making it simply to start, instead dumping you into a UI that has everything it could find on your network ready to add, and a dashboard that is just all of the things shown to you without much organization.
I would rather see it walk you through planning your home, perhaps with a guided interface that allowed you to skip sections if you already knew how you wanted it all laid out. But unless you know how HA works with various types of objects and their properties, it makes it hard to name things well or assign them to rooms/spaces in a way that will be useful at some point when you want to do something more advanced. To this end I am likely going to take time over the holidays to rip apart and recreate my install in a way that is much more supportable long term and easier to work with now that I know how I can leverage different properties and objects within the platform.
 

demultiplexer

Ars Praefectus
5,041
Subscriptor
Maybe its because I am not a programmer and don't try to do anything outside of modifying my main YAML config or use the UI, but HA works pretty well for what I need and the nomenclature of Integrations makes sense from the standpoint of a user (its something that integrates a device or service into our HA ecosystem). I guess like most things it depends on your point of view.
I'm amazed that even non-programmers don't bump into the weirdness that is HA. The first sign of trouble I had was trying to subtract one value from another.

IMO, if you have an automation platform, the very core of what you do is combining logical and mathematical operators. This should be the first thing you design. But try it out: you won't find anything convenient or straightforward or even GUI-based to do this.

Adding two entities together is simple. You make a helper that for some reason is named 'combine the state of two sensors' (because why call things what they are if you can make it cryptic!) and choose the two sensors and you're done. But subtracting? There is no option to do this, even though this is absolutely necessary to make a complete automation engine, if you're into computer science it's what is missing to make this turing complete.

So how do you do this? Well, you make a template. Templating engines, and I'm just explaining this for the non-programmers, are supposed to be used to format stuff. They're printf on steroids. But in HA, you abuse them for math operations all the time. You don't get to choose the entities from a dropdown either, you have to literally write a bit of code to make this work.

Two seemingly equivalent mathematical operations that require completely different, nonobvious ways to achieve them. What a system!

You could always try openHab, not as common as home assistant but still supports a massive range of systems. From memory it uses Java for most things, but was fairly opinionated on how it should be configured.
So the ultimate backstory of all of this is that we've gone through a selection process of home automation systems for my job, this is kind of half my job as well. We've settled on Home Assistant for a good number of reasons and really don't expect there to be anything that can compete in the medium to long term right now. OpenHAB, Domoticz and HomeKit all have much better scripting and a more logical foundation, but nothing can compete with the support and versatility of HA. So this is my life for the next 5 years.

I'm seriously hoping they're going to completely revamp the automation logic at some point and put in a proper automation engine with visual programming elements and just ditch all the yaml and jinja.
 

wxfisch

Ars Scholae Palatinae
975
Subscriptor++
I'm amazed that even non-programmers don't bump into the weirdness that is HA. The first sign of trouble I had was trying to subtract one value from another.

IMO, if you have an automation platform, the very core of what you do is combining logical and mathematical operators. This should be the first thing you design. But try it out: you won't find anything convenient or straightforward or even GUI-based to do this.

Adding two entities together is simple. You make a helper that for some reason is named 'combine the state of two sensors' (because why call things what they are if you can make it cryptic!) and choose the two sensors and you're done. But subtracting? There is no option to do this, even though this is absolutely necessary to make a complete automation engine, if you're into computer science it's what is missing to make this turing complete.

So how do you do this? Well, you make a template. Templating engines, and I'm just explaining this for the non-programmers, are supposed to be used to format stuff. They're printf on steroids. But in HA, you abuse them for math operations all the time. You don't get to choose the entities from a dropdown either, you have to literally write a bit of code to make this work.

Two seemingly equivalent mathematical operations that require completely different, nonobvious ways to achieve them. What a system!
I guess our definitions of automations are different as I don't typically look to directly change (add or subtract) values as part of my automations, instead I am looking to compare values, and then take actions based on that. I don't typically need to directly add or subtract the values for the location of my device and my wifes device, I just need to determine if my device is not home, and my wifes devices is not home, then turn off all the lights and set the thermostat to a defined value. Or if I push a button, check if my car is not at home, then set the AC to 74F, and turn on the seat ventilation for 10 minutes.
In fact I think the only time I do any real math on values is to calculate various energy and power statistics from my solar power system to show in the energy dashboard and I can do all of that in the YAML directly.
Perhaps you are trying to fit a square peg into a round hole and don't really need a home automation solution but rather an industrial control system that is more flexible in how it allows you to interface with it? I think for most users, HA is more of a home integration solution than a true automation solution. My routines are only so regular, and I can only afford so many sensors (and my wife will only tolerate so many bugs), that I and many others still use buttons, switches, and voice assistants to kick off many actions in our homes.

I mean don't get me wrong, HA for sure has quirks, and the built in GUI/YAML automation system isn't great (at least I don't think it is, and from what the devs have said publicly it is on the block for a pretty complete overhaul at some point), but that is why I use an add-on to build most of my automations (where I still am not really doing any calculations, more just gathering, comparing, and passing values to determine actions that need taken). But HA is sort of the go to standard because it works well for what it was intended to do and I haven't really run into a ton of complaining about its core architecture among users at least in the HA forums (aside from announcements for things like deprecating the container image, and the backup changes they made, but those were not really in line with your complaints here). I'm not saying you are wrong, I don't have a comp sci background to really have an informed opinion, but it is a new take for me at least.
 

Aeonsim

Ars Scholae Palatinae
1,253
Subscriptor++
So the ultimate backstory of all of this is that we've gone through a selection process of home automation systems for my job, this is kind of half my job as well. We've settled on Home Assistant for a good number of reasons and really don't expect there to be anything that can compete in the medium to long term right now. OpenHAB, Domoticz and HomeKit all have much better scripting and a more logical foundation, but nothing can compete with the support and versatility of HA. So this is my life for the next 5 years.

I'm seriously hoping they're going to completely revamp the automation logic at some point and put in a proper automation engine with visual programming elements and just ditch all the yaml and jinja.
Can you move all the automation into Appdaemon (python), pyscript (another python addon) or Node-red?
Some of my more complex automation still lives in appdaemon.
 

demultiplexer

Ars Praefectus
5,041
Subscriptor
Perhaps you are trying to fit a square peg into a round hole and don't really need a home automation solution but rather an industrial control system that is more flexible in how it allows you to interface with it? I think for most users, HA is more of a home integration solution than a true automation solution. My routines are only so regular, and I can only afford so many sensors (and my wife will only tolerate so many bugs), that I and many others still use buttons, switches, and voice assistants to kick off many actions in our homes.
I probably expect way more from home automation than you, but IMO the big 'offense' that HA does is to enable all kinds of complex functionality, but make it extremely convoluted to get there because the mechanisms it uses are so extremely limited to ultra-specific use cases. And also IMO, subtracting values is not a complex automation :p

Can you move all the automation into Appdaemon (python), pyscript (another python addon) or Node-red?
Some of my more complex automation still lives in appdaemon.
There's so much faff around that as well. There is currently no convenient way to externally script for home assistant that exposes both the backend and frontend in any kind of convenient way to you. The only thing that comes somewhat close is its built-in pseudo-python 'integration' stuff, but that is such a katamari as well that I still haven't been able to tame that yet.

Another big reservation of mine to avoid external scripting is that this is a deployment nightmare for customers. My applications eventually need to live on either a cloud server or on peoples' own servers.

I'll get there eventually but this thread is just to bitch about it :p
 

wobblytickle

Ars Scholae Palatinae
821
You could always try openHab, not as common as home assistant but still supports a massive range of systems. From memory it uses Java for most things, but was fairly opinionated on how it should be configured.
it is java, and it's not without its own huge problems but I found it way more sane than the bat-shit-crazy approach HA took; they basically built their own very poor container orchestration platform
 

demultiplexer

Ars Praefectus
5,041
Subscriptor
I have another mad thing. Here's an automation. Spot the madness:

Code:
- alias: "@Programmed charge"
  description: ""
  triggers:
  - trigger: time
    at: input_datetime.start_charge
  conditions:
    - condition: state
      entity_id: input_boolean.enable_programmed_charge_discharge
      state: 'on'
  actions:
    - service: number.set_value
      entity_id: number.goodwe_eco_mode_power_2
      data:
        value: "{{ states('input_number.charging_power')|float(0) }}"
    - service: number.set_value
      entity_id: number.goodwe_eco_mode_soc_2
      data:
        value: 100

So you can use a straight entity id as the action target, and you can use a normal number as a value. But if you want to use another entity as a value and not just a hardcoded value, you have to use friggin jinja.
 

Scotttheking

Ars Legatus Legionis
13,148
Subscriptor++
I have another mad thing. Here's an automation. Spot the madness:

Code:
- alias: "@Programmed charge"
  description: ""
  triggers:
  - trigger: time
    at: input_datetime.start_charge
  conditions:
    - condition: state
      entity_id: input_boolean.enable_programmed_charge_discharge
      state: 'on'
  actions:
    - service: number.set_value
      entity_id: number.goodwe_eco_mode_power_2
      data:
        value: "{{ states('input_number.charging_power')|float(0) }}"
    - service: number.set_value
      entity_id: number.goodwe_eco_mode_soc_2
      data:
        value: 100

So you can use a straight entity id as the action target, and you can use a normal number as a value. But if you want to use another entity as a value and not just a hardcoded value, you have to use friggin jinja.
Yep it's fun.

Sharing, here's the "big" automation blueprint I released: https://community.home-assistant.io...ate-your-house-for-shabbat-and-yom-tov/925237
 

redleader

Ars Legatus Legionis
35,861
YAML is like a cautionary tale in how not to parse white space characters. Almost everything in the syntax seems to be designed to maximize the probability that the error message you get will as uninformative as possible. Oh and best of all, the intended audience isn't even experienced developers but casual users with minimal programming experience.
 

demultiplexer

Ars Praefectus
5,041
Subscriptor
YAML is like a cautionary tale in how not to parse white space characters. Almost everything in the syntax seems to be designed to maximize the probability that the error message you get will as uninformative as possible. Oh and best of all, the intended audience isn't even experienced developers but casual users with minimal programming experience.
which makes it all the more infuriating that despite plenty of open source yaml inline IDEs available on the internet, the only places where you edit yaml in home assistant are completely unaided. To the point that you have to navigate to potentially multiple other places to even just reference which entity IDs you need to enter. Let alone which keywords are legal in each platform/section/service. Which are also not documented in a systematic way, by the way.

I disliked doxygen for being all over the place, but this is amazingly inefficient to use.
 
  • Like
Reactions: redleader

Hap

Ars Legatus Legionis
12,121
Subscriptor++
So, per the Smarthome Automation thread, I was in the process of migrating the remainder of my devices off Insteon to Z-Wave (since Insteon integration is a paid service in Home Assistant). I have a Home Assistant server running (not with any of my devices yet, just the basics), but this thread is starting to make me want to stick to my current system. Dashboards aren't pretty, but the software is 100% accessible from Python, or you can chose to integrate Python scripts directly.

I mean below is a very simple script to chose which blinds to close based on whether or not we have guests. It's a button on the dashboard for the evening, and runs automatically the open version at Sunrise. Other than linking it to a time (sunrise) or a button - everything can be handled in Python.

Python:
guest_mode = indigo.variables[1739085701]
indigo.server.log(f"{guest_mode.value}")
if guest_mode.value == "false":
    indigo.device.turnOff(748881128) #Master Bedroom Close
    indigo.device.turnOff(603693808) #Blue Close
    indigo.actionGroup.execute(329565976) #Dining Room Close
    indigo.device.turnOff(44168682) #Exercise Room Close
    indigo.actionGroup.execute(1083429978) #Kitchen Nook Close
else:
    indigo.device.turnOff(748881128) #Master Bedroom Close
    indigo.actionGroup.execute(329565976) #Dining Room Close
    indigo.device.turnOff(44168682) #Exercise Room Close
    indigo.actionGroup.execute(1083429978) #Kitchen Nook Close
 

Scotttheking

Ars Legatus Legionis
13,148
Subscriptor++
So, per the Smarthome Automation thread, I was in the process of migrating the remainder of my devices off Insteon to Z-Wave (since Insteon integration is a paid service in Home Assistant). I have a Home Assistant server running (not with any of my devices yet, just the basics), but this thread is starting to make me want to stick to my current system. Dashboards aren't pretty, but the software is 100% accessible from Python, or you can chose to integrate Python scripts directly.

I mean below is a very simple script to chose which blinds to close based on whether or not we have guests. It's a button on the dashboard for the evening, and runs automatically the open version at Sunrise. Other than linking it to a time (sunrise) or a button - everything can be handled in Python.

Python:
guest_mode = indigo.variables[1739085701]
indigo.server.log(f"{guest_mode.value}")
if guest_mode.value == "false":
    indigo.device.turnOff(748881128) #Master Bedroom Close
    indigo.device.turnOff(603693808) #Blue Close
    indigo.actionGroup.execute(329565976) #Dining Room Close
    indigo.device.turnOff(44168682) #Exercise Room Close
    indigo.actionGroup.execute(1083429978) #Kitchen Nook Close
else:
    indigo.device.turnOff(748881128) #Master Bedroom Close
    indigo.actionGroup.execute(329565976) #Dining Room Close
    indigo.device.turnOff(44168682) #Exercise Room Close
    indigo.actionGroup.execute(1083429978) #Kitchen Nook Close
That wouldn’t be any harder to do in Home Assistant, but if you’re happy writing your automations as Python scripts, might as well stick with indigo.
You’ll have to learn a different way of doing it in Home Assistant (I switched from indigo several years ago).
 

Hap

Ars Legatus Legionis
12,121
Subscriptor++
That wouldn’t be any harder to do in Home Assistant, but if you’re happy writing your automations as Python scripts, might as well stick with indigo.
You’ll have to learn a different way of doing it in Home Assistant (I switched from indigo several years ago).
Most automations are handled directly in Indigo, it's only complex conditionals I need Python for.

Mostly I'm just nervous - I'll have one day to make a full transition with all automations (or my wife will kill me).
 
  • Spicy
Reactions: w00key
So, per the Smarthome Automation thread, I was in the process of migrating the remainder of my devices off Insteon to Z-Wave (since Insteon integration is a paid service in Home Assistant). I have a Home Assistant server running (not with any of my devices yet, just the basics), but this thread is starting to make me want to stick to my current system. Dashboards aren't pretty, but the software is 100% accessible from Python, or you can chose to integrate Python scripts directly.

I mean below is a very simple script to chose which blinds to close based on whether or not we have guests. It's a button on the dashboard for the evening, and runs automatically the open version at Sunrise. Other than linking it to a time (sunrise) or a button - everything can be handled in Python.

Python:
guest_mode = indigo.variables[1739085701]
indigo.server.log(f"{guest_mode.value}")
if guest_mode.value == "false":
    indigo.device.turnOff(748881128) #Master Bedroom Close
    indigo.device.turnOff(603693808) #Blue Close
    indigo.actionGroup.execute(329565976) #Dining Room Close
    indigo.device.turnOff(44168682) #Exercise Room Close
    indigo.actionGroup.execute(1083429978) #Kitchen Nook Close
else:
    indigo.device.turnOff(748881128) #Master Bedroom Close
    indigo.actionGroup.execute(329565976) #Dining Room Close
    indigo.device.turnOff(44168682) #Exercise Room Close
    indigo.actionGroup.execute(1083429978) #Kitchen Nook Close
Ever heard of constants?
 

Hap

Ars Legatus Legionis
12,121
Subscriptor++
indigo.device.turnOff(748881128) #Master Bedroom Close

MASTER_BEDROOM = 748881128
BLUE = 603693808
DINING_ROOM = 329565976
EXERCISE_ROOM = 44168682
KITCHEN_NOOK = 1083429978

indigo.device.turnOff(MASTER_BEDROOM) # Close

Then, should those ids change, you just correct them in one place, preferably included into your project.
Oh, the numbers are fixed. You can reference by name, but the preferred method is by ID as it never changes. They are displayed prominently in the UI, and the scripts tend to be broken up, so I would have to set the constants up everytime, or change my approach.

It was a gradual approach and it grew organically.

EDIT: Or I guess an include file would work.
 
It was a gradual approach and it grew organically.

I know how that happens, and it really wasn't intended as a criticism. I could sit here and redesign a number of aspects of it, and while I might like the final results, I'm not really the one working with it anyway.

I've had plenty of stuff grow over time and then redesign it when it hits a certain level of complexity. The more it looks like spaghetti or a jenga tower the more likely I am to revisit it.

While the ids might not change often; they'll change if you have to replace the hardware, so eventually you'll have to revisit the files to replace a controller here or there. Much nicer if the pre-work shifts all that to one place for future simplification.

(You don't really want to be restructuring it at the same time as your replacing multiple components for instance. Better to know it's all working and tested over time).