WeatherFlow PiConsole

A new feature?
On the WF-app i have no rain, today there was only a little snowfall…

IMG_20181209_184836

Yes, it means that your Sky module has detected rain, but the total is less than 0.1 mm. The WF-app does not show anything below 0.1 mm.

3 Likes

Love it :heart_eyes:

1 Like

New release (v1.8) of the WeatherFlow PiConsole. Changes include:

  • Update notification will now prompt users to download the latest version

For the update notification to work, a new Python module is required. Please run

sudo python3 -m pip install packaging

before using the new version. The update notification will check if a new version of the code is available once a day at midnight, and when the console is first run. The popup can be easily dismissed using the exit button in the top right, but will reappear the following midnight.

Update

8 Likes

Peter - This console just keeps getting better and better. Thank you for all of your hard work.

Rick Comito

3 Likes

Just a heads up that there might be issues with the console if it disconnects, or you try to start it from scratch. Details here: Websocket issues

1 Like

I have exactly this issue… :frowning_face:

Looks like a fix is in the pipeline. Hopefully it’ll be back up and running soon :smiley:

Should be back up and running again now. You may need to restart the console :smiley:

peter …

any chance of allowing personal preferences on 'Feeling' text messages?

I know I’m not in the majority (living in sunny Florida USA) but 64F is NOT considered HOT.
image

perhaps a configuration file or *.ini ?

it would be nice if we could adjust that trigger based on Temp & Dew Point - as opposed to just Temp… as discussed HERE.

4 Likes

Yes, absolutely! In fact it is exactly what I am working on at the moment :smiley: .

My initial instinct was to remove this feature all together, as no one was going to be happy with the hard coded cutoffs (except me of course :wink:). But I like the feature over all and decided that the best way forward was to allow users to define their own cutoffs. This opened a bit of a can of worms, however, regarding how the code handles personal settings, and how these personal settings are maintained between updates. I don’t want you have to to re-enter your cutoffs every time I update the code. So before I can implement this change, I am working on a way of making the wfpiconsole.ini file persistent between versions, saving the API keys and user specified settings. Once that is up and running, then I can introduce the user defined cutoffs for the Feels Like temperature.

So the cutoff at the moment is based on the Feels Like temperature, which is either derived from the wind chill, the observed temperature, or the heat index depending on the ambient temperature and humidity. In your screen shot it is too “cold” for the heat index to be calculated (which is only defined for temperatures above 80 F), so the Feels Like temperature is based on the ambient temperature.

Hope this all helps!

2 Likes

peter…

GREAT - thanks for the insight.

It would be great to have a persistent *.ini file through updates, but it really isn’t a big deal to modify it with each update. Perhaps I have it a bit easier - as I have both of my piconsole monitors with SMB enabled - so I can just pull up the files with my favorite windows text editor (Notepad+) and cut-a-paste in my settings. Adding the ‘Feels Like’ settings along with that would be as easy. But making it even easier would be fantastic.!

I do modify several files each time you do an update, on my large screen piconsole - because of the layout and large screen format. I’ve got it down to where I can make all the changes in just a few minutes. What takes the time is trying to find what you might have changed that is not obvious? ie I noticed changes in the clock format / layout / syntax in the last version 1.8. I prefer a 12H format (more really for my wife). Adding that option would also be welcomed.
image

Hi Peter - I have a bash script that takes care of checking for / pulling updates and updating the parameters in the .ini file. I’m happy to post it, if you’re interested.

Rick Comito

2 Likes

Hi Rick,

Yea would be good to see what approach you have taken. I am working on a solution in Python that when the console is run for the very first time, will prompt you to enter API keys. etc directly into the console, and which will then be copied to the .ini file. Then for every new version update the code will compare your existing .ini file against a default version, transferring keys across as necessary, and perhaps asking for input if new keys are required.

Peter - Your solution sounds much more refined than mine.

I can’t figure out how to include a code block in this forum so I’ve attached it as a .txt file.

WFconsole.txt (5.7 KB)

Rename WFconsole.txt to WFconsole and push it to your PiConsole machine.

Maybe you can find something useful in it.

Rick Comito

to add some code you have to set 3 back tick before and behind the code, forum will set it as code (take out the double quotes as I had to set those to ‘hide’ the back ticks to the forum)

" ``` "
your code

" ``` "

1 Like

Peter, I keep configuration files in their own folder. I use a template file that I can update with new keys and save the users configuration to a working file that is read by the applications. You can see how this works by looking at config.ejs and server.js.

You are welcome to download and use any and all portions of my install.sh and updatefiles.sh scripts. And I am happy to answer any questions you may have.

2 Likes

Thanks Eric - Let’s try this again.

#!/usr/bin/env bash
#
# WFconsole             20181117 Rick Comito
#
# WeatherFlow console tool
#
# Install this script somewhere in your $PATH and make it executable:
#     e.g.: sudo mv WFconsole /usr/local/bin
#           sudo chmod 755 /usr/local/bin/WFconsole
#
#
# Assumes: Peter's WeatherFlow PiConsole software is installed in default location
#          Software will be started on boot with an entry in user pi's crontab sim
#              @reboot sleep 30; /usr/local/bin/WFconsole start
#                           or
#          Software is run as a service via systemctl:
#              sudo cp WeatherFlowPiConsole.service /etc/systemd/system/
#              sudo systemctl enable WeatherFlowPiConsole.service
#
# Usage: WFconsole <start|stop|restart|status|update>"
#
# WFconsole update updates the software preserving your WeatherFlowPiConsole.ini p
#
# ssh into your console to run the script.

USAGE="usage: WFconsole <start|stop|restart|status|update>"
if [ $# -eq 0 ]; then
    echo $USAGE
    exit
fi
CONSOLEDIR=~/wfpiconsole                # Default home of the console software
DLDIR=${CONSOLEDIR}/download            # Directory to download (potential) update
INI=WeatherFlowPiConsole.ini            # File with API keys etc.
PIDn=$(pgrep -f main.py | wc -l)

# wanisup - Returns 0 if we have an internet connection, 1 if not.
wanisup() {
    ping -c1 www.google.com >> /dev/null && return 0 || return 1
}

# gotinternet - Makes maxtrys trys to verify an internet connection with waittime
# Returns 0 on success, 1 on failure
gotinternet() {
    waittime=5  # Seconds
    maxtrys=12  # 1 minute
    thistry=1

    while [ ! wanisup -a $thistry -le $maxtrys ]; do    # Verify / wait for an int
        echo "Waiting for an internet connection ..."
        thistry=$(thistry + 1)
        sleep $waittime
    done

    return $(wanisup)
}

# isaservice - Returns 0 if console is running as a service.
isaservice () {
    systemctl | grep WeatherFlowPiConsole.service | grep enabled >> /dev/null && r
}

# startconsole - Start an instance of the console
startconsole () {
    if [ isaservice ]; then
        sudo systemctl start WeatherFlowPiConsole.service
    else
        cd $CONSOLEDIR
        python3 ./main.py 2>&1 /dev/null &
    fi
}

# stopconsole - Stop the console
stopconsole () {
    if [ isaservice ]; then
        sudo systemctl stop WeatherFlowPiConsole.service
    else
        pkill -HUP -f main.py
    fi
}

# updateini - Use the current INI to update the keys etc in the new one.
updateini () {
    grep "= [a-zA-Z0-9]" $CONSOLEDIR/$INI | grep -v Version |
    while read NAME EQ VALUE; do
        sed -i "/^$NAME =.*/s/.*/$NAME = $VALUE/" $DLDIR/$INI
    done
}

# updateconsole - Apply an update to the console if one is available
updateconsole () {
    if [ ! -d $DLDIR ]; then
        mkdir $DLDIR
    fi
    cd $DLDIR
    # Get the latest available software
    wget -q https://api.github.com/repos/peted-davis/WeatherFlow_PiConsole/tarball
    # and extract it from the compressed tarball
    tar -xvf PiConsole.tar.gz --strip 1 1>&2 >> /dev/null
    rm PiConsole.tar.gz
    # Get the version from the current INI file ...
    currentversion=$(grep Version $CONSOLEDIR/$INI | sed 's/ =/:/')
    # ... and the latest version from the downloaded INI file
    latestversion=$(grep Version $INI | sed 's/ =/:/')
    if [[ $currentversion != $latestversion ]]; then
        echo "Current $currentversion"
        echo "Latest  $latestversion"
        read -p "Update? <y/n> " -n 1 response
        echo
        case $response in
            y|Y)
                cd ~
                # Update the new INI file
                updateini
                stopconsole
                # rsync will update the files that have changed and remove deprica
                rsync -Halz --delete-after ${DLDIR}/ $CONSOLEDIR
                startconsole
                ;;
            *)
                echo "Update aborted."
                ;;
        esac
    else
        echo "Current $currentversion"
        echo "Latest  $latestversion"
        echo "No update needed"
    fi
    cd ~
    rm -rf $DLDIR
}


if [ gotinternet ]; then
    case $1 in
        start)
            if [ $PIDn -eq 1 ]; then
                echo Console running
            elif [ $PIDn -gt 1 ]; then
                echo "Restarting (PIDn: $PIDn)"
                stopconsole
                startconsole
            else
                echo Starting console
                startconsole
            fi
            ;;
        stop)
            if [ $PIDn -gt 0 ]; then
                echo Stopping console
                stopconsole
            else
                echo Console stopped
            fi
            ;;
        restart)
            echo Stopping console
            stopconsole
            echo Restarting console
            startconsole
            ;;
        status)
            if [ $PIDn -eq 0 ]; then
                echo Console stopped
            elif [ $PIDn -eq 1 ]; then
                echo Console running
            else
                echo "PIDn: $PIDn ... Restarting"
                stopconsole
                startconsole
            fi
            ;;
        update)
            updateconsole
            if [[ $latestversion != $currentversion ]]; then
                echo "Updated $currentversion to $latestversion"
            fi
            ;;
        *)
            echo $USAGE
            ;;
    esac
    exit 0
else
    echo "No internet connection.  Try again later"
    exit 1
fi

That worked great Eric. Thanks again.

Rick Comito

1 Like

Thanks @rcomito, that looks like a great script. Definitely going to have a good look at it. Also thank @GaryFunk for pointing me to useful bits of your code :smiley:.

I’m not getting any data on the pi console station id 5766 any ideas
image