Hi everyone
I have a free tier account with AccuWeather which allows for 50 API call per day. I have written what I think is a nice feature in determining if my irrigation should run based on the rain probability + volume. I currently have the following set up:
In configuration.yml
:
rest:
# Retrieve rain probabilities and volumes from 5 day forecast on AccuWeather
- resource: "http://dataservice.accuweather.com/forecasts/v1/daily/5day/LOCATION?apikey=MyKeY&details=true&metric=true"
scan_interval: 360
sensor:
- name: "AccuWRainProbabilityDay1"
value_template: "{{ value_json['DailyForecasts'][1]['Day']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueDay1"
value_template: "{{ value_json['DailyForecasts'][1]['Day']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityNight1"
value_template: "{{ value_json['DailyForecasts'][1]['Night']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueNight1"
value_template: "{{ value_json['DailyForecasts'][1]['Night']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityDay2"
value_template: "{{ value_json['DailyForecasts'][2]['Day']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueDay2"
value_template: "{{ value_json['DailyForecasts'][2]['Day']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityNight2"
value_template: "{{ value_json['DailyForecasts'][2]['Night']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueNight2"
value_template: "{{ value_json['DailyForecasts'][2]['Night']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityDay3"
value_template: "{{ value_json['DailyForecasts'][3]['Day']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueDay3"
value_template: "{{ value_json['DailyForecasts'][3]['Day']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityNight3"
value_template: "{{ value_json['DailyForecasts'][3]['Night']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueNight3"
value_template: "{{ value_json['DailyForecasts'][3]['Night']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityDay4"
value_template: "{{ value_json['DailyForecasts'][4]['Day']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueDay4"
value_template: "{{ value_json['DailyForecasts'][4]['Day']['Rain'].Value }}"
unit_of_measurement: "mm"
- name: "AccuWRainProbabilityNight4"
value_template: "{{ value_json['DailyForecasts'][4]['Night']['RainProbability'] }}"
unit_of_measurement: "%"
- name: "AccuWRainValueNight4"
value_template: "{{ value_json['DailyForecasts'][4]['Night']['Rain'].Value }}"
unit_of_measurement: "mm"
Then in template.yml
I have:
# AccuWeather integration calculations
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainProbabilityDay1"
unit_of_measurement: "%"
state: >
{% set Day = states('sensor.AccuWRainProbabilityDay1')|float %}
{% set Night = states('sensor.AccuWRainProbabilityNight1')|float %}
{{ ((Day + Night) / 2) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainProbabilityDay1')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainProbabilityDay2"
unit_of_measurement: "%"
state: >
{% set Day = states('sensor.AccuWRainProbabilityDay2')|float %}
{% set Night = states('sensor.AccuWRainProbabilityNight2')|float %}
{{ ((Day + Night) / 2) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainProbabilityDay2')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainProbabilityDay3"
unit_of_measurement: "%"
state: >
{% set Day = states('sensor.AccuWRainProbabilityDay3')|float %}
{% set Night = states('sensor.AccuWRainProbabilityNight3')|float %}
{{ ((Day + Night) / 2) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainProbabilityDay3')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainProbabilityDay4"
unit_of_measurement: "%"
state: >
{% set Day = states('sensor.AccuWRainProbabilityDay4')|float %}
{% set Night = states('sensor.AccuWRainProbabilityNight4')|float %}
{{ ((Day + Night) / 2) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainProbabilityDay4')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainVolumeDay1"
unit_of_measurement: "mm"
state: >
{% set Day = states('sensor.AccuWRainValueDay1')|float %}
{% set Night = states('sensor.AccuWRainValueNight1')|float %}
{{ (Day + Night) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainValueDay1')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainVolumeDay2"
unit_of_measurement: "mm"
state: >
{% set Day = states('sensor.AccuWRainValueDay2')|float %}
{% set Night = states('sensor.AccuWRainValueNight2')|float %}
{{ (Day + Night) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainValueDay2')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainVolumeDay3"
unit_of_measurement: "mm"
state: >
{% set Day = states('sensor.AccuWRainValueDay3')|float %}
{% set Night = states('sensor.AccuWRainValueNight3')|float %}
{{ (Day + Night) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainValueDay3')) }}"
- trigger:
- platform: time_pattern
hours: '/12'
sensor:
- name: "RainVolumeDay4"
unit_of_measurement: "mm"
state: >
{% set Day = states('sensor.AccuWRainValueDay4')|float %}
{% set Night = states('sensor.AccuWRainValueNight4')|float %}
{{ (Day + Night) | round(1, default=0) }}
availability: "{{ is_number(states('sensor.AccuWRainValueDay4')) }}"
According to AccuWeather counters I am consistently hitting 10 messages per hour, and I don’t know why that is? According to me I make one call, and from that one call all is being calculated. Or am I missing something important?
Any help will be greatly appreciated!