Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WeatherFlowCloud error when no lightning_last_strike #124071

Open
stuartparmenter opened this issue Aug 16, 2024 · 6 comments
Open

WeatherFlowCloud error when no lightning_last_strike #124071

stuartparmenter opened this issue Aug 16, 2024 · 6 comments

Comments

@stuartparmenter
Copy link

The problem

I get an error in the logs often related to lightning_last_strike. In the tempest app, it just shows lightning strikes: 0

What version of Home Assistant Core has the issue?

core-2024.8.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

weatherflow_cloud

Link to integration documentation on our website

https://www.home-assistant.io/integrations/weatherflow_cloud

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:598
integration: Sensor (documentation, issues)
First occurred: August 15, 2024 at 4:22:50 PM (2 occurrences)
Last logged: 7:06:43 AM

Error adding entity sensor.myhouse_lightning_last_strike for domain sensor with platform weatherflow_cloud
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1366, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 542, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weatherflow_cloud/sensor.py", line 208, in native_value
    return self.entity_description.value_fn(self.station.observation.obs[0])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weatherflow_cloud/sensor.py", line 161, in <lambda>
    value_fn=lambda data: datetime.fromtimestamp(
                          ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

Additional information

No response

@home-assistant
Copy link

Hey there @jeeftor, mind taking a look at this issue as it has been labeled with an integration (weatherflow_cloud) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of weatherflow_cloud can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign weatherflow_cloud Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


weatherflow_cloud documentation
weatherflow_cloud source
(message by IssueLinks)

@stuartparmenter
Copy link
Author

This also results in this error showing up in the logs:

Logger: homeassistant
Source: components/weatherflow_cloud/sensor.py:161
First occurred: August 15, 2024 at 4:23:51 PM (987 occurrences)
Last logged: 9:28:39 AM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 453, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 533, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1005, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1130, in _async_write_ha_state
    self.__async_calculate_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1011, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 542, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weatherflow_cloud/sensor.py", line 208, in native_value
    return self.entity_description.value_fn(self.station.observation.obs[0])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/weatherflow_cloud/sensor.py", line 161, in <lambda>
    value_fn=lambda data: datetime.fromtimestamp(
                          ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object cannot be interpreted as an integer

@jeeftor
Copy link
Contributor

jeeftor commented Aug 16, 2024

Any chance you can turn on debug mode and give me the actual JSON you are getting so i can verify it in a test?

aka whats the value of : self.station.observation.obs[0]

The more i look at the data the more i realize that Tempest Weatherflow has CRAP docs because what they say should be there never is :)

@stuartparmenter
Copy link
Author

{
    "elevation": 291.6996765136719,
    "is_public": true,
    "latitude": XXXX,
    "longitude": XXXX,
    "obs": [
        {
            "air_density": 1.14887,
            "air_temperature": 24.4,
            "barometric_pressure": 981.3,
            "brightness": 111116,
            "delta_t": 7.6,
            "dew_point": 12,
            "feels_like": 24.4,
            "heat_index": 24.4,
            "lightning_strike_count": 0,
            "lightning_strike_count_last_1hr": 0,
            "lightning_strike_count_last_3hr": 0,
            "precip": 0,
            "precip_accum_last_1hr": 0,
            "precip_accum_local_day": 0,
            "precip_accum_local_day_final": 0,
            "precip_accum_local_yesterday": 0,
            "precip_accum_local_yesterday_final": 0,
            "precip_analysis_type_yesterday": 0,
            "precip_minutes_local_day": 0,
            "precip_minutes_local_yesterday": 0,
            "precip_minutes_local_yesterday_final": 0,
            "pressure_trend": "steady",
            "relative_humidity": 46,
            "sea_level_pressure": 1016.1,
            "solar_radiation": 926,
            "station_pressure": 981.3,
            "timestamp": 1723829203,
            "uv": 8.1,
            "wet_bulb_globe_temperature": 22.6,
            "wet_bulb_temperature": 16.8,
            "wind_avg": 1.1,
            "wind_chill": 24.4,
            "wind_direction": 147,
            "wind_gust": 1.5,
            "wind_lull": 0.3
        }
    ],
    "outdoor_keys": [
        "timestamp",
        "air_temperature",
        "barometric_pressure",
        "station_pressure",
        "pressure_trend",
        "sea_level_pressure",
        "relative_humidity",
        "precip",
        "precip_accum_last_1hr",
        "precip_accum_local_day",
        "precip_accum_local_day_final",
        "precip_accum_local_yesterday_final",
        "precip_minutes_local_day",
        "precip_minutes_local_yesterday_final",
        "wind_avg",
        "wind_direction",
        "wind_gust",
        "wind_lull",
        "solar_radiation",
        "uv",
        "brightness",
        "lightning_strike_count",
        "lightning_strike_count_last_1hr",
        "lightning_strike_count_last_3hr",
        "feels_like",
        "heat_index",
        "wind_chill",
        "dew_point",
        "wet_bulb_temperature",
        "wet_bulb_globe_temperature",
        "delta_t",
        "air_density"
    ],
    "public_name": "XXXX",
    "station_id": XXXX,
    "station_name": "XXXX",
    "station_units": {
        "units_direction": "cardinal",
        "units_distance": "mi",
        "units_other": "imperial",
        "units_precip": "in",
        "units_pressure": "hpa",
        "units_temp": "f",
        "units_wind": "mph"
    },
    "status": {
        "status_code": 0,
        "status_message": "SUCCESS"
    },
    "timezone": "America/Los_Angeles"
}

@stuartparmenter
Copy link
Author

Looks like lightning_strike_last_epoch just isn't there

@jeeftor
Copy link
Contributor

jeeftor commented Aug 16, 2024

Oh - its actually an HA issue not a back end lib issue for once.

The value can already be optional in the backing lib:

image

Looks like this is pretty unhappy trying convert a None value into a time:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants