def _forecast_dict( hass: HomeAssistantType, forecast_dt: datetime, use_datetime: bool, condition: str, precipitation: Optional[float], precipitation_probability: Optional[float], temp: Optional[float], temp_low: Optional[float], wind_direction: Optional[float], wind_speed: Optional[float], ) -> Dict[str, Any]: """Return formatted Forecast dict from ClimaCell forecast data.""" if use_datetime: translated_condition = _translate_condition(condition, is_up(hass, forecast_dt)) else: translated_condition = _translate_condition(condition, True) if hass.config.units.is_metric: if precipitation: precipitation = ( distance_convert(precipitation / 12, LENGTH_FEET, LENGTH_METERS) * 1000 ) if temp: temp = temp_convert(temp, TEMP_FAHRENHEIT, TEMP_CELSIUS) if temp_low: temp_low = temp_convert(temp_low, TEMP_FAHRENHEIT, TEMP_CELSIUS) if wind_speed: wind_speed = distance_convert(wind_speed, LENGTH_MILES, LENGTH_KILOMETERS) data = { ATTR_FORECAST_TIME: forecast_dt.isoformat(), ATTR_FORECAST_CONDITION: translated_condition, ATTR_FORECAST_PRECIPITATION: precipitation, ATTR_FORECAST_PRECIPITATION_PROBABILITY: precipitation_probability, ATTR_FORECAST_TEMP: temp, ATTR_FORECAST_TEMP_LOW: temp_low, ATTR_FORECAST_WIND_BEARING: wind_direction, ATTR_FORECAST_WIND_SPEED: wind_speed, } return {k: v for k, v in data.items() if v is not None}
CC_ATTR_SOLAR_GHI = "solarGHI" CC_ATTR_CLOUD_BASE = "cloudBase" CC_ATTR_CLOUD_CEILING = "cloudCeiling" CC_SENSOR_TYPES = [ { ATTR_FIELD: CC_ATTR_FEELS_LIKE, ATTR_NAME: "Feels Like", CONF_UNIT_SYSTEM_IMPERIAL: TEMP_FAHRENHEIT, CONF_UNIT_SYSTEM_METRIC: TEMP_CELSIUS, ATTR_METRIC_CONVERSION: lambda val: temp_convert(val, TEMP_FAHRENHEIT, TEMP_CELSIUS), ATTR_IS_METRIC_CHECK: True, }, { ATTR_FIELD: CC_ATTR_DEW_POINT, ATTR_NAME: "Dew Point", CONF_UNIT_SYSTEM_IMPERIAL: TEMP_FAHRENHEIT, CONF_UNIT_SYSTEM_METRIC: TEMP_CELSIUS, ATTR_METRIC_CONVERSION: lambda val: temp_convert(val, TEMP_FAHRENHEIT, TEMP_CELSIUS), ATTR_IS_METRIC_CHECK:
"""Describes a Tomorrow.io sensor entity.""" unit_imperial: str | None = None unit_metric: str | None = None metric_conversion: Callable[[float], float] | float = 1.0 is_metric_check: bool | None = None value_map: Any | None = None SENSOR_TYPES = ( TomorrowioSensorEntityDescription( key=TMRW_ATTR_FEELS_LIKE, name="Feels Like", unit_imperial=TEMP_FAHRENHEIT, unit_metric=TEMP_CELSIUS, metric_conversion=lambda val: temp_convert(val, TEMP_FAHRENHEIT, TEMP_CELSIUS), is_metric_check=True, device_class=SensorDeviceClass.TEMPERATURE, ), TomorrowioSensorEntityDescription( key=TMRW_ATTR_DEW_POINT, name="Dew Point", unit_imperial=TEMP_FAHRENHEIT, unit_metric=TEMP_CELSIUS, metric_conversion=lambda val: temp_convert(val, TEMP_FAHRENHEIT, TEMP_CELSIUS), is_metric_check=True, device_class=SensorDeviceClass.TEMPERATURE, ), TomorrowioSensorEntityDescription( key=TMRW_ATTR_PRESSURE_SURFACE_LEVEL,