Comments (7)
This seems to be a duplicate of the first part of #94. I do not close this issue yet, because it contains some investigation info.
from ha-average.
With core 2022.5.0 this has additional manifestation in the log: 2022-05-06 12:53:16 ERROR (SyncWorker_1) [custom_components.average.sensor] Could not convert value "<state sensor.dining_room_temperature=24.7 @ 2022-05-06T12:52:16.686611+02:00>" to float: None is not a recognized temperature unit.
Though with core 2022.5.1 the log entry is a bit different: 2022-05-06 13:50:12 WARNING (Recorder) [homeassistant.components.sensor.recorder] sensor.living_room_temperature_average_for_heater has unit None which is unsupported for device_class temperature
from ha-average.
I've added some extra debug info to the sensor.py, see: https://github.com/lmagyar/ha-average/commit/e9d6cafb96e287d198411292c960e5226b5b6e8c
And the log seems to be OK during startup, the unit_of_measurement is always filled out:
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Updating sensor "Bedroom Temperature Average"
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Process duration: 0:01:00
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Calculation period: start=2022-05-06 23:04:20.098217+02:00, end=2022-05-06 23:05:20.098217+02:00
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Processing entity "sensor.bedroom_temperature"
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Initialize sensor mode: sensor.bedroom_temperature - 22.5
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Unit of measurement (entry): None
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] sensor.bedroom_temperature is a temperature entity.
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Unit of measurement (exit): °C
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Initial historical state: <state sensor.bedroom_temperature=22.5; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=Bedroom SI7021 Temperature @ 2022-05-06T23:04:20.098217+02:00>
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Historical state: <state sensor.bedroom_temperature=22.5; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=Bedroom SI7021 Temperature @ 2022-05-06T23:04:20.098217+02:00>
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Historical state: <state sensor.bedroom_temperature=22.5; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=Bedroom SI7021 Temperature @ 2022-05-06T23:04:29.165116+02:00>
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Historical average state: 22.5
2022-05-06 23:05:20 DEBUG (SyncWorker_4) [custom_components.average.sensor] Total average state: 22.5 °C
Even with entities with unknown state (during startup, later OK):
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Updating sensor "Dining room Temperature Average"
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Process duration: 0:01:00
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Calculation period: start=2022-05-06 23:04:20.413899+02:00, end=2022-05-06 23:05:20.413899+02:00
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Processing entity "sensor.dining_room_temperature"
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Initialize sensor mode: sensor.dining_room_temperature - unknown
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Unit of measurement (entry): None
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] sensor.dining_room_temperature is a temperature entity.
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Unit of measurement (exit): °C
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Initial historical state: <state sensor.dining_room_temperature=23.5; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=Dining room SI7021 Temperature @ 2022-05-06T23:04:20.413899+02:00>
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Historical state: <state sensor.dining_room_temperature=23.5; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=Dining room SI7021 Temperature @ 2022-05-06T23:04:20.413899+02:00>
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Historical state: <state sensor.dining_room_temperature=23.5; state_class=measurement, unit_of_measurement=°C, device_class=temperature, friendly_name=Dining room SI7021 Temperature @ 2022-05-06T23:04:27.652906+02:00>
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Historical average state: 23.5
2022-05-06 23:05:20 DEBUG (SyncWorker_0) [custom_components.average.sensor] Total average state: 23.5 °C
So from now on I have no clue where from the unit_of_measurement = None
in the recorded data comes from, but they are definitely there.
from ha-average.
The only workaround I've found is to add as a customize entry the unit_of_measurement to the entity, like:
homeassistant:
customize:
sensor.working_room_temperature_average:
unit_of_measurement: °C
Then I've stopped core, deleted all the recorded average entries from the database:
DELETE states, state_attributes FROM state_attributes INNER JOIN states ON state_attributes.attributes_id=states.attributes_id
WHERE states.entity_id = "sensor.NAME_OF_YOUR_AVERAGE_SENSOR"
Then core start, and this was the first entry:
{
"state_class":"measurement",
"friendly_name":"Living room Temperature Average",
"unit_of_measurement":"\u00b0C"
}
Problem "solved" with this workaround.
from ha-average.
This seems to be the problem for the unit of measurement disappearing.
Fix seems to be simple.
from ha-average.
Nice! I will test it immediately. :)
from ha-average.
I've tested it multiple times, with database cleanup, and works.
As I see it is already merged.
Closing.
from ha-average.
Related Issues (20)
- Average Sensor is Unavailable due to Get_Instance error in log. HOT 5
- Possible Service Call To Reset An Average? HOT 1
- Configuration items HOT 1
- Add Interval Option HOT 3
- Data from the current month only HOT 1
- Looks like HA 2022.10 is breaking this component again HOT 1
- Fix hasn't worked: Average sensor still records lot of unnecessary attribute in the recorder that fills up the database quite fast HOT 1
- Issue in 2022.10.x Temperature HOT 4
- Shut be updated!? HOT 4
- Multiple Entity calculation timeout
- Sensor fails if temperature unit is "f" vs "F" HOT 1
- How to avoid error on HA Startup when entity is not available? HOT 1
- convert_temperature issue/error HOT 5
- Set interval using GUI
- Posibility restrict use only last value from dedicated scanning period.
- Problem with propagation of temperature unit when averaging a statistics helper
- Frequency of sensor update HOT 3
- Hi, the integration seems to break in HA 23.3.1 HOT 11
- This integration will stop working with Home Assistant 2023.4 HOT 8
- can't get average temperature over a 1 day period of last week HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ha-average.