Working on lacrossealertsmobile.com component - Receive "object has no attribute" error on start


#1

Hello everyone,

I am working on a custom component for the lacrossealertsmobile.com service. These $30-50 wireless temp/humitdy sensors are perfect for hot tubs, aquariums, backyards, etc. They can be found on Amazon here.

I found a module on PyPi to interface with the API, and worked with the module’s creator to get it updated for Python 3. Hooray! I was able to get the direct API calls out of my custom component and was one step closer to the requirements for a PR.

My project is on Github here:

I have been using the custom component for a while now, and it works fine except for an issue when home assistant starts. Due to the way my three sensor objects inherit from the Entity object that calls the API, and the way Home Assistant works I suppose, their state() methods are called before the update() method, and I receive 3 errors in the following format:

AttributeError: 'LaCrosseAmbientSensor' object has no attribute '_ambient'

I guess I’m just looking for a nudge in the correct direction on how I should be handling this, because this clearly isn’t quite the right way.

I’m also wondering if the inheritance here is the correct approach, or if there is some other way about this I’m so far unaware of. The way it is now, I am guessing the update method gets called three times when really it only needs to get called once.

Thanks in advance for your reply!

Legomaniac


#2

Please keep me posted! Been going nuts trying to figure out the Jeelink thing.