London Air

The london_air integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] queries the London air quality data feed provided by Kings College London. A single sensor will be added for each location (local authority district or borough) specified in the configuration file. The state of each sensor is the overall air quality in that borough. Note that only 28 of the 32 boroughs have data available.

Boroughs can have multiple monitoring sites at different geographical positions within the borough, and each of those sites can monitor up to six different kinds of pollutant. The pollutants are described here and are Carbon Monoxide (CO), Nitrogen Dioxide (NO2), Ozone (O3), Sulfur Dioxide (SO2), PM2.5 & PM10 particulates. The latitude and longitude of each site is accessible through a data attribute of the sensor, as are details about the pollutants monitored at that site. The sites attribute of a sensor displays how many monitoring sites that sensor covers. The updated attribute of a sensor states when the data was last published. Nominally data is published hourly, but in my experience this can vary. To limit the number of requests made by the sensor, a single API request is made every 30 minutes.

To add sensors to Home Assistant for all possible areas/boroughs add the following to your configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] file. 在更改了configuration.yamlconfiguration.yaml 文件是 Home Assistant 的主要配置文件。它列出了要加载的集成及其特定配置。在某些情况下,需要直接在 configuration.yaml 文件中手动编辑配置。大多数集成可以在 UI 中配置。 [Learn more] 文件后,重启 Home Assistant 以应用更改。 该集成现在显示在集成页面的 设置 > 设备与服务 下。其实体在集成卡片上以及实体标签上列出。

# Example configuration.yaml entry for a single sensor
sensor:
  - platform: london_air
    locations:
      - Barking and Dagenham
      - Bexley
      - Brent
      - Camden
      - City of London
      - Croydon
      - Ealing
      - Enfield
      - Greenwich
      - Hackney
      - Haringey
      - Harrow
      - Havering
      - Hillingdon
      - Islington
      - Kensington and Chelsea
      - Kingston
      - Lambeth
      - Lewisham
      - Merton
      - Redbridge
      - Richmond
      - Southwark
      - Sutton
      - Tower Hamlets
      - Wandsworth
      - Westminster

Configuration Variables

locations list (Optional)

Areas/boroughs in London to monitor.

Default:

All location with data available.

To explore the data available within the data attribute of a sensor use the dev-template tool on the Home Assistant frontend. data contains a list of monitored sites, where the number of monitored sites are given by the sites attribute. If a sensor has four sites, access the fourth site by indexing the list of sites using data[3]. Each site is a dictionary with multiple fields, with entries for the latitude and longitude of that site, a pollution_status, site_code, site_name and site_type. The field number_of_pollutants states how many pollutants are monitored (of the possible six) and the field pollutants returns a list with data for each pollutant. To access the first pollutant in the list for site zero use attributes.data[0].pollutants[0]. Each entry in pollutants is a dictionary with fields for the pollutant code, description, index, quality and a summary. Template sensors can then be added to display these attributes, for example:

# Example template sensors
template:
  - sensor:
    - name: "Updated"
      state: "{{ state_attr('sensor.merton', 'updated') }}"
    - name: "Merton PM10"
      state: "{{ state_attr('sensor.merton', 'data')[0].pollutants[0].summary }}"
    - name: "Westminster S02"
      state: "{{ state_attr('sensor.westminster', 'data')[0].pollutants[3].summary }}"