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

Can not add two secure instances of Elk M1 when using TLS 1.2 #81516

Closed
yestrdave opened this issue Nov 3, 2022 · 55 comments · Fixed by #81627
Closed

Can not add two secure instances of Elk M1 when using TLS 1.2 #81516

yestrdave opened this issue Nov 3, 2022 · 55 comments · Fixed by #81627
Assignees

Comments

@yestrdave
Copy link

The problem

I have two Elk M1 Golds. I can add one device secured and one non secured into HA with no issue. If two secured devices are to attempted to be added, the first secured device will add and the second will yield the following message “An ElkM1 with this address is already configured”
image
image
image

Home Assistant 2022.11.1
Supervisor 2022.10.2
Operating System 9.3
Frontend 20221102.1 - latest

What version of Home Assistant Core has the issue?

2022.11.1

What was the last working version of Home Assistant Core?

unknown

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Elk M1

Link to integration documentation on our website

https://www.home-assistant.io/integrations/elkm1

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

I have also tried switching the device order on another test environment and it yielded the same result.

Additional information

I will be happy to provide additional information. Just not sure on this one.

@home-assistant
Copy link

home-assistant bot commented Nov 3, 2022

Hey there @gwww, @bdraco, mind taking a look at this issue as it has been labeled with an integration (elkm1) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of elkm1 can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign elkm1 Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


elkm1 documentation
elkm1 source
(message by IssueLinks)

@yestrdave
Copy link
Author

Elk RP settings
image

@gwww
Copy link
Contributor

gwww commented Nov 3, 2022

Well that seems like a bug! Based on the image it looks like you are using the discovered workflow. Could you try adding them not using the discovered devices and see what happens.

@yestrdave
Copy link
Author

If you mean add integration select Elk select IP then it does the same thing

@gwww
Copy link
Contributor

gwww commented Nov 3, 2022

Can you supply a debug log. Add the following to your configuration.yaml:

logs:
    homeassistant.components.elkm1: debug

@yestrdave
Copy link
Author

Integration error: logs - Integration 'logs' not found.

@bdraco
Copy link
Member

bdraco commented Nov 4, 2022

Just a tiny typo

logger:
    homeassistant.components.elkm1: debug

https://www.home-assistant.io/integrations/logger/

@yestrdave
Copy link
Author

yestrdave commented Nov 4, 2022 via email

@yestrdave
Copy link
Author

logger:
default: info
logs:
homeassistant.components.elkm1: debug

this work?

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

Sorry for my "typo"; I cut/paste from a non-reliable source. Doh.

When editing configuration.yaml, indentation is important. So paste in exactly, with the logger: line at the very start of the line.

If you hover over the text below a little "Copy to clipboard" icon will pop up in the upper right.

logger:
  default: info
  logs:
    homeassistant.components.elkm1: debug

@yestrdave
Copy link
Author

doesn't seam to give me much when I try to configure

2022-11-03 20:15:47.579 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.582 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.582 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.583 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.583 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.583 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.583 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.583 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.583 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.585 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7f05223e3f10>
2022-11-03 20:15:47.610 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 25.34s
2022-11-03 20:15:47.611 INFO (MainThread) [homeassistant.core] Starting Home Assistant
2022-11-03 20:15:47.624 INFO (MainThread) [custom_components.hacs] Stage changed: HacsStage.STARTUP
2022-11-03 20:15:47.745 INFO (MainThread) [custom_components.hacs] Loading removed repositories
2022-11-03 20:15:48.652 INFO (MainThread) [custom_components.hacs] Loading known repositories
2022-11-03 20:15:49.284 INFO (MainThread) [custom_components.hacs] Starting recurring background task for downloaded repositories
2022-11-03 20:15:49.285 INFO (MainThread) [custom_components.hacs] Stage changed: HacsStage.RUNNING
2022-11-03 20:16:01.420 INFO (SyncWorker_9) [homeassistant.loader] Loaded ffmpeg from homeassistant.components.ffmpeg
2022-11-03 20:16:01.562 INFO (MainThread) [homeassistant.setup] Setting up ffmpeg
2022-11-03 20:16:01.614 INFO (MainThread) [homeassistant.setup] Setup of domain ffmpeg took 0.1 seconds
2022-11-03 20:16:01.683 INFO (SyncWorker_6) [homeassistant.loader] Loaded demo from homeassistant.components.demo
2022-11-03 20:17:07.118 DEBUG (MainThread) [homeassistant.components.elkm1.config_flow] Elk discovered from integration discovery: ElkSystem(mac_address='00:40:9D:DB:2A:FF', ip_address='192.168.91.12', port=2601)
2022-11-03 20:17:07.119 DEBUG (MainThread) [homeassistant.components.elkm1.discovery] Unique id is already present from discovery: ElkSystem(mac_address='00:40:9D:DB:2A:FF', ip_address='192.168.91.12', port=2601)
2022-11-03 20:17:07.119 DEBUG (MainThread) [homeassistant.components.elkm1.config_flow] Elk discovered from integration discovery: ElkSystem(mac_address='00:40:9D:C9:4F:18', ip_address='192.168.91.11', port=2601)
2022-11-03 20:28:43.847 INFO (MainThread) [homeassistant.helpers.storage] Migrating core.config storage from 1.1 to 1.2

@yestrdave
Copy link
Author

192.168.91.11 is the one I want to configure

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

Start with neither ElkM1 configured and then add them. Send that log.

@yestrdave
Copy link
Author

I've done that a couple times. doesnt seam to show in logs

@yestrdave
Copy link
Author

image

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

Does it matter which order you add them in? Is it always the same IP address that fails?

@yestrdave
Copy link
Author

here is an add non secure and it works

2022-11-03 20:43:51.038 INFO (MainThread) [elkm1_lib.connection] Connecting to ElkM1 at elk://192.168.91.11
2022-11-03 20:43:51.041 INFO (MainThread) [elkm1_lib.connection] Connected to ElkM1
2022-11-03 20:43:51.087 DEBUG (MainThread) [homeassistant.components.elkm1] ElkM1 login succeeded
2022-11-03 20:43:51.088 DEBUG (MainThread) [homeassistant.components.elkm1] Received login event
2022-11-03 20:43:51.088 DEBUG (MainThread) [homeassistant.components.elkm1] Waiting for sync_complete event for 120 seconds
2022-11-03 20:43:53.228 DEBUG (MainThread) [homeassistant.components.elkm1] Received sync_complete event
2022-11-03 20:43:53.229 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up alarm_control_panel.elkm1
2022-11-03 20:43:53.229 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.elkm1
2022-11-03 20:43:53.230 INFO (MainThread) [homeassistant.components.climate] Setting up climate.elkm1
2022-11-03 20:43:53.230 INFO (MainThread) [homeassistant.components.light] Setting up light.elkm1
2022-11-03 20:43:53.230 INFO (MainThread) [homeassistant.components.scene] Setting up scene.elkm1
2022-11-03 20:43:53.230 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.elkm1
2022-11-03 20:43:53.231 INFO (MainThread) [homeassistant.components.switch] Setting up switch.elkm1
2022-11-03 20:43:53.231 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.233 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.234 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>
2022-11-03 20:43:53.234 DEBUG (MainThread) [homeassistant.components.elkm1] Creating elk entities for <elkm1_lib.elk.Elk object at 0x7fa526542620>

@yestrdave
Copy link
Author

No it does not matter what order

@yestrdave
Copy link
Author

Ive tried everything it doesnt want to spit out a log

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

No worries. I'll ask again if I can't make progress.

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

@bdraco I can't figure out why this is happening (at least without add more debug logs). The only place I see the reported error message is here: https://github.com/home-assistant/core/blob/dev/homeassistant/components/elkm1/config_flow.py#L244

As I understand it, one Elk is discovered and added. The second discovered Elk throws this error. The images supplied show that. Do you have ideas?

@bdraco
Copy link
Member

bdraco commented Nov 4, 2022

I wrote test to make sure we can add multiple instances and couldn't find a problem.

@yestrdave Is it possible there is a disabled or ignored instance already set up that is blocking the creation of the new one?

@yestrdave
Copy link
Author

Pretty sure that’s not possible. I’ve duplicated on two different servers and the order doesn’t matter. I’ll go into the test server and go through the testing again to make sure.. Since the order does matter it eliminates the set up in the ElKRP too. I will go through and document this shortly. As a last resort I could fire up a fresh vmm and try also.

@yestrdave
Copy link
Author

VMM Test
Home Assistant 2022.11.1
Supervisor 2022.10.2
Operating System 9.3
Frontend 20221102.1 – latest
image

Searched Alarm and Elk – Nothing appears to be hidden

image

Im going to do the one we have problems with in the Production setup first. 11 Main House

image
image

When I search elk everything shows up in entities as it should.
Then try to add Big Garage or 12

image

Reverse it. Deleted integration and restarted HA Big Garage first Main house second

image
image

Main House or 11 now shows as already configured

image

@yestrdave
Copy link
Author

Just ran the test in a docker container and same result

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

Since you can run this on clean docker installs, could you do this:

  1. Start the a clean docker version of HA
  2. Get a copy of config/.storage/core.config_entries; add a -1 to the filename
  3. At this point I'm expecting you see the 2 discovered Elks
  4. Configure the .11 Elk
  5. Get a copy of config/.storage/core.config_entries; add a -2 to the filename (so we can distinguish it)
  6. Try to configure the .12 Elk
  7. Get a copy of config/.storage/core.config_entries; add a -3 to the filename

Send us the 3 files. Make sure to remove your password from the files.

@bdraco I think this is useful. I don't know the internals really at all, does this request make sense?

@gwww
Copy link
Contributor

gwww commented Nov 4, 2022

Ignore last message, at least for now.

I have added some more debug messages to the code. You will have to install the Elk integration as a custom component. Copy the elkm1 directory and contents from here: https://www.dropbox.com/sh/96lxxckro2xdhkr/AABhCmSG6gRYSMeY_xluxE3Da?dl=0 to your config/custom_components directory (making the custom_components directory if it doesn't exist). You should end up with a directory structure config/custom_components/elkm1 and the elkm1 directory will have a bunch of Python files and other bits. The only change from the 2022.11.x version is added debug messages.

If you need help setting up custom_components don't hesitate to ask (I kept the instruction light here because many people already know how to do it).

Also replace your debug logging directives to the following:

logger:
  logs:
    custom_components.elkm1: debug

After those two things are done:

  1. restart HA
  2. Add the .11 Elk followed by the .12 Elk
  3. Send the new logs. **passwords for your Elk will be in the logs and should be removed.

@yestrdave
Copy link
Author

logs.txt

Used notepad plus to redact . Can save any format ya like. Here is a text file. Ill read up on Fenced code blocks

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

A text file is perfect. Use code blocks when pasting text in to a comment. I’ll take a look at the log in a bit. On my phone at the moment.

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

I'm narrowing in! I see a problem but don't understand why yet. Could you copy the code again from dropbox and rerun the test. I added one more log message.

@yestrdave
Copy link
Author

on it

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

I found the problem! No need for you to continue at this point. Once I have a fix I will get you to test it as a custom_component.

@bdraco urlparse does not work for parsing strings such as elksv1_2://192.1.1.1. I don't know if there is a better library, better use of urlparse, or just use split. I will create a fix and submit PR later today.

@yestrdave
Copy link
Author

ok its done if you want it
log2.txt

@yestrdave
Copy link
Author

What an unbelievable Community we have here. I absolutely love the devotion and pride I have experienced here since switching to HA. The commitment everyone has here is outstanding. Thank you so much @GWW and @bdraco you guys rock.

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

My devotion is getting overruled by spouse at the moment ;) I'll be back later today with a fix. I know what to fix, just trying to find the best way.

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

The log confirms what I thought. Thanks.

@yestrdave
Copy link
Author

My spouse is traveling for a couple days. I get to "geek out" uninterrupted today....lol

@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

@bdraco urlparse does not work for parsing strings such as elksv1_2://192.1.1.1. I don't know if there is a better library, better use of urlparse, or just use split. I will create a fix and submit PR later today.

@gwww Maybe try yarl

@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

yarl doesn't seem to work either

>>> from yarl import URL
>>> url = URL('elksv1_2://192.1.1.1')
>>> url
URL('elksv1_2://192.1.1.1')
>>> url.scheme
''
>>> url.host
>>> url.path
'elksv1_2://192.1.1.1'

@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

Every library I can find chokes on the _ in the scheme

@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

The best I could do was to make a new function that partitioned the url at ://, changed the protocol to a parsable string, reassembled it and put it through urlparse

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

All I do in the Elk library is just use split. The urls are simple in all cases.

Interested to know if the new test you wrote would work with the 1.2 scheme.

(I’m out on a hike. I can fix this tonight if you haven’t got to it)

@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

I’ll push something up soon. I’m super jet lagged as I just did a 3 day turn to Europe and back so make sure to double check whatever I write 😬

@gwww
Copy link
Contributor

gwww commented Nov 5, 2022

There’s this: https://github.com/gwww/elkm1/blob/main/elkm1_lib/util.py#L27

would work

@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

Nice. Will use that instead

@bdraco bdraco changed the title Can not add two secure instances of Elk M1 Can not add two secure instances of Elk M1 when using TLS 1.2 Nov 5, 2022
bdraco added a commit to bdraco/home-assistant that referenced this issue Nov 5, 2022
@bdraco
Copy link
Member

bdraco commented Nov 5, 2022

fixed in #81627

I use the function from the lib to parse the url

@gwww
Copy link
Contributor

gwww commented Nov 9, 2022

@yestrdave the new patch release 2022.11.2 is out with this fix.

@yestrdave
Copy link
Author

yestrdave commented Nov 9, 2022 via email

@yestrdave
Copy link
Author

Glenn and Nick we can close this one. I was able to VPN in from hotel and install second instance with no issues. Thank you both

@bdraco
Copy link
Member

bdraco commented Nov 11, 2022

Thanks for confirming 👍

@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants