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.
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.
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.
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)
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.
#!/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
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 .
Then it would seem DNS is working. Check the config file and make sure your station ID is correct and that the API key is correct. Otherwise, @peter will need to assist you.
I got it to work i reinstalled dependencies thank you for your help @GaryFunk. And is it possible to change time to 12 hour clock? and I’m assuming the indoor temp will work when the indoor weather flow is released
Hi @dswally, glad to see you have managed to get in running. Which dependency did you have to reinstall? Thanks @GaryFunk for the troubleshooting help .
It is currently not possible to show the time in a 12-hour format, but I am currently working on a new version that will have a settings screen allowing you to change things like the time format, and the temperature cutoffs for the “feels like” display. Sneak peak: