Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem adding a second S40 in local mode using hostnames #317

Closed
graveland opened this issue Mar 5, 2024 · 19 comments · Fixed by #318
Closed

Problem adding a second S40 in local mode using hostnames #317

graveland opened this issue Mar 5, 2024 · 19 comments · Fixed by #318

Comments

@graveland
Copy link

Describe the bug
I just installed 2 S40's, one for each furnace (upstairs and downstairs). I'm using a hostname, not an IP address, and the names are:

  • upstairs-hvac.<redacted>.net
  • downstairs-hvac.<redacted>.net

Upstairs worked just fine, but downstairs gets this error and fails to setup:
homeassistant.exceptions.InvalidEntityFormatError: Invalid entity id encountered: lennoxs30.conn_downstairs-hvac_<redacted>_net. Format should be <domain>.<object_id>

After a bunch of testing, I re-added the downstairs S40 with its IP address, and it worked. Strange that the hostname worked for upstairs, but not downstairs?

Version

  • Home Assistant: 2024.2.5
  • This Integration: 2024.2.1_r

**Integration Configuration **

  • Cloud or Local Connection: both local, internet blocked at the router (no outgoing connections and no DNS allowed)
  • Inverter or Sensor Diagnostics Enabled: tried both ways

Additional context
When adding the S40's, I installed the upstairs one first and it immediately worked. I've never gotten the downstairs one to add at all. I tried multiple combinations of removing the failed integration, restarting HA, and restarting the thermostat. The app_id for upstairs is ha_up, and I've generally tried ha_down for the downstairs one.

@graveland
Copy link
Author

btw: Thanks for this repo- great work!

@PeteRager
Copy link
Owner

PeteRager commented Mar 5, 2024

Yeah that's a bug, I fixed this in last release for cloud connections. I'll work on a fix. What are the specific host names you have so I can make sure I fix it right?

@graveland
Copy link
Author

downstairs-hvac.domain.net and upstairs-hvac.domain.net, where domain is the redacted part, matching [a-z]+

@PeteRager
Copy link
Owner

Please provide an example domain name preserving any - or _ or . In the name.

For example

my_domain-pete.net

aa_bbbbbb-cccc.net

@graveland
Copy link
Author

I did- my guess is that you need to replace - with _ as well, as the downstairs-hvac portion is likely the problem, and you already replace .'s with _.

@graveland
Copy link
Author

possibly moving to a whitelist form instead of blacklisting specific characters and just removing all characters not in [a-z_]

@PeteRager
Copy link
Owner

I think what happens is when end up with a double underscore and that causes HA to declare the entity id invalid. When I made the change in #310 I only did it for the cloud branch.

@graveland
Copy link
Author

According to the error message it's probably the - character. Replacing characters with _ can potentially lead to duplicate underscores, and the fix to collapse them all to a single one can't be done is a single replace (___ -> __ with a single replace). If it's not too irritating, possibly just deleting all characters that aren't valid in an entity_id would be the safest bet?

@PeteRager
Copy link
Owner

I can't change the algorithm output as it'll break existing installs - at least when it outputs something valid. I do agree that the suggested approach would be simple and robust.

@graveland
Copy link
Author

Yeah, not surprising, but too bad!

@PeteRager
Copy link
Owner

I took your recommendation, other approaches were looking more difficult. It will only cause a minor breakage for those who have more than one thermostat.

@PeteRager PeteRager linked a pull request Mar 5, 2024 that will close this issue
@PeteRager
Copy link
Owner

PeteRager commented Mar 5, 2024

If you want to test it, grab the __init__.py file from here

https://github.com/PeteRager/lennoxs30/tree/connection-state-fix/custom_components/lennoxs30

Replace it in your custom component install and restart HA

@graveland
Copy link
Author

Since that'll change existing installations (ip addresses drop their _'s), what about:

self.connection_state = "lennoxs30.conn_" + re.sub("_+", "_", re.sub("[^A-Za-z0-9]","_",self._ip_address))

@PeteRager
Copy link
Owner

So that will "_+" will remove all double or triple underscores?

@graveland
Copy link
Author

Yeah, _+ means one or more _ characters :)

@PeteRager
Copy link
Owner

Thanks for your help. I've tried to avoid learning regex for 20+ years...thanks for giving me my first lesson.

I've adjusted the changes. They are in this branch:

https://github.com/PeteRager/lennoxs30/tree/2023.3.0

with this pull request

#314

@PeteRager
Copy link
Owner

Should be addressed in latest release 2024.3.0. Thanks for the help.

@graveland
Copy link
Author

Thanks! I'll update and test! re: regex: I've used them too much in the last 20+ years. Fully understand not wanting to be tainted with them :D

@graveland
Copy link
Author

Totally worked- thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants