tony-fav / tasmota-blerry

GNU General Public License v3.0
96 stars 29 forks source link

Support the use of specifying a HA Entity ID and Friendly Name #34

Closed wraggzeh closed 2 years ago

wraggzeh commented 2 years ago

I wanted the alias specified in the config file to be the friendly name in HA to make things a little cleaner.

To do this, I use the alias specified directly as the friendly name, then derive the Entity ID from this by removing any spaces and converting to lowercase.

This also has the side effect of supporting a custom Entity ID in the config file, if desired.

tony-fav commented 2 years ago

I'll admit maybe some ignorance here. In my use cases, the desired behavior you've described basically is the behavior I'm observing. Can you explain what the the exact situation that the previous setup didn't do per your wants?

The changes look fine btw and should be non-breaking, yeah?

Please take a look at the dev branch (https://github.com/tony-fav/tasmota-blerry/tree/dev) and consider making a similar contribute there. I am just about ready to merge it into main and do a release. So, I might not merge this into main as the dev branch is a SIGNIFICANT refactor.

wraggzeh commented 2 years ago

Yeah, so I initially added my sensor with the alias "Shower Climate" - this published into MQTT ok (as blerry_Shower Climate), but Home Assistant didn't pick it up.

I then added it as "shower_climate" and it popped straight in. I looks like it breaks at the initial discovery in HA as if I change the name back to "Shower Climate" in blerry with the entity already created, it works just fine.

Yeah, no breaking changes that I can see. Tested with ATCpvvx.

Will look into the Dev branch, thanks!

tony-fav commented 2 years ago

Okay so it seems that the principle issue is that the way the alias is used throughout the code, it really needs to be space-free. I know uppercase is accepted because my aliases are things like ATC1_Bedroom and the entity IDs are then like sensor.atc1_bedroom_temperature with HA automatically cleaning out the uppercase. It's a good catch, just a case I never even though to try for some reason. Give the dev branch a look and see what you think. I'll also give it some though on how to accommodate such a change there. It's essentially a bugfix + new feature.

wraggzeh commented 2 years ago

Yeah, makes sense, thanks!

Dev wise i'm assuming you can do a similar thing as you're still using the string_replace helper function. I just hijacked the use of that to replace spaces with underscores.

Then it looks to just be a case of adding entity_id to the Blerry_Device class.

tony-fav commented 2 years ago

I'm going to close this now, but add it as something I'll try to add into dev shortly.