jeroenterheerdt / hadailysensor Goto Github PK
View Code? Open in Web Editor NEWSensor for Home Assistant that gets reset at midnight
License: MIT License
Sensor for Home Assistant that gets reset at midnight
License: MIT License
I have a max sensor based on the DSMR voltage sensor.
This is not available when HADailySensor is starting and thus gives an error.
Logger: custom_components.daily.sensor Source: custom_components/daily/sensor.py:156 integration: Daily Sensor ([documentation](https://github.com/jeroenterheerdt/HADailySensor), [issues](https://github.com/jeroenterheerdt/HADailySensor/issues)) First occurred: 16:00:21 (6 occurrences) Last logged: 16:00:27 unable to convert unavailable to float. Please check the source sensor (sensor.electricity_meter_voltage_phase_l1) is available.
Adding an availability template to each daily_sensor would prevent this.
hi i install your plugin!! all working fine but at 0:00 no reset of the data ...
i have tried to create an automation but i have this error: (Message malformed: Service daily.stromverbrauch pro tag_reset does not match format . for dictionary value @ data['action'][0]['service'])
any idea...?
2023-03-02 21:39:22.334 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.daily.sensor
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 779, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 796, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1149, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/homeassistant/.homeassistant/custom_components/daily/sensor.py", line 40, in
class DailySensor(DailySensorEntity):
File "/home/homeassistant/.homeassistant/custom_components/daily/sensor.py", line 49, in DailySensor
@asyncio.coroutine
^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'
2023-03-02 21:39:22.344 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform daily.sensor: Platform not found (Exception importing custom_components.daily.sensor).
2023-03-02 21:39:22.349 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.daily.sensor
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 779, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 796, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1149, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/homeassistant/.homeassistant/custom_components/daily/sensor.py", line 40, in
class DailySensor(DailySensorEntity):
File "/home/homeassistant/.homeassistant/custom_components/daily/sensor.py", line 49, in DailySensor
@asyncio.coroutine
^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'
2023-03-02 21:39:22.355 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform daily.sensor: Platform not found (Exception importing custom_components.daily.sensor).
2023-03-02 21:39:22.358 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.daily.sensor
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 779, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/homeassistant/lib/python3.11/site-packages/homeassistant/loader.py", line 796, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1149, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/home/homeassistant/.homeassistant/custom_components/daily/sensor.py", line 40, in
class DailySensor(DailySensorEntity):
File "/home/homeassistant/.homeassistant/custom_components/daily/sensor.py", line 49, in DailySensor
@asyncio.coroutine
^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'
2023-03-02 21:39:22.364 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform daily.sensor: Platform not found (Exception importing custom_components.daily.sensor).
Since I made updates yesterday to the HADailySensor and Home assistant core (2024.6.0?), none of the daily sensors is updateing anymore. Instead I get the following in the log file
2024-06-07 09:49:38.169 INFO (MainThread) [custom_components.daily] Updating Daily Sensor HoymilesMaxofDaykWh
2024-06-07 09:49:38.174 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved (None)
Traceback (most recent call last):
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/daily/sensor.py", line 72, in
lambda event: self._handle_update( # pylint: disable=unnecessary-lambda
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/daily/sensor.py", line 102, in _handle_update
the_val = self.convert_to_float(input_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/daily/sensor.py", line 155, in convert_to_float
return float(float_value)
^^^^^^^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'State'
Any clue to what has happened?
BR, Jörg.
I changed out some sensors, so I was redefining the daily sensors I use. I first deleted the daily sensors that were to be redefined. The first redefinition worked without problems. When I tried to redefine the second daily sensor, a dialog box saying "aborted" popped up. I tried restarting HA, but the problem persisted.
I noticed that the HA integrations screen froze after the attempted redefinition. Refreshing the page cleared the frozen screen.
There is a bug in helpers.py
, there is no reference to self
(used in exception handling). See logs below:
2024-06-08 14:08:18.551 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/daily/helpers.py", line 28, in convert_to_float
return float(float_value)
^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: 'unknown'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/daily/sensor.py", line 74, in <lambda>
lambda event: self._handle_update( # pylint: disable=unnecessary-lambda
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/daily/sensor.py", line 100, in _handle_update
the_val = convert_to_float(input_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/daily/helpers.py", line 32, in convert_to_float
float_value, self.coordinator.input_sensor
^^^^
Hello,
Here is my es.json file:
https://drive.google.com/file/d/1jKjdYVLmfJH3bYJZbwofB6hbPrN3b8TF/view?usp=sharing
Hi,
I'm trying to add a sensor, but the following error is thrown in the HA log:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/daily/sensor.py", line 38, in async_setup_entry
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'coordinator'
The sensor is created, but it shows no entity in the details.
Hi!
I just saw your new component in HACS and was trying to use it in a slightly different case.
What I am wanting to achieve is to track how long a media player is in a specific state. Would it be possible to set this up so you can track a specific state?
This might be beyond the design on this component, and that's okay - but I thought it would be worth asking 😄 .
For example, how long was a media player in the "playing" state. Another use would be tracking how long a device was online or offline. Do you think this is something you would be able to add to this sensor?
Thanks!
DeadEnd
Hi,
These are the logs:
2020-07-23 12:08:26 ERROR (SyncWorker_0) [custom_components.daily.sensor] unable to convert unavailable to float.
2020-07-23 12:08:26 ERROR (SyncWorker_0) [custom_components.daily.sensor] unable to convert to float.
2020-07-23 12:38:26 ERROR (SyncWorker_2) [custom_components.daily.sensor] unable to convert unavailable to float.
2020-07-23 12:38:26 ERROR (SyncWorker_2) [custom_components.daily.sensor] unable to convert to float.
Hi,
Is it possible to get the sensor to show the maximum over the past hour, every hour?
By default, with 60-minute intervals, it seems to update the sensor max value only when the max in the last hour exceeds the previous max that day.
Then I thought I could achieve this by resetting the sensors every sixty minutes and having a 60-minute duration, but instead my daily sensors are unknown.
I am trying to see track my maximum electrical current drawn in one-hour bins.
As described, I installed HADailySensor via HACS and restarted HA.
Install the custom component (preferably using HACS) and then use the Configuration --> Integrations pane to search for 'Daily Sensor'.
But when I go to Configuration -> Integrations pane, I don't see the Daily Sensor and cannot configure one.
arch | x86_64
-- | --
dev | false
docker | false
hassio | false
installation_type | Home Assistant Core
os_name | Linux
os_version | 5.4.0-37-generic
python_version | 3.8.2
timezone | Europe/Vaduz
version | 0.111.4
virtualenv | true
Frontend-Version: 20200603.3 - latest
What can I do ?
After the update I get "not Available anymore"
No idea how to solve this.
Regards Janus
`Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
Logger: homeassistant.loader
Source: custom_components/daily/sensor.py:49
Integration: Daily Sensor (documentation, issues)
First occurred: 08:51:06 (5 occurrences)
Last logged: 08:51:06
Unexpected exception importing platform custom_components.daily.sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform
cache[full_name] = self._import_platform(platform_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1206, in _gcd_import
File "", line 1178, in _find_and_load
File "", line 1149, in _find_and_load_unlocked
File "", line 690, in _load_unlocked
File "", line 940, in exec_module
File "", line 241, in _call_with_frames_removed
File "/config/custom_components/daily/sensor.py", line 40, in
class DailySensor(DailySensorEntity):
File "/config/custom_components/daily/sensor.py", line 49, in DailySensor
@asyncio.coroutine
^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'
`
As the title suggests: save the datetime the max/min occured at as an attribute to each sensor. This would be incredibly helpful for displaying (in the entity card etc) when the max/min etc occured.
Please reply if you have any other questions about this. I love your work on this integration. Thanks!
Is it possible to give some examples how to use the dailysensor.
I want it to use for some temperature sensors, but i don't know how it works.
It's working now
After upgrading HA to version 2021.3, it comes with a logfile entry:
WARNING (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'daily'. This will not be allowed in a future version of Home Assistant. Please report this to the maintainer of 'daily'
Can you intergrate version keys to the custom components.
This is looking like a great alternative to the average sensor that is broken and unsupported as of 2022.5
What I'd really like is to be able to have the state of the sensor say the average and also have minimum and maximum as attributes.
Thanks for this great tool, after a long search it has finally enabled me to track the max peak of the photovoltaic system for each day. Since the fluctuations sometimes happen within seconds when the sky is cloudy, my question is: Is it possible to set the query sequence of the daily sensor in the seconds range?
I'm starting to use this and love what can do. This is very well done! A couple of questions:
I do have a min/max-Helper sensor with the name sensor.aussentemperatur
When I try to use this sensor as source for daily sensor, it always claims that one or more sensors do not exist and refuses to install the daily sensor
Any idea?
Hi
after updating my HA to 2023.5.2 this warning is shown in the logs:
Entity sensor.fritz7490mindailysent (<class 'custom_components.daily.sensor.DailySensor'>) is using self.async_update_ha_state(), without enabling force_update. Instead it should use self.async_write_ha_state(), please report it to the custom integration author
Using HA core installation in Python VENV with Python 3.10
Armin
Currently, the sensor loses all historical data when HA is being restarted. Therefore, after a restart, the aggregation is not "daily" any more but only from after the time when HA has restarted.
Would it be possible to load the input sensor data from the database upon HA restart and start with a true daily calculation right away? Ideally using a configuration option whether to include historical data (load from DB upon start) or not (start blank)?
Just freshly installed your Integration, which looks exactly what i need!
The first Sensor (Max for the Daily Temperature) went instantly fine.
The second Sensor (Max for the Daily Temperature) didnt work. After Setup it said "sucessful", but under "Integration Entities" it shows the new name i set up, but there is no Entity belonging to it.
2024-05-12 21:51:39.214 INFO (MainThread) [custom_components.daily] auto_reset: True
2024-05-12 21:51:39.215 INFO (MainThread) [custom_components.daily] registered for time change.
2024-05-12 21:51:39.215 INFO (MainThread) [custom_components.daily] Updating Daily Sensor klima_temperatur_aussen_dwd_dailymin
2024-05-12 21:51:39.216 DEBUG (MainThread) [custom_components.daily] Finished fetching klima_temperatur_aussen_dwd_dailymin data in 0.000 seconds (success: True)
2024-05-12 21:51:39.217 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up daily platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/daily/sensor.py", line 38, in async_setup_entry
coordinator = hass.data[DOMAIN][entry.entry_id][COORDINATOR]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'coordinator'
I am using v2024.4.3
HomeAssistant 2024.5.3
HAOS 12.3
Any Idea what might be the Reason - and Solution? 😄
Downloaded Daily Sensor with hacs into core-2022.3.4. It doesn't show in 'add integrations'. HassOS running on an XU4.
I am not able to delete a daily sensor. Is there a way to achieve this (apart from deleteing it in the .storage/core.config_entries)?
When esphome looses connecting to a node the entity referred in the daily sensor becomes unavailable. This leads to a bunch of errors in the log until the connection is re-established and the entity becomes available again.
2021-05-28 06:35:22 WARNING (MainThread) [homeassistant.components.esphome] Can't connect to ESPHome API for energymeter (192.168.0.84): Timeout while connecting to ('192.168.0.84', 6053)
2021-05-28 06:35:34 WARNING (MainThread) [homeassistant.components.esphome] Error getting initial data for 192.168.0.84: Timeout while waiting for API response!
2021-05-28 06:35:43 ERROR (SyncWorker_46) [custom_components.daily.sensor] unable to convert unavailable to float.
2021-05-28 06:35:43 ERROR (SyncWorker_46) [custom_components.daily.sensor] unable to convert to float.
2021-05-28 06:35:43 ERROR (SyncWorker_46) [custom_components.daily.sensor] unable to convert unavailable to float.
2021-05-28 06:35:43 ERROR (SyncWorker_46) [custom_components.daily.sensor] unable to convert to float.
2021-05-28 06:35:43 ERROR (SyncWorker_46) [custom_components.daily.sensor] unable to convert unavailable to float.
2021-05-28 06:35:43 ERROR (SyncWorker_46) [custom_components.daily.sensor] unable to convert to float.
HI, I am new in homeassistant. I would like to have an example of your integration to put in the configuration.yaml. I tried this and it didn't work.
daily:
name: max_airtemp
sensor: sensor.lumi_airt
operation: max
interval: 1
unit_of_measurement: °C
friendly_name: "Max airtemp"
Thanks!
Hi,
would it be possible to have the daily sensor not to update after a specfifc time interval but instead whenever the main sensor changes it's value? My goal is to display the min and max temperature next to the actual temperature on my Dashboard and it looks kind of wrong if it get's warmer than the current max temp but the sensor takes a while to update and thus shows a wrong value. Sure, I could just reduce the time interval but imo the better alternative would be to automatically update the daily sensor based on state changes.
Thanks for this great integration. Helped me to get rid of multiple helpers and Node Red flows.
Any plans to add a daily sensor for the PREVIOUS day as well?
In the HA logs, I get this warning - probably since the 2021.12 releases.
Entity sensor.max_temp (<class 'custom_components.daily.sensor.DailySensor'>) implements device_state_attributes. Please report it to the custom component author.
I upgraded to v0.3.5 yesterday and have noticed that the HADaily Sensor did not get reset at 12AM. Could you look into this?
I have attached a screenshot of the daily sensor for the last 4 days. The yellow highlights show that the sensor starts with 0 at 12AM. However, it did not get reset on 12 Aug as shown by the pink highlight and continued where it left off from yesterday.
After upgrading to v2024.42 my sensors update every 30 second instead of every 30 minute (mentioned in the changelog as a breaking change, but not updated in the README btw...).
How do I reconfigure my sensors? I can't find any way to do that in the UI.
Hi, i am pretty new in HA and maybe too stupid. But i can not find how to set the parameters in config.YAML
The feature is exactlywhat i need. Pls where can,i find the how-to ?
Thx
Is there a way to edit / change parameters i.e. Interval without having to delete the entity and resubmiting ?
Is there a way to automatically populate the entity field with a droplist of choices and a droplist of choices for the unit if measurement. In my opinion this would greatly increase usability of your excellent work
Bedankt
G
Hi. Do I need to download a specific repo for this? Cause can't seem to find this integration in HACS no matter where I search
don't take into account, I was just blind.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.