Outdoor illuminance estimated from weather conditions

Yes, change:

    @property
    def should_poll(self):
        # For the system (i.e., EntityPlatform) to configure itself to
        # periodically call our async_update method any call to this method
        # during initializaton must return True. After that, for WU we'll
        # always poll, and for others we'll only need to poll during the ramp
        # up and down periods around sunrise and sunset, and then once more
        # when period is done to make sure ramping is completed.
        if not self._init_complete or self._using_wu:
            return True
        changing = 0 < self.sun_factor(dt_util.now()) < 1
        if changing:
            self._was_changing = True
            return True
        if self._was_changing:
            self._was_changing = False
            return True
        return False

to:

    @property
    def should_poll(self):
        return True

    @property
    def force_update(self):
        return True

Awesome, thanks! I just went ahead and changed the script, I’ll let you know if I see anything weird or not working properly.

As has been discussed, starting with HA 0.86, the folder layout in custom_components has changed. I’ve recently updated the installation instructions. custom_components.json (which is used by Custom Updater) has also been updated to be compatible with the new layout.

If you are installing this custom platform for the first time:

Then just follow the recently updated installation instructions

If you do not use Custom Updater, and are updating HA from before 0.86 to 0.86 or later:

Then you need to manually move/rename the file. The following Linux commands (or similar) should make the necessary changes:

# From config folder
cd custom_components
sudo -u homeassistant mkdir illuminance
sudo -u homeassistant mv sensor/illuminance.py illuminance/sensor.py

If you use Custom Updater, and are on a version of HA before 0.86:

Then you’ll need to update the following line in your configuration for custom_updater. Change:

  component_urls:
    - https://raw.githubusercontent.com/pnbruckner/homeassistant-config/master/custom_components.json

to:

  component_urls:
    - https://raw.githubusercontent.com/pnbruckner/homeassistant-config/master/custom_components_old.json

Once you update to HA 0.86 or later you should change it back.

If you use Custom Updater, and are on HA 0.86 or later:

Then you should be good to go. Just use the Custom Updater to install and/or update.

Note: You may need to clean up the old files after you install/update, if you care.

If anyone is wondering how to install this, the instructions are here . https://github.com/pnbruckner/homeassistant-config/blob/master/docs/custom_updater.md

Not sure if anyone else has upgraded to 0.89, but I did tonight and I’m getting this error:

Wed Mar 06 2019 20:41:44 GMT-0500 (Eastern Standard Time)

Error loading custom_components.illuminance.sensor. Make sure all dependencies are installed

Traceback (most recent call last): 
  File "/usr/src/app/homeassistant/loader.py", line 166, in _load_file 
    module = importlib.import_module(path) 
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
  File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _gcd_import 
  File "&lt;frozen importlib._bootstrap&gt;", line 983, in _find_and_load 
  File "&lt;frozen importlib._bootstrap&gt;", line 967, in _find_and_load_unlocked 
  File "&lt;frozen importlib._bootstrap&gt;", line 677, in _load_unlocked 
  File "&lt;frozen importlib._bootstrap_external&gt;", line 728, in exec_module 
  File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed 
  File "/config/custom_components/illuminance/sensor.py", line 25, in &lt;module&gt; 
    from homeassistant.components.sensor.yr import ( 
ImportError: cannot import name 'CONF_ATTRIBUTION' from 'homeassistant.components.sensor.yr' (/usr/src/app/homeassistant/components/sensor/yr.py)

I rolled back to 0.88.2 and everything was fine, so not sure what happened with YR.

You’re using a custom component. There’s a documented Breaking Change for custom components.

D’oh! I’ll try to fix that soon. Yet another ramification of the Great Migration.

EDIT: Hmm, this time it actually wasn’t the great migration. It was renaming CONF_ATTRIBUTION in sensor.yr to ATTRIBUTION, just like they did back in the 0.85 release with the Dark Sky Sensor.

Yeah, I’ve already changed the file structure, I have other custom components that are working fine, including @pnbruckner’s Life360 component. So I don’t think it’s that.

No worries man, was just hoping it wasn’t me. lol. Thanks for the great work you put into these components.

1 Like

got the same error

ERROR (MainThread) [homeassistant.loader] Error loading custom_components.illuminance.sensor. Make sure all dependencies are installed Traceback (most recent call last): File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 166, in _load_file module = importlib.import_module(path) File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load File "&lt;frozen importlib._bootstrap&gt;", line 950, in _find_and_load_unlocked File "&lt;frozen importlib._bootstrap&gt;", line 655, in _load_unlocked File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed File "/home/homeassistant/.homeassistant/custom_components/illuminance/sensor.py", line 25, in &lt;module&gt; from homeassistant.components.sensor.yr import ( ImportError: cannot import name 'CONF_ATTRIBUTION'

For latest release (just because I am not using it), it was required to disable the yr component integration

"""
from homeassistant.components.sensor.yr import (
    CONF_ATTRIBUTION as YRS_ATTRIBUTION)
"""

I was able to do that because I am using darksky.

This is the error in the logs I was facing:

2019-03-07 12:38:31 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.illuminance.sensor. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/home/ha/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 166, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ha/.homeassistant/custom_components/illuminance/sensor.py", line 25, in <module>
    from homeassistant.components.sensor.yr import (
ImportError: cannot import name 'CONF_ATTRIBUTION'
2019-03-07 12:38:31 ERROR (MainThread) [homeassistant.loader] Unable to find platform illuminance.

For some reason they decided to rename CONF_ATTRIBUTION to ATTRIBUTION in PR #21069. Working on a fix.

Released 2.0.2

Fixes problem caused by Yr Sensor change in HA 0.89 release.

3 Likes

Thank you very much! :slight_smile:

1 Like

Just upgraded the component and then upgraded back to 0.89. No more errors. Thanks for the quick turnaround!

1 Like

Can’t load the component due to problem with Dark Sky version 0.91

Yep. The Great Migration strikes again. :slight_smile: Luckily that’s now done.

See Issue #127, including a workaround until I can release a new version.

Released 2.0.5

Apparently HA 0.92 will require all custom components to have a manifest.json file. And the custom updater requires the component to have an __init__.py file to load other files. This release should work with 0.92 and the latest custom updater.

NOTE: Because of the reorganization, it’s possible the custom updater may not be able to simply update the component. You may need to install it again using the custom_updater.install service. You may want to get the latest version before updating to 0.92.

Released 2.1.0 in new HACS-compliant repo.

1 Like

@pnbruckner you might want to edit your first post. Some of the links in it are broken since there have been changes.