1 """Support for Ampio Air Quality data."""
3 from __future__
import annotations
6 from typing
import Final
8 from asmog
import AmpioSmog
9 import voluptuous
as vol
12 PLATFORM_SCHEMA
as AIR_QUALITY_PLATFORM_SCHEMA,
23 from .const
import CONF_STATION_ID, SCAN_INTERVAL
25 _LOGGER: Final = logging.getLogger(__name__)
27 PLATFORM_SCHEMA: Final = AIR_QUALITY_PLATFORM_SCHEMA.extend(
28 {vol.Required(CONF_STATION_ID): cv.string, vol.Optional(CONF_NAME): cv.string}
35 async_add_entities: AddEntitiesCallback,
36 discovery_info: DiscoveryInfoType |
None =
None,
38 """Set up the Ampio Smog air quality platform."""
40 name = config.get(CONF_NAME)
41 station_id = config[CONF_STATION_ID]
46 await api.async_update()
49 _LOGGER.error(
"Station %s is not available", station_id)
56 """Implementation of an Ampio Smog air quality entity."""
58 _attr_attribution =
"Data provided by Ampio"
61 self, api: AmpioSmogMapData, station_id: str, name: str |
None
63 """Initialize the air quality entity."""
66 self.
_name_name = name
or api.api.name
70 """Return the name of the air quality entity."""
71 return self.
_name_name
75 """Return unique_name."""
76 return f
"ampio_smog_{self._station_id}"
80 """Return the particulate matter 2.5 level."""
81 return self.
_ampio_ampio.api.pm2_5
85 """Return the particulate matter 10 level."""
86 return self.
_ampio_ampio.api.pm10
89 """Get the latest data from the AmpioMap API."""
94 """Get the latest data and update the states."""
97 """Initialize the data object."""
100 @Throttle(SCAN_INTERVAL)
102 """Get the latest data from AmpioMap."""
103 await self.
apiapi.get_data()
None __init__(self, AmpioSmog api)
None __init__(self, AmpioSmogMapData api, str station_id, str|None name)
str|None particulate_matter_10(self)
str|None particulate_matter_2_5(self)
None async_setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback async_add_entities, DiscoveryInfoType|None discovery_info=None)
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)