Change desktop background based on weather (MQTT + HASS Workstation Service)

Full guide here: https://smarthomepursuits.com/hass-workstation-service-automatically-change-desktop-wallpaper-based-on-weather/

Have you ever thought how cool it would be to if your desktop PC wallpaper automatically changed based on the weather outside? For example, if it was raining, the wallpaper would change to a live “rainy” wallpaper, or if it was sunny, it might show a beach with moving waves.

In combination with Home Assistant, HASS Workstation Service, and Lively backgrounds, this is definitely possible!

I did not come up with this idea, so all credit goes to GeekToolKit’s youtube video. He went through the setup very quickly, and after I set this up myself, I found a few extra things he should’ve pointed out, so I took the time to document this process step-by-step.

Enjoy!

Prerequisites

This guide assumes you already have Home Assistant running and HASS Workstation Service is already setup. HASS Workstation Service, in case you didn’t know, is an application that lets you control your desktop PC from within Home Assistant. If you don’t have these setup up, refer to these links first.

Download Lively

The first step is to download Lively Backgrounds from here: Lively Wallpaper by rocksdanister

Once downloaded, installed, and running, you should see a Lively Wallpaper icon in your taskbar by your clock. Click that to open. Choose any background as a test to see if it works.

If you have only 1 monitor, you can move onto the next step. But if you have multiple, you are going to want to click the monitor icon and choose “span across screens”.

Download and install Lively Command Line tools

For this to work, you need to download the lively_command_utility.zip from here: Releases · rocksdanister/lively · GitHub

Once downloaded, right click to extract. Extract it to a folder. For this demo, I extracted mine to C:\Users\Danny\Pictures\Lively.

Create CustomAction in HASS Workstation Service

Launch HASS Workstation Service from your Windows start button. Ensure your MQTT broker shows an “All Good” status.

Under the Commands section, click Add.

Give it a name like “SetRainWallpaper” and paste a path like below. The first path is the path location of the command line utility, and the 2nd path is the location of the lively wallpapers.

To find the path of the Lively wallpapers, open the Lively app and right click any wallpaper >Open File Location:

Then, copy the path to clipboard:

Next, you will combine those together to form a command like this:

C:\Users\Danny\Pictures\Lively\livelycu setwp --file "C:\Users\Danny\AppData\Local\Lively Wallpaper\Library\wallpapers\xn0quq52.bq2"

Then, click Test. If it works correctly, you can click Save. If it doesn’t work, you will probably need to mess with the first path until it does.

Create Home Assistant Automation to Change Background When It Rains

Now that you confirmed you can change background via command line using HASS Workstation, it’s time to create the automations(s) in Home Assistant. To do this, we are using a “trigger” state of rainy. If rainy, then SetRainBackground.

In HA, navigate to Configuration > Automations > Add Automation. Start with an empty automation.

  • Name: Rainy Desktop
  • Trigger Type: State
  • Trigger State: start typing “weather”. My entity is called weather.my_ecobee, but yours may be different.
    • Attribute: blank
    • From: blank
    • To: Rainy
    • For: empty

  • Conditions: Empty
  • Actions
    • Action Type: Call Service
    • Service: switch.turn_on
    • Targets: Choose an entity (Type whatever you named your button)

Reset Background if Not Rainy

Something the video didn’t point out is, how do you revert your background to something different if it isn’t rainy? It’s quite simple. You basically just create another automation like above, except you use different states.

Under Triggers, you would set it from Rainy to Cloudy, Rainy to sunny, and Rainy to Partly cloudy. (There may be more states your weather services reports, so be sure to click the history of your weather entity to find the others.) Under actions, you would choose a different background that you’ve set up in Hass Workstation Service.

Testing It Out

Obviously if it’s sunny out and you want to test this automation out, you don’t want to have to wait until it starts raining. A quick way to test this out is to manually change the weather state in Developer Tools.

Click Developer Tools. Search for your weather entity. Change the state from whatever it is set to, to Rainy. Then click save.

If all goes well, your background should’ve changed! If you also set the “reset background” automation, you can switch it to sunny, cloudy, or partly cloudy as well and it should change.

3 Likes

That really looks interesting, thanks for contributing :+1:t4::muscle:t4:

Awesome project! When I “test” the command, it works, but it doesn’t work from HA. Just wonderin gif you have an idea why this would be the case…

Honestly I’m not sure. It still works for me almost a year later after creating this post.

Did you mean it works when you manually set the state via Developer Tools?

1 Like

No, I mean when I test the command in the Hass Workstation Service. Clicking “test” will change the background, but clicking the switch in HA for that custom command doesn’t do anything.

Hello, this is a very interesting topic, do you if its possible to pass a variable as <file-path> in the:
setwp --file <file-path> --monitor <screen-id>
in order to change it in home assistant? My use case is to randomize videos I have in my computer so that the screensave/wall paper changes all the time