Official exchange rate of hryvnia to foreign currencies
The official exchange rate of the hryvnia to foreign currencies dollar and euro for the current date from the website of the National Bank of Ukraine (API)
Built by Dmytro Sudakevych (megadimich)
Published 24 December 2023 · updated 24 December 2023 · 4 downloads
- 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.
npWxo0jJ5vJk.yaml · 1.7 KB
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
These icons belong on the device, in /ICONS. Each one is at
most 32×8
pixels — shown here at actual proportions, magnified.
11388.gif
8×8
2147.gif
8×8