hi there for people who might be using WeeWx and want to import data into Domoticz home automation. I struggle with this for a bit, as every method I tried did not work. in the end I ended up combining several methods to get a method that worked.
Install Weewx:
wget -qO - http://weewx.com/keys.html | sudo apt-key add -
wget -qO - http://weewx.com/apt/weewx.list | sudo tee /etc/apt/sources.list.d/weewx.list
apt-get update
apt-get install weewx
configure and install your weather station:
recommended software:
Belchertown - nice web interface
Weewx-mqtt - mqqt publishing of weewx data
Weewx-influx - send weewx data to influxdb
Weewx-sdr - SDR driver for weewx
WeeWX to Domoticz
download stats.py to weewx/user
cd /usr/share/weewx/user
wget https://raw.githubusercontent.com/weewx/weewx/master/examples/stats.py
now we need to modify weewx.conf
nano /etc/weewx/weewx.conf
Inside the section [StdReport] you can find the following subsections: [[StandardReport]] , [[FTP]] and [[RSYNC]] : after the latter section, before the line ############################### , add the following section:
[[Domoticz]]
skin = Domoticz
HTML_ROOT = /var/www/html/
and save with ctrl-x , y , enter
now we need to create the Domoticz skin.conf
cd /etc/weewx
mkdir skins/Domoticz
nano skins/Domoticz/skin.conf
and copy and past this>
[CheetahGenerator]
encoding = html_entities
search_list_extensions = user.stats.MyStats
[[ToDate]]
[[[Domoticz]]]
template = domoticz.json.tmpl
[Generators]
generator_list = weewx.cheetahgenerator.CheetahGenerator
now we have to create the template :
nano skins/Domoticz/domoticz.json.tmpl
and paste this in:
#encoding UTF-8
{
"time":"$current.dateTime",
"stats": {
"current": {
"outTemp":"$current.outTemp.format(add_label=False)",
"windchill":"$current.windchill.format(add_label=False)",
"heatIndex":"$current.heatindex.format(add_label=False)",
"dewpoint":"$current.dewpoint.format(add_label=False)",
"humidity":"$current.outHumidity.format(add_label=False)",
"barometer":"$current.barometer.format(add_label=False)",
"barometerTrendData":"$trend.barometer.format(add_label=False)",
"windSpeed":"$current.windSpeed.format(add_label=False)",
"windDir":"$current.windDir.format(add_label=False)",
"windDirText":"$current.windDir.ordinal_compass",
"windGust":"$current.windGust.format(add_label=False)",
"windGustDir":"$current.windGustDir.format(add_label=False)",
"rainRate":"$current.rainRate.format(add_label=False)",
"rxCheckPercent":"$current.rxCheckPercent.format(add_label=False)"
},
"sinceMidnight": {
"rainSum":"$day.rain.sum.format(add_label=False)"
}
}
}
now restart weewx
/etc/init.d/weewx restart
to check weewx for run errors
tail -f /var/log/syslog |grep weewx
Now to configure Domoticz
Virtual sensors must be created in Domoticz
Setup > Hardware, Add: “Dummy (Does nothing, use for virtual switches only)”,
name the virtual hardware is here “WeeWX”. Created once for WeeWX weather station.
Setup > Hardware > for created virtual hardware > Create Virtual Sensors,
three sensors should be created, this dzVents script assumes that are named:
name: “Weatherstation”, Sensor Type: “Temp+Hum+Baro”
name: “Wind”, Sensor Type: “Wind”
name: “Rain”, Sensor Type: “Rain”
Now create an dzVents script
Setup>More Options> Events
change type to dzVents
name weewx
and enable
copying this to the script window
-- dzVents script: "weewx.lua" to fetch weather data from WeeWX and present it in Domoticz
--
-- dzVents Version: 2.4 or higher is needed
--
-- Virtual sensors must be created in Domotics
-- Setup > Hardware, Add: "Dummy (Does nothing, use for virtual switches only)",
-- name the virtual hardware is here "WeeWX". Created once for WeeWX weather station.
-- Setup > Hardware > for created virtual hardware > Create Virtual Sensors,
-- three sensors should be created, this dzVents script assumes that they are named:
-- name: "Weatherstation", Sensor Type: "Temp+Hum+Baro"
-- name: "Wind", Sensor Type: "Wind"
-- name: "Rain", Sensor Type: "Rain"
--
local DEBUGPRT = false -- true if debug print to log, else false
return {
on = {
timer = {"every 5 minutes"},
httpResponses = {"statusTrigger"}
},
execute = function(domoticz, item)
local temp_hum_baro = domoticz.devices("Weatherstation")
local wind = domoticz.devices("Wind")
local rain = domoticz.devices("Rain")
if (item.isTimer) then
-- Send a status request
domoticz.openURL({
url = "http://192.168.1.125/domoticz.json",
method = "GET",
callback = "statusTrigger"
})
end
if (item.isHTTPResponse and item.ok and item.isJSON) then
if (item.trigger == "statusTrigger" and item.json.stats ~= nil) then
if (DEBUGPRT == true) then
print(string.format("WeeWX %s", item.json.time))
print(string.format("outTemp: %s", item.json.stats.current.outTemp))
print(string.format("windchill: %s", item.json.stats.current.windchill))
print(string.format("heatIndex: %s", item.json.stats.current.heatIndex))
print(string.format("dewpoint: %s", item.json.stats.current.dewpoint))
print(string.format("humidity: %s", item.json.stats.current.humidity))
print(string.format("barometer: %s", item.json.stats.current.barometer))
print(string.format("windSpeed: %s", item.json.stats.current.windSpeed))
print(string.format("windDir: %s", item.json.stats.current.windDir))
print(string.format("windDirText: %s", item.json.stats.current.windDirText))
print(string.format("windGust: %s", item.json.stats.current.windGust))
print(string.format("windGustDir: %s", item.json.stats.current.windGustDir))
print(string.format("rainRate: %s", item.json.stats.current.rainRate))
print(string.format("rainSum: %s", item.json.stats.sinceMidnight.rainSum))
end
local dp = tonumber(item.json.stats.current.dewpoint)
local hum_stat = domoticz.HUM_NORMAL
if (dp > 20) then
hum_stat = domoticz.HUM_WET
elseif (dp > 10) then
hum_stat = domoticz.HUM_COMFORTABLE
else
hum_stat = domoticz.HUM_DRY
end
temp_hum_baro.updateTempHumBaro(item.json.stats.current.outTemp,
item.json.stats.current.humidity, hum_stat,
item.json.stats.current.barometer, domoticz.BARO_NOINFO)
wind.updateWind(item.json.stats.current.windDir,
item.json.stats.current.windDirText,
item.json.stats.current.windSpeed,
item.json.stats.current.windGust,
item.json.stats.current.outTemp,
item.json.stats.current.windchill)
rain.updateRain(item.json.stats.current.rainRate * 100,
item.json.stats.sinceMidnight.rainSum)
end
end
end
}
and you are done you should see your weather station data loading into domoticz every 5 minutes
I use the weather station data and other data from weather services in domoticz to determine if my wind generator brakes should be applied. Ie Massive drop in air pressure over short period of time will automatically enable my wind generator braking system… once air speeds normalize to safe operational levels then the brake will be released for normal operations…
that control is done in blockly