I build an addon in HA with python code and much usage of get_state()
I have the problem reduced to a simple piece of testcode:
import hassapi as hass
from requests import get
class TestWM(hass.Hass):
def __init__(self):
self.hassurl = "http://192.168.178.80:8123/"
self.hasstoken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJmNmUwNjRhZmM0NTM0MDI5YmNjNzU2MDkzMTc3MmQ1NyIsImlhdCI6MTcxMjIzOTUxNiwiZXhwIjoyMDI3NTk5NTE2fQ.2sO0bo3gS81-7hW6CTDf5goQEavzdEUO7SImOb-UCu4"
super().__init__(hassurl=self.hassurl, token=self.hasstoken)
headers = {
"Authorization": "Bearer " + self.hasstoken,
"content-type": "application/json",
}
resp = get(self.hassurl + "api/config", headers=headers)
print(resp.text)
def test(self):
state = self.get_state("input_datetime.start_window").state
print(state)
test_wm = TestWM()
test_wm.test()
When I run this code against an HA machine with version 2024.3.3: no problems
But when I run with a machine with version 2404.4.0 I get this error:
Traceback (most recent call last):
File "/home/cees/prive/day_ahead/day-ahead/dao/prog/test_get_state.py", line 23, in <module>
test_wm.test()
File "/home/cees/prive/day_ahead/day-ahead/dao/prog/test_get_state.py", line 18, in test
state = self.get_state("input_datetime.start_window").state
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/cees/prive/day_ahead/env/lib/python3.11/site-packages/hassapi/client/states.py", line 13, in get_state
return State(**self._get(f"states/{entity_id}")) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: State.__init__() got an unexpected keyword argument 'last_reported'
Process finished with exit code 1
I have read the release notes but only found some information about a new attribute “last_reported”.
What am I doing wrong?