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

octoprint platform causes error even though not in configuration #18627

Closed
rwifall opened this issue Nov 21, 2018 · 9 comments · Fixed by #20303
Closed

octoprint platform causes error even though not in configuration #18627

rwifall opened this issue Nov 21, 2018 · 9 comments · Fixed by #20303

Comments

@rwifall
Copy link

rwifall commented Nov 21, 2018

Home Assistant release with the issue:

0.82.1

Last working Home Assistant release (if known):
Unknown

Operating environment (Hass.io/Docker/Windows/etc.):

Hass.io

Component/platform:

octoprint

Description of problem:
I do not have octoprint in my configuration, because I have no need to use Home Assistant to interface with octoprint, however I do have an octoprint server on my network.
The octoprint component in Home Assistant automatically detects my octoprint install and then reports a keyerror: File "/usr/local/lib/python3.6/site-packages/homeassistant/components/octoprint.py", line 95, in setup for printer in config[DOMAIN]: KeyError: 'octoprint'
The octoprint component should not report an error if I don't have it configured regardless of whether I happen to have an octoprint server on my network. I should not be forced to include a component that I don't want to use.
The desired behavior here would be for the component to show up in the "new integrations" portion of the "Configuration" instead of causing an error.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

I do not have octoprint in my configuration

Traceback (if applicable):

Wed Nov 21 2018 15:09:46 GMT-0800 (PST)

Error during setup of component octoprint
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/octoprint.py", line 95, in setup
    for printer in config[DOMAIN]:
KeyError: 'octoprint'

Additional information:

@OttoWinter
Copy link
Member

Please double check you don't have octoprint in any of your sensor or binary_sensor blocks. Something like this:

binary_sensor:
- platform: octoprint
  # ...

will auto-load the octoprint component

@MartinHjelmare
Copy link
Member

I think it's a bug in the component setup caused by the network discovery service (netdisco). We probably should add a guard clause that checks for domain key in config and returns if not found.

@rwifall
Copy link
Author

rwifall commented Nov 23, 2018

I don't have octoprint anywhere in any of my files:

core-ssh:/config# grep -i octoprint *.yaml
core-ssh:/config# 

@MartinHjelmare
Copy link
Member

If you have discovery component activated it will trigger the octoprint component to load if an octoprint signature is found when scanning the network.

Components can be excluded from discovery. But this is still a bug cause of the KeyError.

@forkineye
Copy link

I just ran into this issue after updating to 82.1 as well. Same deal, it's being detected under known_devices but I don't have it configured and get the KeyError.

@ceejii
Copy link

ceejii commented Dec 22, 2018

I upgrade from 0.79 to 0.84 and also get this error. I have Octoprint on the same network running on a raspberry pi but haven't set up the Octoprint component.

I do have a switch that I named Octoprint, simple because it controls the power to that raspberry pi, but I sincerely hope that isn't the problem.

Looking in the source code for the Discovery component I can indeed see that it looks for Octoprint but the information wasn't added to the Discovery doc. So I created a pull request to the Discovery doc for that.

So of course I can, and have now, put octoprint on the ignore list for my Discovery component. For anyone looking to do the same, update your discovery configuration:
discovery: ignore: - octoprint

I'm surely going to forget that -ignore pretty soon, propably before I set up the Octoprint component "sometime in the future". Will I still be able to use the Octoprint in the future with the discovery ignore config remaining there and instead configuring the host manually as per the component doc?

@MartinHjelmare
Copy link
Member

Manual config should work.

@ceejii
Copy link

ceejii commented Dec 22, 2018

So in the pull request I was asked to say that the Octoprint component works in the Discovery component by adding it to the docs. I haven't used the component but it normally works with Discovery, right?

@MartinHjelmare
Copy link
Member

MartinHjelmare commented Dec 23, 2018

No, discovery isn't really supported. There's just a debug message. We should remove the discovery listener or make it supported and fix the KeyError problem.

ceejii added a commit to ceejii/home-assistant.io that referenced this issue Dec 23, 2018
ludeeus pushed a commit to home-assistant/home-assistant.io that referenced this issue Dec 23, 2018
alengwenus pushed a commit to alengwenus/home-assistant.io that referenced this issue Feb 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants