robmarkcole/Hue-sensors-HASS

name '_LOGGER' is not defined

Mariusthvdb opened this issue · 8 comments

with the new ini.py. this error is logged

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/hue_custom/__init__.py", line 22, in update_api
    await api.update()
  File "/usr/local/lib/python3.7/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.7/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
concurrent.futures._base.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/hue_custom/remote.py", line 254, in update_bridge
    available = await update_api(bridge.api.sensors)
  File "/config/custom_components/hue_custom/__init__.py", line 24, in update_api
    _LOGGER.debug("Failed to fetch sensors: %s", err)
NameError: name '_LOGGER' is not defined

How irritating, that should be fixed by adding to __init__.py the following:

import logging
_LOGGER = logging.getLogger(__name__)

Can you test?

sure will do!
should I take that out of the other files then?

and what to replace that with.

no leave them alone

that fixed it..

OK is the error message "Failed to fetch sensors: %s" even useful?

Must admit I've never seen it ;-)
Still, if it were to be relevant, Id like to know what happened.

at each startup, I see this for all my motion sensors:

2020-02-11 18:15:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.dorm_motion_sensor_temperature fails
lots of text...
  File "<template>", line 2, in top-level template code
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

after which that never appears again. Only for the temp sensors.
Still, good to know the system isn't ready for the sensors yet, or vice versa.

Anyway, some sort of error reporting would be nice.

Hold on, are you reporting a second issue or do you get this error in place of the first one with the fix applied?

@Mariusthvdb can you test out https://github.com/robmarkcole/Hue-sensors-HASS/tree/fix-213 and report? Thanks

No, no new error.

Think this is a Ha related error and has always been there.
Will test 213 later today, have to fly now , sorry