My little accuweather.com MinuteCast®

Hi People started to work on my own ideas for a custom weather widget and i really liked the weather alerts from accuweather so i made a small shell script that can be used to show alerts and i thought i share it with you guys.

#!/bin/bash
SET_AGENT="Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0"
SET_URL="https://www.accuweather.com/en/se/boras/315908/minute-weather-forecast/315908"

weather_alert () {

curl -A "$SET_AGENT" -s $SET_URL |\
         perl -wne 'print if /<div class="mc-summary/ .. /<\/div>/' |\
         perl -wne 'print if /<p>/ .. /<\/p>/' |\
         sed 's/<\/p>//' | sed 's/<p>//' | grep -oE "[A-Z].*"
}

weather_alert

looks like this when you add it as a command line sensor

image

hope that someone will get some usage outta this :slight_smile:

there is how it looks under lovelace
image

6 Likes

Awesome!

Thanks for sharing :slight_smile:

1 Like

updated script above so it works better

Interesting.

Thanks for posting this.

1 Like

will update the script as time goes on with missing weather conditions

a little update again to make it all easier for me to maintain :slight_smile:

an update again no more regexp, using perl to just get the status so it catches everything now from the statusline :slight_smile:

4 Likes

This is great! I’ve been looking for a way to create a lightning alert (being in florida) that I could use to sound an alarm or TTS notification to get out of the pool or something… This seems like a great step in that direction!

1 Like

Hi,

sorry for the noob question.

I’ve created a weatheralert.sh in my HA default folder and then the command line sensor below:

  - platform: command_line
    name: Allerta Meteo
    command: 'bash /volume1/docker/homeassistant/weatheralert.sh'

But I can’t see nothing on reboot. Where is the error?

Thank you in advance!

any errors in the log ?

Yes.

Just a generic error:

Mon Jul 16 2018 08:25:56 GMT+0200 (Ora legale dell’Europa centrale)

Command failed: weatheralert.sh

so make it executeable chmod +x /volume1/docker/homeassistant/weatheralert.sh and make sure that ha has access to the file and it should work.

1 Like

It worked!

But now it appears as a round. How can I show it as a box and how can I set an automation an alert when status change?

all that is simple and its all in the docs :wink:

1 Like

Ok next step.

Did anyone knows how to setup an automation like:

If status contains rain then notify on telegram.

For me it doesn’t work.
-create weather_alert.sh(chmod +x)
-sensor:
platform: command_line
name: Meteo
command: ‘sh /usr/share/hassio/homeassistant/scripts/weather_alert.sh’

get error: Command failed: sh /usr/share/hassio/homeassistant/scripts/weather_alert.sh

-with terminal $ sh /usr/share/hassio/homeassistant/scripts/weather_alert.sh
no rain for 120min

Why not just use the scrape sensor?

1 Like

select: ??? for scrape sensor

The value for “select” will be the CSS selector you want to grab from the page.

For the Accuweather Minutecast page, the select value would be “.mc-summary p” - meaning the text inside the <p> tag that is inside the tag with the “mc-summary” class.

nop…it doesn’t work…