Custom component to declare/set variables

YES!
Same problem like other custom_components have.

check here also:

full error in log:

2018-12-13 11:36:59 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.variable. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    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 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 "/config/custom_components/variable.py", line 20, in <module>
    from homeassistant.helpers.restore_state import async_get_last_state
ImportError: cannot import name 'async_get_last_state'
2018-12-13 11:36:59 ERROR (MainThread) [homeassistant.loader] Unable to find component variable
2018-12-13 11:36:59 ERROR (MainThread) [homeassistant.config] Package package_motion setup failed. Component variable does not exist (See /config/packages/package_motion.yaml:6).

@VDRainer would you be able to check if the solution in your other component could also be used in the component Variable? Maybe @rogro82 could you have a look what’s wrong?

Looks like this has been fixed.
https://github.com/rogro82/hass-variables/pull/9

1 Like

ah yes, nice! really need this component…
thanks , and to @rogro82 for fixing!

Yes it should work again, I just merged the fix for 0.84 ( thanks to Tobias )

it does work, I can confirm, downloaded from your repo and replaced the old version.
Thank you very much.

btw this is on 0.84.1

It seems that after upgrading HA to 0.84.2 (and applying the latest hass-variables fix), variables with "restore": true don’t preserve their state after HA restart anymore. I have opened a new bug: https://github.com/rogro82/hass-variables/issues/11.

Hi i just upgraded to 0.84.2 and updated the variable.py. Still getting errors.

2018-12-16 11:58:36 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.variable. Make sure all dependencies are installed

Traceback (most recent call last):

File "/usr/src/app/homeassistant/loader.py", line 92, in get_component

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 994, in _gcd_import

File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load

File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked

File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked

File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module

File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed

File "/config/custom_components/variable.py", line 14, in &lt;module&gt;

from homeassistant.helpers.restore_state import async_get_last_state

ImportError: cannot import name 'async_get_last_state'

2018-12-16 11:58:36 ERROR (MainThread) [homeassistant.loader] Unable to find component variable

Any help please…

I have the same problem. Hope having a solution soon

Have a look here

1 Like

Are you sure you updated to the latest variable.py correctly because your log shows an import from the previous version:

File "/config/custom_components/variable.py", line 14, in &lt;module&gt;
from homeassistant.helpers.restore_state import async_get_last_state
ImportError: cannot import name 'async_get_last_state'

Line 14 should be:

Thank you

Hi there, when I tried to install the custom component HA complains on startup:

2018-12-20 15:43:36 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.variable. Make sure all dependencies are installed
Traceback (most recent call last):
File “/home/homeassistant/.pyenv/versions/3.6.3/envs/homeassistant-3.6.3/lib/python3.6/site-packages/homeassistant/loader.py”, line 92, in get_component
module = importlib.import_module(path)
File “/home/homeassistant/.pyenv/versions/3.6.3/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 678, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/home/homeassistant/.homeassistant/custom_components/variable.py”, line 14, in
from homeassistant.helpers.restore_state import RestoreEntity
ImportError: cannot import name ‘RestoreEntity’

Do I need to install the dependency?

You need to run 0.84.x for the latest version of this component.

Ah thanks… that solved my problem! :wink:

Just pushed an update to github which should fix this issue.

HI @rogro82

would you care to make this card ‘trackable’ by the custom_component updater card please? https://github.com/custom-cards/tracker-card

would make updating you CC so much more comfortable .

thanks for considering

2 Likes

could it be that the restore state functionality of the Variable component is somehow compromised lately?

On each restart my variables lose their history, while I have enabled restore:

variable:
  solar_angle_outside_light:
    value: 'Not set'
    restore: true
    attributes:
      icon: mdi:format-rotate-90
      name: 'Solar angle'

  virtual_light_outside_light:
    value: 'Not set'
    restore: true
    attributes:
      icon: mdi:brightness-5
      name: 'Virtual light'

I did move from the default recorder to MariaDB lately but still have variable included in the domains in recorder,yaml. HA 84.3

Do you use the latest version of hass-variables? This issue has been fixed already - see https://github.com/rogro82/hass-variables/issues/11 .

yes I have dl’d that version, and think (…) it worked al right.
Unfortunately this component hasn’t got a version number in the file, and can’t be tracked by the updater card, but I’ve secured it manually