Code Monkey home page Code Monkey logo

Comments (6)

PiotrMachowski avatar PiotrMachowski commented on June 8, 2024

Can you try to make a following change in the code (in __init__.py file) and check if it works?

...
-    @asyncio.coroutine
-    def async_added_to_hass(self):
-        state = yield from self.async_get_last_state()
+    async def async_added_to_hass(self):
+        state = await self.async_get_last_state()
         if state is not None \
                 and state.attributes is not None \
...

from home-assistant-custom-components-saver.

syphernl avatar syphernl commented on June 8, 2024

After changing that a new error popups up:

Traceback (most recent call last):
  File "/srv/hass/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1074, in get_code
  File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/hass/.homeassistant/custom_components/saver/__init__.py", line 150
    state = yield from self.async_get_last_state()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'yield from' inside async function

from home-assistant-custom-components-saver.

PiotrMachowski avatar PiotrMachowski commented on June 8, 2024

It looks like you haven't applied all changes from the fragment I have posted above. The updated code should look the following way:

    @property
    def state(self):
        return len(self._entities_db) + len(self._variables_db)

    async def async_added_to_hass(self):
        state = await self.async_get_last_state()
        if state is not None \
                and state.attributes is not None \
                and "variables" in state.attributes and not isinstance(state.attributes["entities"], list) \
                and "entities" in state.attributes and not isinstance(state.attributes["variables"], list):
            self._variables_db = state.attributes["variables"]
            self._entities_db = state.attributes["entities"]

from home-assistant-custom-components-saver.

syphernl avatar syphernl commented on June 8, 2024
state = await self.async_get_last_state()

Ah you're right. I only changed the first part earlier today. The full change seems to work fine as entity saver.saver is now back.

from home-assistant-custom-components-saver.

PiotrMachowski avatar PiotrMachowski commented on June 8, 2024

Great, thank you. I will adjust the integration 👍

from home-assistant-custom-components-saver.

PiotrMachowski avatar PiotrMachowski commented on June 8, 2024

Fixed in v1.1.5

from home-assistant-custom-components-saver.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.