@Rui_Duarte wrote:
Hello!
I have been looking over the last few days for information on how to make a history_stat sensor that would have the start period based on the information coming from an input_date field and the end on “now()”. I read a lot of posts here and none were matching exactly what I needed.What I want to do?
I want to measure the time since the power consumption on that particular plug raises to a certain level (Have a TP Link HS110 for it) and I created a binary switch for that, as I know that roughly after 90 minutes the washing machine is supposed to finish its work. But there can exist interruptions in the middle of the cycle as I have a routine that stops some equipment when the usage of the main power is too much ( which drives my wife crazy…) and will resume it later. Also, when she is away, it will leave the last 10 minutes to when she is here, so that the clothing does not get all wrinkled… Finally, I will most likely not have just a single cycle during the day which would make the “normal” parameters for history stats not to fit what I want.
Everything is working properly, except for the history_stats sensor that has the following code:
- platform: history_stats name: tempo a lavar entity_id: binary_sensor.maq_lavar_roupa_lavar state: 'on' type: time start: '{{(states.input_datetime.inicio_lavagem_roupa.attributes.timestamp) | timestamp_local}}' end: '{{ now() | timestamp_local}}'
So, this configuration is giving me the following issues in the LOG, although the Check Config is OK:
2020-04-11 18:50:19 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.tempo_a_lavar fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/history_stats/sensor.py", line 180, in update self.update_period() File "/usr/src/homeassistant/homeassistant/components/history_stats/sensor.py", line 294, in update_period if start > dt_util.now(): TypeError: can't compare offset-naive and offset-aware datetimes
So , I checked this last statement and it seems that all has to do with date time formatting. I tried to force the same for start and end, but still the problem remains. What I am missing?
Looking forward to here from you!
Posts: 1
Participants: 1