home-assistant / home-assistant-notebooks

:notebook: Sample Jupyter Notebooks to explore Home Assistant data
https://data.home-assistant.io/
Other
63 stars 32 forks source link

Getting Started Notebook fails with Execute error #25

Open chicagoandy opened 1 year ago

chicagoandy commented 1 year ago

After a clean install of the Jupyter plugin I received the following error. The error persisted after updating the getting-started notebook to latest from this repository:

import detective.functions as functions import pandas as pd ​ db = detective.db_from_hass_config() YAML tag !include_dir_merge_named is not supported Successfully connected to database sqlite:////config/home-assistant_v2.db Error with query: SELECT DISTINCT(entity_id) FROM states

'Engine' object has no attribute 'execute'

AttributeError Traceback (most recent call last) Cell In[10], line 5 2 import detective.functions as functions 3 import pandas as pd ----> 5 db = detective.db_from_hass_config()

File /usr/local/lib/python3.9/dist-packages/detective/core.py:19, in db_from_hass_config(path, kwargs) 16 path = config.find_hass_config() 18 url = config.db_url_from_hass_config(path) ---> 19 return HassDatabase(url, kwargs)

File /usr/local/lib/python3.9/dist-packages/detective/core.py:57, in HassDatabase.init(self, url, fetch_entities) 55 print("Successfully connected to database", stripped_db_url(url)) 56 if fetch_entities: ---> 57 self.fetch_entities() 58 except Exception as exc: 59 if isinstance(exc, ImportError):

File /usr/local/lib/python3.9/dist-packages/detective/core.py:85, in HassDatabase.fetch_entities(self) 79 """Fetch entities for which we have data.""" 80 query = text( 81 """ 82 SELECT DISTINCT(entity_id) FROM states 83 """ 84 ) ---> 85 response = self.perform_query(query) 87 # Parse the domains from the entities. 88 self.entities = [e[0] for e in response]

File /usr/local/lib/python3.9/dist-packages/detective/core.py:73, in HassDatabase.perform_query(self, query, **params) 71 """Perform a query.""" 72 try: ---> 73 return self.engine.execute(query, params) 74 except: 75 print(f"Error with query: {query}")

AttributeError: 'Engine' object has no attribute 'execute'

geiseri commented 1 year ago

The notebook needs to be updated to deal with upstream API changes from https://github.com/robmarkcole/HASS-data-detective/pull/154. You can in the meantime use this notebook