Skip to content

[Bug] Error updating data: 'NoneType' object has no attribute 'astimezone' #35

Description

@RonnyAL

Short summary 📝

Integration suddenly stopped working altogether, due to a NoneType object

Detailed description 📋

Discovered that the integration no longer provides any sensors. Tried updating Home Assistant, which made no difference. I'm guessing a previous update of Home Assistant broke this integration. It seems like event_time is no longer getting fetched, and becomes a NoneType object which breaks the integration.

Version 📌

0.2.2

Environment 🌐

Installation method Home Assistant OS
Core 2025.12.5
Supervisor 2025.12.3
Operating System 16.3
Frontend 20251203.3

Logs and screenshots 📂

Traceback (most recent call last):
  File "/config/custom_components/lunar_phase/coordinator.py", line 38, in _async_update_data
    attributes = await self.hass.async_add_executor_job(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        self.moon_calc.get_moon_attributes
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/lunar_phase/moon.py", line 169, in get_moon_attributes
    STATE_ATTR_NEXT_RISE: self.get_event_time("rise"),
                          ~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/config/custom_components/lunar_phase/moon.py", line 111, in get_event_time
    return event_time.astimezone(config_timezone)
           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'astimezone'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 419, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/lunar_phase/coordinator.py", line 47, in _async_update_data
    raise UpdateFailed(f"Error updating data: {err}") from err
homeassistant.helpers.update_coordinator.UpdateFailed: Error updating data: 'NoneType' object has no attribute 'astimezone'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/lunar_phase/__init__.py", line 43, in async_setup_entry
    await coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in async_config_entry_first_refresh
    await self._async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 352, in _async_config_entry_first_refresh
    raise ex
homeassistant.exceptions.ConfigEntryNotReady: Error updating data: 'NoneType' object has no attribute 'astimezone'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions