@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
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:
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 "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/config/custom_components/illuminance/sensor.py", line 25, in <module>
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.
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.
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 "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/home/homeassistant/.homeassistant/custom_components/illuminance/sensor.py", line 25, in <module> 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.
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.