-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
history_stats sensor displaying 'Unknown' after upgrading to 0.111.4 #37010
Comments
history_stats documentation |
There are no relevant errors in the log. I just updated to 0.112dev and still seeing the same thing. Is it possible to enable debug logging and / or see the query it's trying to run? |
You would need to modify recorder to echo and then use
|
I enabled the logging, then rolled back to 0.109.6 and my sensor works again. Here's the two queries: 0.109.6:
0.112dev:
These are the differences I notice: The new query has an additional clause: |
Is there anything else I can try or info I can provide to help debug this further? |
Can you try reverting #35719 on your instance and seeing if it fixes it? |
I installed 0.110.7 and that was working. I then installed 0.111.0 and the issue was present, so it's something in the 0.111.0 changes. I reverted #35719 and that didn't fix the issue. Any other ideas? |
You'll have to wait 24 hours for a reversion of #35719 to have effect as it will need to generate new rows in the database |
I've been running it with the reversion of #35719 for a few hours now. I changed my hvac_running sensor from 24 hours to 1 hour and it's still showing 'Unknown'. |
Please try the above change. This will give us raw sql queries that we can test with. |
Also, do you get results if you manually query the history api for https://developers.home-assistant.io/docs/api/rest/#get-apihistoryperiodtimestamp |
Also by chance, do you have |
Actually, the query I just posted is probably not from the history_stats sensor because it's doing a LIMIT 1. I think this is the right query:
|
The Limit 1 is to get the initial state for the left side of the graph |
So, if I use the API like this:
I only get results from the past hour or so, corresponding with when I had the sensor unhidden. If I run the above query in psql (modifying the time slightly):
I get all of the state change results for the past 24 hours, including the period when the sensor was hidden. The attributes column for a hidden row looks like: So it appears that the state change data is being saved regardless of whether the sensor is hidden, but the history_stats sensor must be ignoring rows where the |
The hidden check was added in #3674 for history and #3426 for logbook When history was refactored in 0.111, some code was de-duplicated and the hidden check now works for all history apis. We have a test to make sure history states with Removing the |
Ok, I guess I'll remove the hidden attribute then. Thank you for your help figuring this out! |
The problem
Upgraded from 0.109.6 to 0.111.4. I have a history_stats sensor that no longer works and just displays 'Unknown'.
Environment
arch | armv7l
dev | false
docker | false
hassio | false
installation_type | Home Assistant Core
os_name | Linux
os_version | 4.19.97-v7+
python_version | 3.7.3
timezone | America/Chicago
version | 0.111.4
virtualenv | true
database: postgres 11.7
Problem-relevant
configuration.yaml
Config for the sensor that's NOT working:
I also have another very similar history_stats sensor that IS working. Here's that config:
The text was updated successfully, but these errors were encountered: