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

min_max doesn't wait for template entities to be ready #41931

Closed
Mariusthvdb opened this issue Oct 16, 2020 · 18 comments
Closed

min_max doesn't wait for template entities to be ready #41931

Mariusthvdb opened this issue Oct 16, 2020 · 18 comments

Comments

@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Oct 16, 2020

The problem

At startup, the min_max integration throws errors on entities which are template sensors. After startup, the integration does its job alright, and creates the ( in this case) average temperature based on the configuration

Environment

  • Home Assistant Core release with the issue: 116.4
  • Last working Home Assistant Core release (if known): not sure, but never saw this error before 116
  • Operating environment (OS/Container/Supervised/Core): OS
  • Integration causing this issue: Min max
  • Link to integration documentation on our website: https://www.home-assistant.io/components/sensor.min_max/

Problem-relevant configuration.yaml

  # https://www.home-assistant.io/components/sensor.min_max/
  - platform: min_max
    name: Mean indoor temp
    type: mean
    entity_ids:
      - sensor.temperatuur_living
      - sensor.dining_table_sensor_calibrated_temperature
      - sensor.auditorium_sensor_calibrated_temperature
      - sensor.frontdoor_sensor_calibrated_temperature
      - sensor.library_sensor_calibrated_temperature
      - sensor.dorm_sensor_calibrated_temperature
      - etc etc

these calibrated sensors are based on the core HUE sensors:

      dining_table_sensor_calibrated_temperature:
        friendly_name: Dining table calibr temp
        value_template: >
          {{(states('sensor.dining_table_sensor_temperature')|float +
             states('input_number.temp_calibration')|float)|round(2)}}
        unit_of_measurement: °C
        device_class: temperature

Traceback/Error logs

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 254, in _async_state_change_dispatcher
    hass.async_run_job(action, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 384, in async_run_job
    target(*args)
  File "/usr/src/homeassistant/homeassistant/components/min_max/sensor.py", line 164, in async_min_max_sensor_state_listener
    if new_state.state is None or new_state.state in [
AttributeError: 'NoneType' object has no attribute 'state'

Additional information

happening on reload of template entities too

@probot-home-assistant
Copy link

min_max documentation
min_max source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @fabaff, mind taking a look at this issue as its been labeled with an integration (min_max) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Oct 24, 2020

have we had some recognition of this issue yet?
on 117.0b3 now and still see this:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 258, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 434, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/min_max/sensor.py", line 210, in _async_min_max_sensor_state_listener
    if new_state.state is None or new_state.state in [
AttributeError: 'NoneType' object has no attribute 'state'

the lines in the error have changed so that's why I ask and report the error once more. Additional info: this also happens upon reload of template entities (because that's what the min-max sensor uses in my config).

@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 Jan 25, 2021
@Mariusthvdb
Copy link
Contributor Author

0n 2021.1.5 and haven't seen the error for some time now

@github-actions github-actions bot removed the stale label Jan 26, 2021
@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Feb 5, 2021

and they're back, probably simply missed it before:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 257, in _async_state_change_dispatcher
hass.async_run_hass_job(job, event)
File "/usr/src/homeassistant/homeassistant/core.py", line 435, in async_run_hass_job
hassjob.target(*args)
File "/usr/src/homeassistant/homeassistant/components/min_max/sensor.py", line 210, in _async_min_max_sensor_state_listener
if new_state.state is None or new_state.state in [
AttributeError: 'NoneType' object has no attribute 'state'

happening after each reload of the template entities.

template sensors havent changed, nor has the min_max sensor

this is on HA 2021.2.1 now

@Mariusthvdb
Copy link
Contributor Author

so we are on 2021.3.4 and on each restart/reload of templates this error returns.

consider the error catch in the integration is

        if new_state.state is None or new_state.state in [
            STATE_UNKNOWN,
            STATE_UNAVAILABLE,
        ]:

I have availability_templates on all relevant sensors:

        availability_template: >
          {% set id = states('sensor.corridor_sensor_temperature') %}
          {% set un = ['unknown','unavailable'] %}
          {{id not in un and id is not none}}

and still the error persists.

Please help me sort this?

@Mariusthvdb
Copy link
Contributor Author

keeping this alive before it is declared stale..
2021.4.0 and still there

@Mariusthvdb
Copy link
Contributor Author

@frenck sorry for the tag, but since this has been around for half a year now, could you please help me get some attention for the issue?

@frenck
Copy link
Member

frenck commented Apr 10, 2021

Please don't tag @Mariusthvdb, you know better.

@Mariusthvdb
Copy link
Contributor Author

wow, very helpful. thanks.

@Mariusthvdb
Copy link
Contributor Author

Hey Frenck, what's up..
No need to scrutinize me here, or privately like you just did, including threatening me on being warned now.

I excused myself for the tag in advance, and merely asked for help. Literally. What more need polite users do not to offend you.
I am amazed at this, truly.

a much friendlier answer could have been: ‘o sorry mariusthvbd, we skipped that one, lets have a look, it will take some more time, but you got our attention.
and btw, thank you for keeping such a keen eye for the bugs in our HA core, that’s what takes the project forward…’

Won't tag you again, and again sorry for that.
Cheers.

@frenck
Copy link
Member

frenck commented Apr 10, 2021

No need to scrutinize me here, or privately like you just did

image

☝️ For full transparency, attached a screenshot of the message you accused me of scrutinizing you. Which was more a general warning. I'm happy to do the warning publicly as well. You are around long enough to know that it is not appreciated to pull people into the conversation. (As made clear on how you started the ping in the first place).

My comment on private in Discord was meant to directly instead of putting out a warning here in public, just because you are around for a long time. But if you want it public this way, that is fine too.

There are many issues open and things rely on contributions. I don't have time for more contributions at this point as I'm already swamped with things I still need (well want) to do.

So I'm not sure what you expected to happen?

Really, as with all issues and PRs open, if anybody wants something to move faster, help out!

@Mariusthvdb
Copy link
Contributor Author

tbh, I would hope for senior dev's that aren't happy to scrutinize people at all, privately or publicly.

What I expected was some help 'getting this some attention', not for you to solve it in any way, right away.

Also, since you yourself were already in this conversation since oct 2020, I didnt think the harmless tag would be very 'impolite'.

I can see through the unnecessary abusive words you use, and do understand you don't want to be tagged al day long, by anyone, and I respect that. Goes without saying.

So, I don't want a warning at all, I expect some mutual respect, because that has 2 be bi-directional.

Enough said. I'll be glad to have a go at the issue at hand, but, I would need guidance and help for that.
Ultimately, that was what I was looking for, either assist in the notion of the bug, and/or be a part of a solution. I have no high hopes of the latter because of my skills on the subject though.

I would rather close this because of the discussion on the matter of the tag, but the core issue is still open, so I can't.

Hope to clear the air with this.

@frenck
Copy link
Member

frenck commented Apr 10, 2021

This is no longer about this issue at this point.

There was no scrutinizing, only a warning on behavior we generally don't appreciate. It is documented within our community as well. There is nothing personal about that, it just not helpful. Some devs turned of mention notifications because of it, which is even a worse outcome as communication becomes hard. Just... don't do it, please 🙏

Also, since you yourself were already in this conversation since oct 2020

I added a label to help categorizing issues, I did not take part in the conversion.

So, I don't want a warning at all, I expect some mutual respect, because that has 2 be bi-directional.

Just don't tag at random, thanks 👍

Enough said. I'll be glad to have a go at the issue at hand, but, I would need guidance and help for that.

We have our developer documentation to help you get started, if you have additional questions, we have developer channels on Discord for that 👍

@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Apr 10, 2021

ok thanks.
as it stands, I rather let it in the hands of the pro team now that we have that. It will be quicker if the dev teams tackles this, instead of having to answer all my questions in the process.

please don't let it die here, it is a nasty issue, which I, with the knowledge in templating and None type that I have right now, can't solve.

@Mariusthvdb
Copy link
Contributor Author

Mariusthvdb commented Apr 18, 2021

as of the last update HA 2021.4.4/5 this particular sensor doesnt even create anymore showing
Schermafbeelding 2021-04-18 om 15 34 49

in the frontend. I have 2 others that are still there, so the integration probably;y is working still. Though, I have set logger to debug on this integration

homeassistant.components.min_max.sensor: debug

nothing is displayed at all in the log.....

update
NM this latest additional issue: somehow the integration created a secondary mean_indoor_temp_2 sensor. Deleting the original (without the suffix) and restart made it reappear.

@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 Jul 29, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 17, 2021
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