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

“Statistics sensor” from an “Filter sensor” don’t work (unavailable) #78912

Closed
Gferretta opened this issue Sep 22, 2022 · 5 comments
Closed

Comments

@Gferretta
Copy link

The problem

Hi

I have an:

  1. Sonoff TH16 Temperature and Humidity sensor
  2. An Template sensor over last (1) for accuracy setting if needed
  3. An Filter sensor over last (2) for low/high pass

What I am wanting to do is have statistical sensors defined on the filter sensor (3) to be able to save the minimum/maximum/average values according to different time values.

The problem is that in the statistics, when using the filter sensor (3), I ALWAYS receive "unavailable".

But if I use the template sensor (2) in the statistics, I immediately begin to have values and they adjust correctly.

My question is enlarged because I have correctly saved the history on the filter (3) since I can use the statistics card on that sensor in lovelace.

I have followed all the new settings defined in: https://www.home-assistant.io/integrations/statistics/

Any idea if it can or am I doing something wrong? It's Possible to do?

Thanks

Example:

(1)
sonoff:
   sensor: sonoff_123456789

(2)
template:
  - sensor:
     - name: humidity_th16
       unique_id: hum1
       device_class: humidity
       state_class: measurement
       unit_of_measurement: '%'
       state: >
          {{ (states('sensor.sonoff_123456789_humidity')|float(0)*0.98)|round(1) }}

sensor:
(3)
- platform: filter
  name: "FHum1"
  entity_id: sensor.hum1
  filters:
    - filter: lowpass
      time_constant: 20
      precision: 1
(4.a)  DON'T WORK
- platform: statistics
  name: "MAX FHum1 for 24 hours"
  entity_id: sensor.fhum1
  state_characteristic: value_max
  max_age:
    hours: 24
  sampling_size: 200
  precision: 1
(4.b)  WORK OK
- platform: statistics
  name: "MAX Hum1 for 24 hours"
  entity_id: sensor.hum1
  state_characteristic: value_max
  max_age:
    hours: 24
  sampling_size: 200
  precision: 1

What version of Home Assistant Core has the issue?

core-2022.9.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

statistics

Link to integration documentation on our website

https://www.home-assistant.io/integrations/statistics/

Diagnostics information

.

Example YAML snippet

.

Anything in the logs that might be useful for us?

.

Additional information

.

@probot-home-assistant
Copy link

statistics documentation
statistics source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @fabaff, @ThomDietrich, mind taking a look at this issue as it has been labeled with an integration (statistics) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@ThomDietrich
Copy link
Contributor

ThomDietrich commented Oct 1, 2022

Hello @Gferretta,
thanks for posting the issue. Your config looks reasonable to me. This is probably not a bug with the integration.

Your statistics sensor 4a "does not work" you say. Not sure what that means.

Please try the following code. Let sensor.fhum1 collect values for a few minutes, then send us a screenshot of the graph and attributes the statistics sensor

sensor:
  platform: filter
  name: "FHum1"
  entity_id: sensor.hum1
  filters:
    - filter: outlier
        window_size: 3
        radius: 999

- platform: statistics
  name: "MAX FHum1 for 24 hours"
  entity_id: sensor.fhum1
  state_characteristic: count
  max_age:
    hours: 24
  sampling_size: 9999

@Gferretta
Copy link
Author

Hello @Gferretta, thanks for posting the issue. Your config looks reasonable to me. This is probably not a bug with the integration.

Your statistics sensor 4a "does not work" you say. Not sure what that means.

Please try the following code. Let sensor.fhum1 collect values for a few minutes, then send us a screenshot of the graph and attributes the statistics sensor

sensor:
  platform: filter
  name: "FHum1"
  entity_id: sensor.hum1
  filters:
    - filter: outlier
        window_size: 3
        radius: 999

- platform: statistics
  name: "MAX FHum1 for 24 hours"
  entity_id: sensor.fhum1
  state_characteristic: count
  max_age:
    hours: 24
  sampling_size: 9999

What I meant by "NOT working" is that it does not bring the maximum/minimum values of an "Filter"

I have made the changes you have proposed and I will show you the results shortly
Regards and thank you very much

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 30, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants