Skip to content

Instantly share code, notes, and snippets.

@samueljon
Last active November 29, 2020 15:41
Show Gist options
  • Save samueljon/a4cd73d126df3b9785f31c1fd97c7062 to your computer and use it in GitHub Desktop.
Save samueljon/a4cd73d126df3b9785f31c1fd97c7062 to your computer and use it in GitHub Desktop.
Sensor sem sækir gengi frá M5 og birtir í Home Assistant sem m5_is_rate_GJALDMIDILL
#####################
# Sensors
#####################
sensor:
- platform: rest
name: apis_currency_m5
resource: https://apis.is/currency/m5
scan_interval: 60
json_attributes:
- results
value_template: "OK"
- platform: template
sensors:
m5_is_rate_usd:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'USD' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_dkk:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'DKK' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_eur:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'EUR' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_jpy:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'JPY' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_cad:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'CAD' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_nok:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'NOK' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_gbp:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'GBP' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_chf:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'CHF' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_sek:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'SEK' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
m5_is_rate_twi:
unit_of_measurement: "kr"
value_template: >
{% for state in states.sensor.apis_currency_m5.attributes["results"] %}
{%- if state.shortName == 'TWI' %}
{{ state.value |float}}
{% endif -%}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment