Last active
April 26, 2023 21:13
-
-
Save krissen/277fcd24532e48d4ff8e2fa347c9b19a to your computer and use it in GitHub Desktop.
Pollennivå i Homeassistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FÖR ATT FÅ POLLEN-SENSORERNA | |
# 1) Installera custom_component från | |
# https://github.com/JohNan/home-assistant-pollenkoll | |
# 2) Konfigurera enligt anvisningarna i komponenten. | |
# Inställningarna numer i HA direkt, inte YAML. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# För att kunna använda komponentens sensorer i statistik-kort | |
# behöver du berätta åt HA att det handlar om mätningar. | |
# Det kan du göra genom att lägga till detta i customize.yaml: | |
sensor.pollen_forshaga_al: | |
state_class: measurement | |
sensor.pollen_forshaga_alm: | |
state_class: measurement | |
sensor.pollen_forshaga_ambrosia: | |
state_class: measurement | |
sensor.pollen_forshaga_bjork: | |
state_class: measurement | |
sensor.pollen_forshaga_bok: | |
state_class: measurement | |
sensor.pollen_forshaga_ek: | |
state_class: measurement | |
sensor.pollen_forshaga_grabo: | |
state_class: measurement | |
sensor.pollen_forshaga_gras: | |
state_class: measurement | |
sensor.pollen_forshaga_hassel: | |
state_class: measurement | |
sensor.pollen_forshaga_salg_vide: | |
state_class: measurement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update. Try my custom card instead? https://github.com/krissen/pollenprognos-card/tree/master | |
########## | |
# FÖR ATT FÅ MÄTARE I FRONTEND | |
# Lägg till följande i lovelace.yaml | |
title: Pollenkollen | |
icon: mdi:flower | |
cards: | |
- type: vertical-stack | |
cards: | |
- type: horizontal-stack | |
cards: | |
- type: gauge | |
entity: sensor.pollen_forshaga_al | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: gauge | |
entity: sensor.pollen_forshaga_alm | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: gauge | |
entity: sensor.pollen_forshaga_bjork | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: horizontal-stack | |
cards: | |
- type: gauge | |
entity: sensor.pollen_forshaga_bok | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: gauge | |
entity: sensor.pollen_forshaga_ek | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: gauge | |
entity: sensor.pollen_forshaga_grabo | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: horizontal-stack | |
cards: | |
- type: gauge | |
entity: sensor.pollen_forshaga_gras | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: gauge | |
entity: sensor.pollen_forshaga_hassel | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 | |
- type: gauge | |
entity: sensor.pollen_forshaga_salg_vide | |
min: 0 | |
max: 7 | |
severity: | |
green: 1 | |
yellow: 3 | |
red: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Update. Try my custom card instead? https://github.com/krissen/pollenprognos-card/tree/master | |
# | |
/* | |
# Ett custom lovelace kort är https://github.com/nidayand/lovelace-pollen-card | |
# I skrivande stund funkar det nästan. :-) | |
# Allergenen `Sälg / vide` ställer till det lite. | |
# Antingen kan du ta bort (läs: låta bli ange) den i kortets inställningar, | |
# *eller* så löser du problemet: | |
*/ | |
// Om du *har* installerat ovan nämnda kort genom HACS (custom URL), så har du en fil `www/community/lovelace-pollen-card/pollen-card.js`. Ändra rad 20 till följande: | |
return intext.toLowerCase().replaceAll("å","a").replaceAll("ä","a").replaceAll("ö","o").replace(' \/ ','_'); | |
/* Det är sistnämnda replace som är grejen. | |
* Följ repons issue #4 för att se om det löses direkt, där | |
* https://github.com/nidayand/lovelace-pollen-card/issues/4 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Template för att få en pollenprognos i text. | |
# 1) Skapa en group.pollen | |
# Alla medlemmar i group.pollen gås igenom, och rapporteras. | |
# Genom att ha olika group.pollen1 och group.pollen2 och anpassa | |
# koden nedan, kan du ha olika, summerande rapporter för olika | |
# områden eller liknande. | |
# 2) Använd koden nedan som template i automation, script, template_sensor el. dyl. | |
# | |
# Användningsområden: t. ex. pollenrapport över TTS eller textsummering i frontend. | |
# Exempel output: "Din pollenprognos: Måttliga halter av sälg / vide.Låga halter av al, alm och hassel." | |
Din pollenprognos: | |
{% for entity_id in states.group.pollen.attributes.entity_id if states(entity_id) >= '5' %} | |
{% set parts = entity_id.split('.') -%} | |
{%- if loop.first -%}Höga halter av | |
{% elif loop.last %} och {% else %}, | |
{% endif -%} | |
{{ states[parts[0]][parts[1]].name | lower }} | |
{%- if loop.last %}. {%- endif %} | |
{%- endfor %} | |
{%- for entity_id in states.group.pollen.attributes.entity_id if states(entity_id) == '3' or states(entity_id) == '4' -%} | |
{% set parts = entity_id.split('.') -%} | |
{%- if loop.first %}Måttliga halter av {% elif loop.last %} och {% else %}, | |
{% endif -%}{{ states[parts[0]][parts[1]].name | lower }} | |
{%- if loop.last %}. {%- endif %} | |
{%- endfor %} | |
{%- for entity_id in states.group.pollen.attributes.entity_id if states(entity_id) == '2' or states(entity_id) == '1' -%} | |
{% set parts = entity_id.split('.') -%} | |
{%- if loop.first %}Låga halter av {% elif loop.last %} och {% else %}, {% endif -%} | |
{{ states[parts[0]][parts[1]].name | lower }} | |
{%- if loop.last %}. {%- endif %}{%- endfor %} | |
# Testa genom att klistra in ovanstående i dev-template. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Update. Try my custom card instead? https://github.com/krissen/pollenprognos-card/tree/master | |
# | |
# Ett annat sätt att få olika ikoner för pollen-läget, är att göra nya template-sensorer | |
# utgående från de som erhålls genom JohNans custom komponent. Det kan se ut så här: | |
- sensor: | |
- name: "Pollen: sälg/vide" | |
state_class: measurement | |
state: "{{ states('sensor.pollen_forshaga_salg_vide') | float(0) | round(0) }}" | |
icon: >- | |
{% set lvl = states('sensor.pollen_forshaga_salg_vide')|float(0) %} | |
{% if lvl == 0 %} | |
mdi:hand-okay | |
{% elif lvl == 1 %} | |
mdi:bee-flower | |
{% elif lvl >= 2 %} | |
mdi:flower-tulip-outline | |
{% elif lvl >= 4 %} | |
mdi:flower | |
{% elif lvl == 6 %} | |
mdi:flower-pollen-outline | |
{% elif lvl == 7 %} | |
mdi:flower-pollen | |
{% else %} | |
mdi:gauge | |
{% endif %} | |
- name: "Pollen: ambrosia" | |
state_class: measurement | |
state: "{{ states('sensor.pollen_forshaga_ambrosia') | float(0) | round(0) }}" | |
icon: >- | |
{% set lvl = states('sensor.pollen_forshaga_ambrosia')|float(0) %} | |
{% if lvl == 0 %} | |
mdi:hand-okay | |
{% elif lvl == 1 %} | |
mdi:bee-flower | |
{% elif lvl >= 2 %} | |
mdi:flower-tulip-outline | |
{% elif lvl >= 4 %} | |
mdi:flower | |
{% elif lvl == 6 %} | |
mdi:flower-pollen-outline | |
{% elif lvl == 7 %} | |
mdi:flower-pollen | |
{% else %} | |
mdi:gauge | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uppdatering! Gjort en egen repo med fork av ovan nämnda custom kort. Bland annat lagt till möjlighet till mer minimalistisk layouts enligt bilden nedan.
Fler exempel @ repon : https://github.com/krissen/pollenprognos-card/tree/master