Where is the "glue" between ESP and HomeAssistant

Hi,

tl;dr: I am looking for a way to securely use sensor names that are generated during first adaption of an ESP in HomeAssistant (HA), so I can use these names in pre-generated automation scripts on HA.

I am having “some” ESP ePaper, that display the dates for $today from specific calendars that are in HomeAssistant. Connection between ESP and Calendars are N:M, so more than one ESP can display one of M calendars.

As the ESPs are mostly sleeping, I do need nearly for every “Variable” in the ESP I want to let the HA user change a “mirror” helper, that the user can use to change the value in the HA frontend anytime, and the value is than pushed over to the ESP when it wakes up.

This all works, because I have a script, that creates the IMHO needed automations to trigger the change from the helper to the ESP “Variable” “on connect” of the specific ESP. The script generates automations for each ESP from a template file by replacing e.g. $$$ESPNAME$$$ within the template and than generating the relevant automation within a package in for each ESP. (Helpers, automations, scripts, … you name it).

There is another template which takes care, that the ESP individual firmware YAMLs are also generated. These individual YAMLs include the “common” files which I have for two sorts of hardware.

It all works. My problem: It more and more feels to me, that I am re-inventing a wheel I cannot find :slight_smile:

What I want to achive:

a.) Have HA automations that are needed for displaying and booking slots on the ESP hardaware pre-generated so the user that wants to install a new system has everything in place. But not onyl new users on new system, also existing users on existing systems.

b.) Change Firmware on ESP (I managed to get a stable OTA with mainly sleeping EPSs, so this is not the issue), where I can give the users new features in the firmware.

My general problem ist, that I made assumptions how names are generated from new ESPs that “arise”. They seems to collide with the reality :slight_smile: I e.g. had to change a variable I had on the ESP, as the naming was really bad and misleading. When doing so, I had to learn, that now, the sensors are not named number.s03_max_wake_interval_during_work but number.homeoffice_s03_max_wake_interval_during_work, where s03 is my testing system within my HomeOffice.

Problem I have: I do not know how I can generate “unchangeable” ESP ids, that i can use within HA. Reason: I now have “10” or so without the “homeoffice_” in fron, and this one with the “homeOffice” in front, which might come in due to the reason, that I disconnected the ESP from HA, and re-connected it, and added “HomeOffice” as his area. Maybe before the very first inclusion of this ESP I was not using this area at all. Other problem: If I rename the area, the sensor is not renamed. So what is the technical “most sticky” name I can rely on, and go from there within my automations to use the sensors from my ESPs.

So the idea of having automated sensor ids during an adaption is not working for me (or I fundamentally got something wrong, which I still assume).

As this might happen with new installations by other users as well, I need a stable way to automate this, and reliably rely on the naming.

My quesion: What am I doing wrong? Is there a way, I can read me thru? If this really is “as is”, my simplest solution would be to tell the users NOT to use any location when a new ESP arises.

thank you for readying till here. My journey started about 2 years ago, and I am damn close before a release, but I cannot support user questions, that IMHO will arise from this with a 99.5% chance.

Any hints welcome, but please no KI generated untest help. I digged thru KI and internet the last 4 weeks, whith no luck; help from real people that I will adore afterwards welcome :slight_smile:

all the best

Juergen

no solution but this thread will show you are not alone.

That thread mentioned above was mine, but look instead here:

https://github.com/home-assistant/core/issues/173125

It’s a long (LONG!) thread of people complaining about this issue, and near the bottom (where what is the bottom as of yesterday) look for postings by “frenck” (with @ before it, trying to avoid pinging him here), he’s the one that matters and is stating what might (sounds like will) change shortly.

For anyone not willing to go through the saga of clicking Load More & trying to find a single post among hundreds of others, the relevant post is here

Sorry, I probably should have found it, but if you can tolerate it the discussion (including some of the venom) is educational in terms of understanding the issues and why templates may not be a complete solution.

Problem with github is that comments get compressed under the load more function somewhere towards the middle & it gets worse as more comments are added. You can tell from the issue because people kept asking variants of the same question.

Unless you’re willing to read through every post (most of which contributed nothing new) & keep pressing Load More multiple times, it’s like trying to find a needle in a haystack.

Hi all,
thanks a lot. At least I see I am not alone. I personally understand the change, and somehow like it. My question is (and I hope you can help me here.)
frenck is talking about help for “new” devices. But I am more interested in “ESP devices that are under development”. What I now see is (e.g.)
‘sensor.area_device_name_temperature’ for all new sensors I define on my ESP, but the old ones still last around with ‘sensor.device_name_humidity’. In this example I added a sensor temperature, which is now in the new naming sceme, but it feels very “ugly” within the automations where I do have two different “name starts” for the same device. In the process of developing I often try things, make them work, and than clean the code later, which also implies renaming variables/sensors that I found I named wrong the first time.
So what I would assume is that there is a way to get/generate the internal HomeAssistant ID, before HA adapts is from the ESP, and than stick from there with all automatically generated automations for this ESP. And if HA notices, that this ID is already is used, than it could rename it and throw an error/warning in the logs. And I do want to set it, as I do not see a way I can use the MAC addresses, which seems to be the case for HA right now. If an ESP breaks, and is replaced by a new one, the new one has a new MAC address, so for HA it’s new, but as it does the same job, it should be a 1:1 dropin replacement, where I somewhere could say: replace the device for the old/broken one you might find.
But in HA/ESP the naming is so extremly sticky, that even if I delete an ESP completely and adapt it new, the old namings are still around, and if I have bad luck, they are added by a _2. I would love to have a “nuke this device, and all old sensors” beeing asked, during an adaption of an new/old ESP and new/old device.
Like: "Hey you think this device is new, but I think I got it already: Should I delete all references of this device, or should I try to do my bnest (which is IMHO now causing problems), or do you need to go one step back, read here the consequences and retry…)
IMHO it is similar to the problem I have if I get a new mobile phone, and need to go thru all automations that send messages to the old phone. Even if I give the new phone the same name of the old phone like “juergensmobile”, the new phone gets juergensmobile_2 in the sensors. But I still want the automations to send the message to “juergensmobile” regardless if old/new whatever.
Same think wo me, if a device breaks, and I want to replace the new device 1:1 with the old one. I did not catch how this is solved with the new naming sceme.
I read thru the thread, but it seems to turn in circles, and strongly reminds me, that such discussions should be done more face2face.
Can anyone enlighten me if such features exists, and I am just searching for the wrong things?
many thanks
Juergen