Limych / ha-iaquk

Indoor Air Quality Sensor Component for Home Assistant
MIT License
105 stars 15 forks source link

Fix state_class attribute for entities #116

Closed smarrk closed 11 months ago

smarrk commented 1 year ago

Proposed change

Since v2023.5 the IAQ-Level entities fail with

Sensor sensor.iaquk_home_indoor_air_quality_level has device class None, state class measurement and unit None thus indicating it has a numeric value; however, it has the non-numeric value: Good (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

This PR fixes the conflicts in the attribute definitions by only setting the state_class attribute for the IAQ-Index entities.

Type of change

Additional information

Checklist

billmaterial commented 1 year ago

Working for me now also, thanks for fixing this!

billmaterial commented 1 year ago

Updated to core 2023.5.3 and it does not work at all now, error in configuration.yaml: Component error: iaquk - Exception importing custom_components.iaquk

smarrk commented 1 year ago

Updated to core 2023.5.3 and it does not work at all now, error in configuration.yaml: Component error: iaquk - Exception importing custom_components.iaquk

@billmaterial Are you talking about this PR or the unchanged, "original" Code?

billmaterial commented 1 year ago

@smarrk I am talking about this PR, seems update to 2020.5.3 has stopped it from working with both the level and index not working now. I have reverted back to the original code for testing and there is no error in configuration.yaml but the air quality level again shows unknown. Going back to this PR same issue with config check: "error in configuration.yaml: Component error: iaquk - Exception importing custom_components.iaquk"

Logs show: Home Assistant Core Unexpected exception importing component custom_components.iaquk 12:26:31 – (ERROR) Indoor Air Quality UK Index (custom integration) - message first occurred at 12:26:17 and shows up 2 times Setup failed for custom integration iaquk: Unable to import component: Exception importing custom_components.iaquk 12:26:17 – (ERROR) setup.py

Hope this helps to fix the issue.

smarrk commented 1 year ago

@billmaterial This is strange: I'm also on HA 2020.5.3 and i'm unable to reproduce this. Can you provide me with your configuration section for the integration?

billmaterial commented 1 year ago

@smarrk Yes it is a very strange issue, I have not changed my configuration and had no issues until 2023.5.0 then I changed sensor.py according to this PR and it worked fine with 5.1 and 5.2, then stopped with 5.3??? I have my configuration.yaml reference iaquk.yaml by the way to avoid any confusion.

my configuration.yaml file:

iaquk: !include iaquk.yaml

my iaquk.yaml file:

office: name: "Office" sources: temperature: sensor.temperature_scd41 humidity: sensor.humidity_scd41 co2: sensor.co2_scd41

livingroom: name: "Living Room" sources: temperature: sensor.house_temperature humidity: sensor.house_humidity

smarrk commented 1 year ago

@billmaterial I'm afraid i'm still unable to reproduce this. Have you tried adding my forked repo as Custom repository in HACS instead of changing sensor.py manually? (You can remove the original integration and then add my forked one; restart afterwards)

billmaterial commented 1 year ago

@smarrk Fantastic it works!!! Thank you so much for your help on this, you are a star :)

rogodra commented 1 year ago

It works, thanks @smarrk

darkstoneathome commented 1 year ago

@Limych Could you review this merge request?

Limych commented 11 months ago

Thanks :heart: