From 6d21831a1903f643342957c7fc5f698eabbae2e9 Mon Sep 17 00:00:00 2001 From: Jeff Stein Date: Fri, 16 Aug 2024 15:30:50 -0600 Subject: [PATCH] Adding a error condition and a fix for missing lightning epoch values --- .../components/weatherflow_cloud/sensor.py | 4 +- .../components/weatherflow_cloud/conftest.py | 35 + .../fixtures/station_observation_error.json | 99 +++ .../snapshots/test_sensor.ambr | 805 ++++++++++++++++++ .../weatherflow_cloud/test_sensor.py | 16 + 5 files changed, 958 insertions(+), 1 deletion(-) create mode 100644 tests/components/weatherflow_cloud/fixtures/station_observation_error.json diff --git a/homeassistant/components/weatherflow_cloud/sensor.py b/homeassistant/components/weatherflow_cloud/sensor.py index 9314c77a65c4b..e36b416ef8654 100644 --- a/homeassistant/components/weatherflow_cloud/sensor.py +++ b/homeassistant/components/weatherflow_cloud/sensor.py @@ -160,7 +160,9 @@ class WeatherFlowCloudSensorEntityDescription( device_class=SensorDeviceClass.TIMESTAMP, value_fn=lambda data: datetime.fromtimestamp( data.lightning_strike_last_epoch, tz=UTC - ), + ) + if data.lightning_strike_last_epoch is not None + else None, ), ) diff --git a/tests/components/weatherflow_cloud/conftest.py b/tests/components/weatherflow_cloud/conftest.py index 36b42bf24a83b..ed4cbda6efec8 100644 --- a/tests/components/weatherflow_cloud/conftest.py +++ b/tests/components/weatherflow_cloud/conftest.py @@ -113,3 +113,38 @@ def mock_api(): mock_api_class.return_value = mock_api yield mock_api + + +@pytest.fixture +def mock_api_with_lightning_error(): + """Fixture for Mock WeatherFlowRestAPI.""" + get_stations_response_data = StationsResponseREST.from_json( + load_fixture("stations.json", DOMAIN) + ) + get_forecast_response_data = WeatherDataForecastREST.from_json( + load_fixture("forecast.json", DOMAIN) + ) + get_observation_response_data = ObservationStationREST.from_json( + load_fixture("station_observation_error.json", DOMAIN) + ) + + data = { + 24432: WeatherFlowDataREST( + weather=get_forecast_response_data, + observation=get_observation_response_data, + station=get_stations_response_data.stations[0], + device_observations=None, + ) + } + + with patch( + "homeassistant.components.weatherflow_cloud.coordinator.WeatherFlowRestAPI", + autospec=True, + ) as mock_api_class: + # Create an instance of AsyncMock for the API + mock_api = AsyncMock() + mock_api.get_all_data.return_value = data + # Patch the class to return our mock_api instance + mock_api_class.return_value = mock_api + + yield mock_api diff --git a/tests/components/weatherflow_cloud/fixtures/station_observation_error.json b/tests/components/weatherflow_cloud/fixtures/station_observation_error.json new file mode 100644 index 0000000000000..41bb452c91151 --- /dev/null +++ b/tests/components/weatherflow_cloud/fixtures/station_observation_error.json @@ -0,0 +1,99 @@ +{ + "elevation": 2063.150146484375, + "is_public": true, + "latitude": 43.94962, + "longitude": -102.86831, + "obs": [ + { + "air_density": 0.96139, + "air_temperature": 10.5, + "barometric_pressure": 782.8, + "brightness": 757, + "delta_t": 8.4, + "dew_point": -10.4, + "feels_like": 10.5, + "heat_index": 10.5, + "lightning_strike_count": 0, + "lightning_strike_count_last_1hr": 0, + "lightning_strike_count_last_3hr": 0, + "lightning_strike_last_distance": 26, + "precip": 0.0, + "precip_accum_last_1hr": 0.0, + "precip_accum_local_day": 0.0, + "precip_accum_local_day_final": 0.0, + "precip_accum_local_yesterday": 0.0, + "precip_accum_local_yesterday_final": 0.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": 22, + "sea_level_pressure": 1006.2, + "solar_radiation": 6, + "station_pressure": 782.8, + "timestamp": 1708994629, + "uv": 0.03, + "wet_bulb_globe_temperature": 4.6, + "wet_bulb_temperature": 2.1, + "wind_avg": 1.4, + "wind_chill": 10.5, + "wind_direction": 203, + "wind_gust": 3.2, + "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_last_epoch", + "lightning_strike_last_distance", + "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": "My Home Station", + "station_id": 24432, + "station_name": "My Home Station", + "station_units": { + "units_direction": "degrees", + "units_distance": "mi", + "units_other": "metric", + "units_precip": "in", + "units_pressure": "hpa", + "units_temp": "f", + "units_wind": "bft" + }, + "status": { + "status_code": 0, + "status_message": "SUCCESS" + }, + "timezone": "America/Denver" +} diff --git a/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr b/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr index 95be86664a2f1..1ff02c07e1f34 100644 --- a/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr +++ b/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr @@ -804,3 +804,808 @@ 'state': '10.5', }) # --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_air_density-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_air_density', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 5, + }), + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Air density', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'air_density', + 'unique_id': '24432_air_density', + 'unit_of_measurement': 'kg/m³', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_air_density-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'friendly_name': 'My Home Station Air density', + 'state_class': , + 'unit_of_measurement': 'kg/m³', + }), + 'context': , + 'entity_id': 'sensor.my_home_station_air_density', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0.96139', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_dew_point-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_dew_point', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Dew point', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'dew_point', + 'unique_id': '24432_dew_point', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_dew_point-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Dew point', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_dew_point', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '-10.4', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_feels_like-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_feels_like', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Feels like', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'feels_like', + 'unique_id': '24432_feels_like', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_feels_like-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Feels like', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_feels_like', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '10.5', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_heat_index-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_heat_index', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Heat index', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'heat_index', + 'unique_id': '24432_heat_index', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_heat_index-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Heat index', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_heat_index', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '10.5', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_count-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_lightning_count', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Lightning count', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'lightning_strike_count', + 'unique_id': '24432_lightning_strike_count', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_count-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'friendly_name': 'My Home Station Lightning count', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_lightning_count', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_count_last_1_hr-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_lightning_count_last_1_hr', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Lightning count last 1 hr', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'lightning_strike_count_last_1hr', + 'unique_id': '24432_lightning_strike_count_last_1hr', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_count_last_1_hr-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'friendly_name': 'My Home Station Lightning count last 1 hr', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_lightning_count_last_1_hr', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_count_last_3_hr-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_lightning_count_last_3_hr', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Lightning count last 3 hr', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'lightning_strike_count_last_3hr', + 'unique_id': '24432_lightning_strike_count_last_3hr', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_count_last_3_hr-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'friendly_name': 'My Home Station Lightning count last 3 hr', + 'state_class': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_lightning_count_last_3_hr', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '0', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_last_distance-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_lightning_last_distance', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Lightning last distance', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'lightning_strike_last_distance', + 'unique_id': '24432_lightning_strike_last_distance', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_last_distance-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'distance', + 'friendly_name': 'My Home Station Lightning last distance', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_lightning_last_distance', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '26', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_last_strike-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_lightning_last_strike', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Lightning last strike', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'lightning_strike_last_epoch', + 'unique_id': '24432_lightning_strike_last_epoch', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_lightning_last_strike-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'timestamp', + 'friendly_name': 'My Home Station Lightning last strike', + }), + 'context': , + 'entity_id': 'sensor.my_home_station_lightning_last_strike', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_pressure_barometric-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_pressure_barometric', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 3, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Pressure barometric', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'barometric_pressure', + 'unique_id': '24432_barometric_pressure', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_pressure_barometric-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'atmospheric_pressure', + 'friendly_name': 'My Home Station Pressure barometric', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_pressure_barometric', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '782.8', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_pressure_sea_level-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_pressure_sea_level', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 3, + }), + 'sensor.private': dict({ + 'suggested_unit_of_measurement': , + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Pressure sea level', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'sea_level_pressure', + 'unique_id': '24432_sea_level_pressure', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_pressure_sea_level-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'atmospheric_pressure', + 'friendly_name': 'My Home Station Pressure sea level', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_pressure_sea_level', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '1006.2', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Temperature', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'air_temperature', + 'unique_id': '24432_air_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '10.5', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_wet_bulb_globe_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_wet_bulb_globe_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Wet bulb globe temperature', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'wet_bulb_globe_temperature', + 'unique_id': '24432_wet_bulb_globe_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_wet_bulb_globe_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Wet bulb globe temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_wet_bulb_globe_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '4.6', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_wet_bulb_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_wet_bulb_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Wet bulb temperature', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'wet_bulb_temperature', + 'unique_id': '24432_wet_bulb_temperature', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_wet_bulb_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Wet bulb temperature', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_wet_bulb_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '2.1', + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_wind_chill-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': dict({ + 'state_class': , + }), + 'config_entry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.my_home_station_wind_chill', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + 'sensor': dict({ + 'suggested_display_precision': 1, + }), + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Wind chill', + 'platform': 'weatherflow_cloud', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'wind_chill', + 'unique_id': '24432_wind_chill', + 'unit_of_measurement': , + }) +# --- +# name: test_all_entities_with_lightning_error[sensor.my_home_station_wind_chill-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'attribution': 'Weather data delivered by WeatherFlow/Tempest REST Api', + 'device_class': 'temperature', + 'friendly_name': 'My Home Station Wind chill', + 'state_class': , + 'unit_of_measurement': , + }), + 'context': , + 'entity_id': 'sensor.my_home_station_wind_chill', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '10.5', + }) +# --- diff --git a/tests/components/weatherflow_cloud/test_sensor.py b/tests/components/weatherflow_cloud/test_sensor.py index 35ce098f5a788..bc16b1ce47861 100644 --- a/tests/components/weatherflow_cloud/test_sensor.py +++ b/tests/components/weatherflow_cloud/test_sensor.py @@ -27,3 +27,19 @@ async def test_all_entities( await setup_integration(hass, mock_config_entry) await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) + + +async def test_all_entities_with_lightning_error( + hass: HomeAssistant, + snapshot: SnapshotAssertion, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, + mock_api_with_lightning_error: AsyncMock, +) -> None: + """Test all entities.""" + with patch( + "homeassistant.components.weatherflow_cloud.PLATFORMS", [Platform.SENSOR] + ): + await setup_integration(hass, mock_config_entry) + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)