Flow Details
- You need to create a sensor in the configuration.yaml file or add a link to the file where the bank_gov_ua sensor is recorded. In my case, I added the following lines to the configuration.yaml:
homeassistant:
packages: !include_dir_merge_named includes/packages
Place the bank_gov_ua_sensors.yaml file in the packages folder.
-
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 icons mentioned in the project: 11388, 2147.
If you have any questions, please contact me on Discord at megadimich.
1. File bank_gov_ua_sensors.yaml:
#https://bank.gov.ua/ua/open-data/api-dev
bank_gov_ua_sensors:
sensor:
- platform: rest
name: bank_gov_ua_eur
resource_template: https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?valcode=EUR&json&date={{ now().strftime("%Y%m%d") }}
method: GET
headers:
content-type: 'application/json'
value_template: "{{ value_json[0].rate }}"
json_attributes:
- "''"
scan_interval: 3600 # 1 Hour
- platform: rest
name: bank_gov_ua_usd
resource_template: https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?valcode=USD&json&date={{ now().strftime("%Y%m%d") }}
method: GET
headers:
content-type: 'application/json'
value_template: "{{ value_json[0].rate }}"
json_attributes:
- "''"
scan_interval: 3600 # 1 Hour
2. File automations.yaml:
- id: '1703259398273'
alias: 'AWTRIX: USD and EURO currency rates'
description: ''
trigger:
- platform: time_pattern
minutes: /4
condition: []
action:
- service: mqtt.publish
data:
qos: '0'
retain: false
topic: awtrix_565c3c/custom/rateusd
payload: '{ "text": "{{ states(''sensor.bank_gov_ua_usd'') | round(3)
}}", "icon": "11388", "repeat": 2, "duration":
5 }'
- service: mqtt.publish
data:
qos: '0'
retain: false
topic: awtrix_565c3c/custom/rateeur
payload: '{ "text": "{{ states(''sensor.bank_gov_ua_eur'') | round(3)
}}", "icon": "2147", "repeat": 2, "duration":
5 }'
mode: single
-- Flow first published on December 24, 2023, last updated on December 24, 2023 at 15:09.