Howto Weewx to Domoticz Home Automation

Tags: #<Tag:0x00007f8de5eab6e8>

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 - | sudo apt-key add -
wget -qO - | 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 to weewx/user

cd /usr/share/weewx/user

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:

      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>

    encoding = html_entities
    search_list_extensions = user.stats.MyStats

        template = domoticz.json.tmpl

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
  "stats": {
    "current": {
     "sinceMidnight": {

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: “Weaterstation”, 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
            url = "",
            method = "GET",
            callback = "statusTrigger"
    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))
            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
                hum_stat = domoticz.HUM_DRY
                item.json.stats.current.humidity, hum_stat,
                item.json.stats.current.barometer, domoticz.BARO_NOINFO)
            rain.updateRain(item.json.stats.current.rainRate * 100,

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

forgot to mention Domoticz defaults measurement is m/s for wind . edit dzVents script


if wanting to work in different measure ie km/h even if the json is in km/h it will assume it will assume the input is m/s … so a work around is this is to divide by 3.6 for km/h or divide by 2.237 for miles per hour

item.json.stats.current.windSpeed / 3.6,    
item.json.stats.current.windGust / 3.6,

this is probably a bug in the current version of Domoticz so perhaps it will be updated at some point . if not this a the work around for you it will display properly for you in domoticz after that


if you are not sure about domoticz. it an “easy” home automation software with a very small foot print and graphs stuff nicely for you… example: here one for wind - showing temperature /the chill and the temperature variance ;