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

Home Assistant #5

Open
dib0 opened this issue Oct 17, 2018 · 1 comment
Open

Home Assistant #5

dib0 opened this issue Oct 17, 2018 · 1 comment

Comments

@dib0
Copy link

dib0 commented Oct 17, 2018

Nice work on the surepet support!

I'm trying to get the home assistant sensor working, but I keep getting the following error:

Error while setting up platform sure_petflap Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform SLOW_SETUP_MAX_WAIT, loop=hass.loop) File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for return fut.result() File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/home/hass/.homeassistant/custom_components/sensor/sure_petflap.py", line 59, in setup_platform username = config.get(CONF_USERNAME) NameError: name 'CONF_USERNAME' is not defined

I'm not sure what goes wrong. The code looks alright. I'm running hass 0.80.2. any Ideas?

@Jbossalini
Copy link

I think the eval under def is_hass_component(): is not working. As a hack, I commented out that block, commented the if start/stop, updated the indentation for the remaining lines within the if, and then commented everything in the else block.

#def is_hass_component():
#    try:
#        import homeasssistant
#        return True
#    except ImportError:
#        return False

#if is_hass_component():
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD)
import homeassistant.helpers.config_validation as cv

from deps.sure_petcare import SurePetFlap
from deps.sure_petcare.utils import gen_device_id

import voluptuous as vol

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
})
#else:
    # Assume not running within home assistant.  This *does* mean that you
    # won't be able to run this test script if you have homeassistant
    # installed but, if you do, you're probably running (or can run) this
    # component from within hass anyway.
#    from sure_petcare import SurePetFlap
#    from sure_petcare.utils import gen_device_id

    # dummy dependencies
#    class Entity( object ):
#        pass

#    def Throttle( *args, **kwargs ):
#        def decorator( f ):
#            return f
#        return decorator

I plan on returning to this shortly to figure out a permanent fix.

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

No branches or pull requests

2 participants