Air Quality Index (AQI) in your city
Air Quality Index (AQI) in your city
About this flow
| System | Home Assistant |
|---|---|
| AWTRIX version | AWTRIX 3 |
| Topic | Social |
| Built by | Dmytro Sudakevych (megadimich) |
| File | PjqGAXrjOYNK.yaml · 1.8 KB |
| Icons | 1 |
| Published | 24 Jan 2024 · updated 24 Jan 2024 |
| Downloads | 41 |
Is this your flow?
If you created this flow, open your saved edit link to add it to your account. You can then manage it whenever you sign in. Adding it to your account replaces the edit link.
- You need to create a sensor in the configuration.yaml file or add a link to a file containing an AQI sensor and a sensor to change the color of the message text.
In my case, I added the following lines to the configuration.yaml:
homeassistant:
packages: !include_dir_merge_named includes/packages
Place the api_waqi_info_sensors.yaml file in the packages folder.
At https://aqicn.org/data-platform/token/ you must create your token according to the instructions on that site.
Then you should enter this token in the file api_waqi_info_sensors.yaml in resource_template instead of YOURS_TOKEN and instead of A195973 enter your city, for example kyiv or better Air quality monitoring station: A + station code - mine is A195973.
-
Create your automation. I added my automation to the automations.yaml file. In this file, set your AWTRIX MQTT prefix in topic: instead of awtrix_565c3c.
-
Do not forget to download the icon mentioned in the project.
If you have any questions, please contact me on Discord at megadimich.
PjqGAXrjOYNK.yaml
1. File api_waqi_info_sensors.yaml:
#https://aqicn.org/api
api_waqi_info_sensors:
sensor:
- platform: rest
name: api_waqi_info
resource_template: "https://api.waqi.info/feed/A195973/?token=YOURS_TOKEN"
method: GET
headers:
content-type: 'application/json'
value_template: "{{ value_json.data.iaqi.pm25.v }}"
json_attributes:
- "data"
scan_interval: 600 # 10 Minutes
- platform: template
sensors:
api_waqi_color_text:
friendly_name: "api_waqi_color_text"
value_template: >
{% if ((states('sensor.api_waqi_info') | int) >= 0) and ((states('sensor.api_waqi_info') | int) <= 50) %}#009966
{% elif ((states('sensor.api_waqi_info') | int) >= 51) and ((states('sensor.api_waqi_info') | int) <= 100) %}#ffde33
{% elif ((states('sensor.api_waqi_info') | int) >= 101) and ((states('sensor.api_waqi_info') | int) <= 150) %}#ff9933
{% elif ((states('sensor.api_waqi_info') | int) >= 151) and ((states('sensor.api_waqi_info') | int) <= 200) %}#cc0033
{% elif ((states('sensor.api_waqi_info') | int) >= 201) and ((states('sensor.api_waqi_info') | int) <= 300) %}#660099
{% elif ((states('sensor.api_waqi_info') | int) > 300) %}#7e0023
{% else %}#ffffff
{% endif %}
2. File automations.yaml:
- id: '1703280435999'
alias: AWTRIX Aqi
description: ''
trigger:
- platform: time_pattern
minutes: /2
condition: []
action:
- service: mqtt.publish
data:
qos: '0'
retain: false
topic: awtrix_565c3c/custom/airquality
payload: '{ "text": "pm:{{ states(''sensor.api_waqi_info'') }}", "color": "{{
states(''sensor.api_waqi_color_text'') }}", "textCase": 2, "icon": "56366", "repeat":
2, "duration": 5 }'
mode: single
This flow uses the following icons. Add them to your AWTRIX along with the flow.
8×8 px
More flows for Home Assistant or Social
Something wrong with this flow? Report it.