Weather Forecast by Hue Bulb

Hey All:

So I’ve been straining over this for a while, partially because I’m such a neophyte at this and partially because my coding skills suck.

I have a colour Hue bulb by the front door of my house. It turns on every morning for me before I go to work (and as long as the sun hasn’t risen). I’m up before that anyways. I wanted that bulb to tell me what today would be like as compared to yesterday - bluer if it’s colder, oranger if it’s warmer. I never bother checking the forecast and can never remember what the actual numeric temperature was the next day - I just want to know if I should grab a coat on my way out the door or not.

Here’s my various pieces to make this happen. If you guys spot a refinement, please let me know, but if it’s the kind of “Hey, cool automation” trick that you’d like to show off your toys, please feel free

configuration.yaml:

input_number:
  var_weather_difference:
    name: Weather Difference
    min: -10
    max: 10
    mode: box
sensor:
  - platform: yweather
    forecast: 0
    name: weather_today
    monitored_conditions:
      - temp_max
  - platform: yweather
    forecast: 1
    name: weather_tomorrow
    monitored_conditions:
      - temp_max 

automation.yaml

- id: storehightemp
  alias: Store difference between today and tomorrow
  trigger:
  - platform: time
    at: '23:00:00'
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.var_weather_difference
  value: >
    {% if ((states('sensor.weather_tomorrow_temperature_max')|int) - (states('sensor.weather_today_temperature_max')|int)) > 10 %}
      10
    {% elif ((states('sensor.weather_tomorrow_temperature_max')|int) - (states('sensor.weather_today_temperature_max')|int)) < -10 %}
      -10
    {% else %}
      {{(states('sensor.weather_tomorrow_temperature_max')|int) - (states('sensor.weather_today_temperature_max')|int)}}
    {% endif %}
- id: ruleFrontLightsOninMorning
  alias: Turn on Front Lights in Morning
  trigger:
  - platform: time
    at: '06:30:00'
  condition:
  - condition: sun
    before: sunrise
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.front_entrance
      brightness_pct: 25
      color_temp: >
        {{(((states('input_number.var_weather_difference')|int) * 17.35) + 326.5)|int}}

Enjoy!

8 Likes

I like the idea of using the difference between two days and showing the value in a colored bulb.

For the five faves that I got for this, there’s an edit on the original post (I assume a reply notifies you of this).

I had assumed that we would never swing more than 10 degrees in a single day. Anyone who lives in my neck of the woods (Calgary, Alberta, Canada) knows that this was a stupid assumption. The original code therefore breaks when, for example, we shifted by a lovely 15 degrees celsius overnight. My -10 – 10 bounded input box puked last night.

So, here’s some if-then-else statements to fix that. Added a bit more work for anyone who wants more nuanced control than +/-10 but I trust you’ll figure it out. And this will be a reference and a lesson for me.