Any AI that can help me out with creating good YAML?

,

it didn’t suggest using the climate component, which seems like a better choice for what you need/want.

There is always more than one way to accomplish a goal. I haven’t (yet) used the climate control so I don’t know how easy it would be to use for your specific needs, but it is where I would have started.

I have a floor thermostat and I use an automation to change the set point depending on some conditions. This separates the concerns. The thermostat knows how to keep the temperature at the set point. The automations change the set point based on probability of occupancy. This seems a lot clearer to me and if I step away from it for 6 months and then come back to it, it will likely be easier to remember “what was I thinking” when I wrote that.

There are many dimensions with which you can measure how good something is. If what you are doing is working for you, that is likely the most important one to you.

Yes. The hive mind here.
I am a retired software engineer, and hint to my age, Python was just first released a few years before I retired. People were still hiring COBOL programmers. I’m that old.

I still remember the huge lawsuit between Sun and Microsoft over Java. (Microsoft lost).

Anyway, I digress. I never learned Java or Python. If it weren’t for assistance from the more experienced people here I might have given up on home automation. Today I have many dozens of ESP devices around the house- mostly DIY. (But, I am not an expert, so ask me for help with caution).

So, try writing your ESPHome configuration(s). Start small. Fail. Ask ChatGPT or CoPilot for help. AI is usually wrong or at best a couple of years behind the current state of the programming world. For example, if I ask AI for help with a Linux question, I am often directed to use “apt-get”, but “-get” was depreciated two years ago. In Home Assistant, “Service” is now “Action”, but AI doesn’t know it yet, so many answers are simply wrong. Post your best yaml here (use code tags) and ask for help. You will usually get it. (And sometimes it will be correct- :laughing:).

2 Likes

The device is an IR space heater that doesn’t have separate on and off commands, it just toggles. I keep track of its state with input_boolean.heater_status.

The AI advantages I stated were generalizations, not necessarily applying to my sample. I like how this one was simplified and easier to follow.

The redundant state check is a remnant from my initial stab, which wasn’t working. Claude also mentioned that was pointless.

1 Like

The new automation is so convoluted that I can’t really tell what is going on by spending way too much time on it (which is the problem with most AI generated yaml).

The way it is written is also using “blanket” triggers, ignoring the conditions but instead using lots of ifs to make sense of the states of the sensors. This is not how home assistant automations are designed to work. Will it work? Possibly. Is it something you can lean from on how to write good automtions: definitely not.

How HA was designed? Use triggers to listen for specific changes, use conditions in the conditions section to check for the right combination to do something, then do what is needed.

Different actions should use different automations. Turning something on needs different triggers and conditions than off, don’t try to put those in one automation just because you like that more. Certainly not if you have trouble writing complex automations.

If the automation is just to turn the heater on if it is in automatic mode, in need of heating and the room is occupied, this is way overcomplicated. If that is not what this does, then you proved my point that this automation is convoluted. It is very likely that the automation is trying to do too many things in one automation.

PS. Don’t ever ask me to fix AI generated automations. It happens way too much, and is driving me away from helping people here. Ask Claude, who wrote it in the first place.

3 Likes

Same

Hell Im ‘the AI guy’ and I wont touch someone else’s AI Gen code. I will if I wrote it but I know what I’m doing and can tell when the AI is not being exactly above board. I’m starting to be able to pick out the AI Gen code too. It’s overly verbose like when it writes in English.

I didn’t ask anyone for help here, merely pointing out that I like (so far) what Claude is cooking. Every action in that automation is needed, and both versions work perfectly.

The question on top was “good yaml”. “It is working” is only one of the requirements for good code. I explained what a properly designed automation should look like, and why I think it does not fit that bill. It is fully up to you what you do with the advice.

I have a second boolean that determines whether or not I want the auto heater function enabled. That, the current temp, desired temp and heater status need to be considered. As I said earlier, I’m no whiz but I don’t see anything extraneous given the heater shortcomings and desired functionality. I may not be equipped to fully appreciate your opinions, but thanks.

It sounds like at least a large part of what you are doing is to emulate a thermostat. Maybe making use of a generic thermostat entity to take care of the temperature comparisons would make the automation a lot simpler? The automation would then only need to take care of when the thermostat is on.

It would also give you a nice UI to control the heating.

That is what I’m doing. The heater has a thermostat but its worthless, because it’s in the heater. So I have a Zooz sensor at my desk to get a meaningful current temp. study_heater_needed is set by a comparison of needed vs actual.

What I suggest is that you make use of a templated climate entity instead of booleans and automations. A climate entity has a nice UI. So this, or if your heater is not an on/off type device, there are other options too:

But we’re going off topic. To go back on topic, an AI just want to please and do as you ask, but would not stop to think and say: hey, is this the right approach in the first place? :wink:

3 Likes

I agree and disagree. I am somewhere between noob and basic/advanced :slight_smile: I used ChatGPT to write automations that were full of errors and did not work 80% of the time as they were a bit more complex. However, with time, I started understanding the code by comparing and mimicking it in the UI. Also, even now, it is a good starting point or a way to give you an idea how an automation can be executed in a specific action. However, sometimes the logic is wrong so is the code, but it gives me the idea how it can be achieved, and I finish it myself as I now have the knowledge and experience to do so :slight_smile:

Basically the least it can do ChatGPT can help you become Neo in the Matrix, :slight_smile: It is an awesome tool that is not very reliable to do the job for you.

That surely would have been easier. I guess I assumed it needed an actual HVAC😞 I wasted even more time on this

3 Likes

Looks nice! Climate UI is nice, but not that nice :slight_smile:

1 Like

The fan even lights up and spins when on. Let’s see Climate do that

2 Likes

Hey never know, I’ve seen the guys really good with card-mod can do weird stuff. :rofl:

It is too easy. Overlay a small fan image and css can spin it. I meant natively.

1 Like

That’s how I do my smoke detectors someone did one and matched up a small ring with the lit led circle on a Nest Protect. Then you animate the ring. The effect is incredibly convincing. But we’re WAY in left field now. :rofl: