jeroenterheerdt / HADailySensor

Sensor for Home Assistant that gets reset at midnight
MIT License
76 stars 19 forks source link

Adding sensor throws error #55

Closed Calimerorulez closed 5 months ago

Calimerorulez commented 6 months ago

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.

Calimerorulez commented 6 months ago

Reverting back to 2024.4.2 solves it.

jeroenterheerdt commented 5 months ago

I don't see this issue at all, it works fine for me.

jeroenterheerdt commented 5 months ago

can you explain a bit more of what you're doing?

Calimerorulez commented 5 months ago

Hi @jeroenterheerdt

When adding a new daily sensor, I select the sensor from which the new daily sensor should take its value. When done configuring the new sensor via the config flow introduced in .3, I see the new daily sensor is being created in the integration, but it does not save the (name) of the sensor from which it should take its value. When looking in the logging the error in the openings post is shown.

Existing daily sensors, created before the update to .3, continue to work, but newly created give me the error.

I suspect that it has something to do with the added config flow.

Groeten, Patrick

jeroenterheerdt commented 5 months ago

I am not seeing that at all... is there any chance you could do a uninstall, reboot, reinstall to see if that helps?

Giorsetti commented 5 months ago

Hello, I've uninstalled everything and restarted HA, but the problem is still the same. Before the update, at the beginning of the week, everything was operational. Here are the error messages:

This error comes from a custom integration

Recorder: homeassistant Source: custom_components/daily/sensor.py:155 Integration: Daily sensor (documentation, problems) First occurred: 17:32:06 (7 occurrences) Last recorded: 17:35:06

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'

Thank you.