pywws posting to Domoticz

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
Abnormal
Posts: 2
Joined: Wednesday 18 January 2017 21:13
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.6371
Location: UK
Contact:

pywws posting to Domoticz

Post by Abnormal »

Has anyone already configured their pywws and weather station to submit to Domoticz?

Would you be willing to share your config?
jimicek
Posts: 6
Joined: Monday 09 October 2017 9:35
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: pywws posting to Domoticz

Post by jimicek »

Hello,
my pywws weather station was sending data to Weatherunderground, and Domoticz downloaded it back.
Now I created a pywws template and shell script to transfer weather data directly.
Virtual sensors of adequate type must be created, and their numbers filled in the shell script
This all is placed in my Synology NAS, for your implementation should be probably needed some path modifications

Here is the code:

1/ domoticz.txt template -should be placed along with others txt templates in pywws, and is invoked by placing the template into "logged"" section of weather.ini

Code: Select all

#raw#
T_OUT: #temp_out "%.1f" #

T_IN: #temp_in "%.1f" #

W_DIR: #wind_dir "%.0f" "0" "x * 22.5" #

W_AVE: #wind_ave "%.1f" "" "x * 10" #

W_GUST: #wind_gust "%.1f" "" "x * 10" #

H_OUT: #hum_out "%d" #

H_IN: #hum_in "%d" #

REL_P: #rel_pressure "%.1f" #

#hourly#
RAIN_H: #rain "%.1f" "" "x * 100"#

#daily#
RAIN_D: #rain "%.1f" #

#raw#
W_TXT: #wind_dir "%s" "-" "wind_dir_text[x]"#
2/ shell script pw2domo.sh, which takes data created by pywws and pushes to Domoticz (invoked by cron task)

Code: Select all

#!/bin/bash

PATH=/opt/bin:/opt/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin

#setup
host=192.168.1.22
port=8080
username=
password=
TOUTidx=213
TINidx=214
WDIRidx=218
WAVEidx=219
WGUSTidx=220
HOUTidx=221
HINidx=223
RELPidx=224
RAINidx=225

TOUT=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^T_OUT: \(-[0-9]*\.[0-9]*\).*/\1/p')
TIN=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^T_IN: \([0-9]*\.[0-9]*\).*/\1/p')
WDIR=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^W_DIR: \([0-9]\[0-9]\)*/\1/p')
WAVE=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^W_AVE: \([0-9]*\.[0-9]*\).*/\1/p')
WGUST=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^W_GUST: \([0-9]*\.[0-9]*\).*/\1/p')
HOUT=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^H_OUT: \([0-9]\[0-9]*\)*/\1/p')
HIN=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^H_IN: \([0-9]\.[0-9]\)*/\1/p')
RELP=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^REL_P: \([0-9]*\.[0-9]*\).*/\1/p')
RAINH=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^RAIN_H: \([0-9]*\.[0-9]*\).*/\1/p')
RAIND=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^RAIN_D: \([0-9]*\.[0-9]*\).*/\1/p')
WTXT=$(cat /volume1/web/meteo/data/domoticz.txt | sed -ne 's/^W_TXT: \([A-Z]*\[A-Z]*\)*/\1/p')

HIST=1
if [ "$HIN" -gt 60 ]
then HIST=3
fi
if
[ "$HIN" -ls 40 ]
then HIST=2
fi

HOST=0
if [ "$HOUT" -gt 60 ]
then HOST=3
fi
if
[ "$HOUT" -ls 40 ]
then HOST=2
fi

#output if you run it manually
echo "TOUT = $TOUT"
echo "TIN = $TIN"
echo "WDIR = $WDIR"
echo "WTXT = $WTXT"
echo "WAVE = $WAVE"
echo "WGUST = $WGUST"
echo "HOUT = $HOUT"
echo "HIN = $HIN"
echo "RELP = $RELP"
echo "RAINd = $RAIND"
echo "RAINh = $RAINH"
echo $HIST
echo $HOST

curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$TOUTidx&svalue=$TOUT"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$TINidx&svalue=$TIN"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$WDIRidx&nvalue=0&svalue=$WDIR;$WTXT;$WAVE;$WGUST;0;0"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$HOUTidx&nvalue=$HOUT&svalue=$HOST"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$HINidx&nvalue=$HIN&svalue=$HIST"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$RELPidx&nvalue=0&svalue=$RELP;5"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command&param=udevice&idx=$RAINidx&nvalue=0&svalue=$RAINH;$RAIND"
Post Reply

Who is online

Users browsing this forum: btessela and 1 guest