Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_history error - takes one positional arguement but 2 were given #1990

Open
chris-hunter opened this issue Apr 14, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@chris-hunter
Copy link

What happened?

When using hass.get_history() I get an error saying that I have used 2 positional arguements - but I haven't, I have used one (the entity ID), and a keyword arguement (start_time). I have tried using the days keyword arguement and get the same error. I am using python 3.11 on ubuntu 22.04, appdaemon 4.4.2

Version

4.4.2

Installation type

Python virtual environment

Relevant log output

2024-04-14 18:59:00.012400 WARNING pi3_check: ------------------------------------------------------------
TypeError: Hass.get_history() takes 1 positional argument but 2 were given
^^^^^^^^^^^^^^^^^^^^^
return await coro(*args, **kwargs)
File "/opt/appdaemon/lib/python3.11/site-packages/appdaemon/plugins/hass/hassapi.py", line 30, in coro_wrapper
raise self._exception
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
^^^^^^^^^^^^^^^^^^^
return self.__get_result()
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
result = future.result(self.AD.internal_function_timeout)
File "/opt/appdaemon/lib/python3.11/site-packages/appdaemon/utils.py", line 313, in run_coroutine_threadsafe
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
File "/opt/appdaemon/lib/python3.11/site-packages/appdaemon/utils.py", line 231, in inner_sync_wrapper
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
H1 = self.get_history('climate.play_room_radiator_1_heat_demand', start_time = history_start_time)
File "/opt/appdaemon/apps/heating.py", line 29, in run_check
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/opt/appdaemon/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker
2024-04-14 18:59:00.011949 WARNING pi3_check: Traceback (most recent call last):
2024-04-14 18:59:00.009854 WARNING pi3_check: ------------------------------------------------------------
2024-04-14 18:59:00.009480 WARNING pi3_check: Worker Ags: {'id': 'f43d438c36f84b76b7ec134a0425c33c', 'name': 'pi3_check', 'objectid': 'a071accc286141dabdf1bdcfefc9bb38', 'type': 'scheduler', 'function': <bound method check_pi3.run_check of <heating.check_pi3 object at 0x7f8da826ed10>>, 'pin_app': True, 'pin_thread': 8, 'kwargs': {'interval': 86400, '__thread_id': 'thread-8'}}
2024-04-14 18:59:00.009051 WARNING pi3_check: Unexpected error in worker for App pi3_check:
2024-04-14 18:59:00.008573 WARNING pi3_check: ------------------------------------------------------------

Relevant code in the app or config file that caused the issue

history_start_time = datetime.now() - timedelta(hours=12)
H1 = self.get_history('climate.play_room_radiator_1_heat_demand', start_time = history_start_time)

Anything else?

No response

@chris-hunter chris-hunter added the bug Something isn't working label Apr 14, 2024
@0x414c49
Copy link

Use like this:

self.get_history(entity_id = "sensor", days = 5)

@hioctane61
Copy link

hioctane61 commented Jul 17, 2024

`history_start_time = datetime.now() - timedelta(hours=12)

H1 = self.get_history(entity_id="climate.play_room_radiator_1_heat_demand", start_time = history_start_time)`

you're using positional argument above for your sensor, that doesn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants