Skip to content

Commit

Permalink
Re: #118
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjking committed Sep 8, 2017
1 parent f22bae7 commit f833c30
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 34 deletions.
24 changes: 24 additions & 0 deletions customize.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@
friendly_name: Kitchen Sink
emulated_hue: true
icon: 'mdi:lightbulb-on'
sensor.pollen_index:
icon: mdi:flower
sensor.pollen_level:
icon: mdi:flower
sensor.top_allergen_1:
icon: mdi:flower
sensor.top_allergen_2:
icon: mdi:flower
sensor.top_allergen_3:
icon: mdi:flower
sensor.pollen_trend:
icon: mdi:flower
sensor.pollen_outlook:
icon: mdi:flower
sensor.pollen_season:
icon: mdi:flower
sensor.pollen_index_forecast:
icon: mdi:flower
sensor.pollen_level_forecast:
icon: mdi:flower
sensor.cold__flu_percentage:
icon: mdi:snowflake
sensor.cold_flu_risk:
icon: mdi:snowflake



Expand Down
180 changes: 146 additions & 34 deletions sensor/pollen-rest-sensor.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,159 @@
- platform: rest
name: pollen
resource: https://www.pollen.com/api/forecast/current/pollen/60640
value_template: "{{value_json.Location.periods[1].Index}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

- platform: rest
name: cold_flu
resource: https://www.pollen.com/api/forecast/extended/cold/60640
value_template: "{{value_json.Location.periods[0].Index}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

pollen_level:
sensor:
# Today's Pollen Index
- platform: rest
name: 'Pollen Index'
resource: https://www.pollen.com/api/forecast/current/pollen/60640
value_template: "{{value_json.Location.periods[1].Index}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Today's Pollen Level
- platform: template
sensors:
pollen_level:
friendly_name: 'Pollen Level'
entity_id: sensor.pollen_index
value_template: >-
{%- if states.sensor.pollen_index.state|float <= 2.4 %}
Low
{%- elif states.sensor.pollen_index.state|float <= 4.8 %}
Med/Low
{%- elif states.sensor.pollen_index.state|float <= 7.2 %}
Med
{%- elif states.sensor.pollen_index.state|float <= 9.6 %}
Med/High
{%- elif states.sensor.pollen_index.state|float <= 12.0 %}
High
{% else %}
Unknown
{%- endif %}
# Tomorrow's Pollen Index Forecast
- platform: rest
name: 'Pollen Index Forecast'
resource: https://www.pollen.com/api/forecast/current/pollen/60640
value_template: "{{value_json.Location.periods[2].Index}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Tomorrow's Pollen Level Forecast
- platform: template
sensors:
pollen_level_forecast:
friendly_name: 'Pollen Level Forecast'
entity_id: sensor.pollen_index
value_template: >-
{%- if states.sensor.pollen.state|float <= 2.4 %}
{%- if states.sensor.pollen_index_forecast.state|float <= 2.4 %}
Low
{%- elif states.sensor.pollen.state|float <= 4.8 %}
Medium-Low
{%- elif states.sensor.pollen.state|float <= 7.2 %}
Medium
{%- elif states.sensor.pollen.state|float <= 9.6 %}
Medium-High
{%- elif states.sensor.pollen.state|float <= 12.0 %}
{%- elif states.sensor.pollen_index_forecast.state|float <= 4.8 %}
Med/Low
{%- elif states.sensor.pollen_index_forecast.state|float <= 7.2 %}
Med
{%- elif states.sensor.pollen_index_forecast.state|float <= 9.6 %}
Med/High
{%- elif states.sensor.pollen_index_forecast.state|float <= 12.0 %}
High
{% else %}
Unknown
{%- endif %}
cold_flu_risk:
# Today's Top Allergen
- platform: rest
name: 'Top Allergen 1'
resource: https://www.pollen.com/api/forecast/current/pollen/60640
value_template: >-
{% if value_json.Location.periods[1].Triggers[0] %}
{{ value_json.Location.periods[1].Triggers[0].PlantType }}
{% else %}
-
{% endif %}
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Today's Second Allergen
- platform: rest
name: 'Top Allergen 2'
resource: https://www.pollen.com/api/forecast/current/pollen/60640
value_template: >-
{% if value_json.Location.periods[1].Triggers[1] %}
{{ value_json.Location.periods[1].Triggers[1].PlantType }}
{% else %}
-
{% endif %}
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Today's Third Allergen
- platform: rest
name: 'Top Allergen 3'
resource: https://www.pollen.com/api/forecast/current/pollen/60640
value_template: >-
{% if value_json.Location.periods[1].Triggers[2] %}
{{ value_json.Location.periods[1].Triggers[2].PlantType }}
{% else %}
-
{% endif %}
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Pollen Trend
- platform: rest
name: 'Pollen Trend'
resource: https://www.pollen.com/api/forecast/outlook/60640
value_template: "{{value_json.Trend}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Pollen Outlook
- platform: rest
name: 'Pollen Outlook'
resource: https://www.pollen.com/api/forecast/outlook/60640
value_template: "{{value_json.Outlook}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Pollen Season
- platform: rest
name: 'Pollen Season'
resource: https://www.pollen.com/api/forecast/outlook/60640
value_template: "{{value_json.Season}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"

# Today's Cold/Flu Percentage
- platform: rest
name: 'Cold & Flu Percentage'
resource: https://www.pollen.com/api/forecast/extended/cold/60640
value_template: "{{value_json.Location.periods[1].Index}}"
scan_interval: 21600
headers:
Referer: "https://www.pollen.com"
unit_of_measurement: "%"

# Today's Cold/Flu Risk
- platform: template
sensors:
cold_flu_risk:
friendly_name: 'Cold & Flu Risk'
entity_id: sensor.cold__flu_percentage
value_template: >-
{%- if states.sensor.cold_flu.state|float <= 2.4 %}
{%- if states.sensor.cold__flu_percentage.state|float <= 2.4 %}
Low
{%- elif states.sensor.cold_flu.state|float <= 4.8 %}
Medium-Low
{%- elif states.sensor.cold_flu.state|float <= 7.2 %}
Medium
{%- elif states.sensor.cold_flu.state|float <= 9.6 %}
Medium-High
{%- elif states.sensor.cold_flu.state|float <= 12.0 %}
{%- elif states.sensor.cold__flu_percentage.state|float <= 4.8 %}
Med/Low
{%- elif states.sensor.cold__flu_percentage.state|float <= 7.2 %}
Med
{%- elif states.sensor.cold__flu_percentage.state|float <= 9.6 %}
Med/High
{%- elif states.sensor.cold__flu_percentage.state|float <= 12.0 %}
High
{% else %}
Unknown
Expand Down

0 comments on commit f833c30

Please sign in to comment.