MQTT out for Domoticz

MQTT out for Domoticz

I have been playing with MQTT for Domoticz. After some initial fiddling I have figured out all the commands to send to Domoticz using MQTT for all the different dummy sensors.

All MQTT messages (which you send to topic domoticz/in) have the following JSON format:

{ "command" : "" , "idx" :  , "nvalue" :  ,
 "svalue" : "" ...... }

In a JSON format you can have spaces in between, so “command”:”test” is the same as “command” : “test”. The default command for Domoticz is udevice so you can leave that out if you want to but I have included it in all of them.

Weather sensors

Barometer

The barometer shows the atmospheric pressure and a prediction. You can send digits for the pressure.

{"command":"udevice", "idx":1234, "svalue":"ba;pr"}

where ba is the pressure and pr is the prediction which can have the following values:

pr can have the following values:

  • 0, no prediction
  • 1, sunny
  • 2, partly cloudy
  • 3, cloudy
  • 4, rain
  • 5, unknown
  • 6, cloudy/rain

Temperature+Barometer

The Temperature+Humidity sensor will show just that and a prediction. You can send digits for the temperature but only the first is displayed (it is rounded off). You can send digits for the pressure as well.

{"command":"udevice", "idx":1234, "svalue":"tm;ba;pr"}

where tm is the temperature, ba is the pressure and pr is the prediction which can have the following values:

pr can have the following values:

  • 0, no prediction
  • 1, sunny
  • 2, partly cloudy
  • 3, cloudy
  • 4, rain
  • 5, unknown
  • 6, cloudy/rain

Temperature+Humidity+Barometer

The temperature+Humidity+Barometer sensor will show just that and an environment level and a prediction. You can send digits for the temperature but only the first is displayed (it is rounded off). The humidity only displays whole numbers (chops off any digits).

{"command":"udevice", "idx":1234, "svalue":"tm;hu;lv;ba;pr"}

where tm is the temperature, hu is the humidity and lv is the environment level, ba is the pressure and pr is the prediction.

lv can have the following values:

  • 0, normal
  • 1, comfortable
  • 2, dry
  • 3, wet

pr can have the following values:

  • 0, no prediction
  • 1, sunny
  • 2, partly cloudy
  • 3, cloudy
  • 4, rain
  • 5, unknown
  • (oddly enough 6 cloudy/rain does not work for this sensor)

Rain

The rain sensor will show the amount of rain fallen in mm and a rate in mm/h. You can send

{"command":"udevice", "idx":1234, "svalue":"rt;fl"}

where rt is the rate in mm/h fl is amount of rain fallen. PLEASE NOTE that fl is cumulative, so if the value is 3 mm and you send 2 mm, it will be 5 mm.

Solar radiation

The solar radiation sensor will show just that in W/m2. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

UV

The UV sensor will show just that in the UV Index. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"uv;0"}

where uv is the uv index.

Visibility

The visibility sensor will show just that in km. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Wind

The wind sensor will show wind direction, velocity and gust speed. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"an;dr;sp;gu;tm;ch"}

where an and dr are used to show the angle and wind direction, where an is the angle (can be any number and my have digits after the decimal) and dr is the direction. You can use N, NE, E, SE, S, SW, W and NW. sp is the speed in 0.1 m/s and gu is the gust speed in 0.1 m/s.

Wind+Temperature+Chill

The wind+temperature+chill sensor uses the same command as the wind sensor except in this case the tm (temperature, you can not use digits after the decimal) and ch (chill temperature, you can not use digits after the decimal) are shown.

Temperature sensors

Humidity

The humidity sensor will show humidity and an environment level. You can only send whole numbers.

{"command":"udevice", "idx":1234, "svalue":"lv", "nvalue":hu}

where hu is the humidity and lv is the environment level which can have the following values:

  • 0, normal
  • 1, comfortable
  • 2, dry
  • 3, wet

Temperature+Humidity

The temperature+humidity sensor will show humidity and an environment level. For the temperature you can send digits after the decimal. For humidity anything after the decimal will be chopped off.

{"command":"udevice", "idx":1234, "svalue":"tm;hu;lv"}

where tm is the temperature, hu is the humidity and lv is the environment level which can have the following values:

  • 0, normal
  • 1, comfortable
  • 2, dry
  • 3, wet

Temperature

The temperature sensor will show the temperature. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Temperature+Humidity+Barometer

See section Weather sensors.

Wind+Temperature+Chill

See section Weather sensors.

Utility sensors

Air quality

The air quality sensor will some value in ppm. You can only send whole numbers.

{"command":"udevice", "idx":1234, "nvalue":3}

Lux

The lux sensor will show the amount of light in lux. Any extra digits send are chopped off.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Pressure

The pressure sensor will show the pressure in bar. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Distance

The distance sensor will show the distance in cm. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Leaf wetness

The leaf wetness sensor will show the leaf wetness. You can only send whole numbers.

{"command":"udevice", "idx":1234, "nvalue":34}

Percentage

The percentage sensor will show a percentage. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Scale

The scale sensor will show the weight of something in kg. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Thermostat setpoint

The thermostat setpoint sensor will show setpoint of a thermostat. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Soil moisture

The soil moisture sensor will show the soil moisture in centiBars. You can only send whole numbers.

{"command":"udevice", "idx":1234, "nvalue":34}

Sound level

The sound level sensor will show the level of sound in decibel of something. Digits after the decimal are dropped.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Custom

The custom sensor will show what you want in the units you want. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Alert

The alert sensor will show you a message and an alert level.

{"command":"udevice", "idx":1234, "svalue":"any text", "nvalue":lvl}

where level can be any of the following:

  • 0 off, grey
  • 1 ok, green
  • 2 yellow, level 1 warning
  • 3 orange, level 2 warning
  • 4 red, level 3 warning

Text

The text sensor will show any text you want.

{"command":"udevice", "idx":1234, "svalue":"any text"}

Ampere (1 phase)

The ampere (1 phase) sensor will show the power draw in A. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Ampere (3 phase)

The ampere (3 phase) sensor will show the power draw in A for 3 phases. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"p1;p2;p3"}

where p1, p2 and p3 are the the power draw for every phase.

Usage

The voltage sensor will show the usage in Watt of something. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Voltage

The voltage sensor will show voltage of something. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Electric

The electric sensor will show the current usage of electricity in Watt and the cumulative usage in kWh. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"us;cu"}

where us is usage in Watt and cu is cumulative usage in Wh (even though it is displayed in kWh)

P1 Smart meter

The P1 Smart meter sensor allows you to show you power consumption, low and high usage, low and high return, actual consumption and actual return.

{"command":"udevice", "idx":1234, "svalue":"lu;hu;lr;hr;ac;ar"}

where lu is low tariff usage (in Wh so 1000 is 1 kWh), hu is high tariff usage (in Wh), lr is low tariff return (in Wh), hr is high tariff return (in Wh), ac is actual consumption (in W) and ar is current usage (in W).

Gas

The gas sensor will show the usage of gas in m3. You can add digits after the decimal if needed.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Waterflow

The waterflow sensor shows the water flow in liters / minute. You can add digits after the decimal.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

Counter

The counter sensor will show usage. You can add digits after the decimal if needed. The main display will show it rounded of to 2 digits while beneath it, it will show the whole number you upload. For some reason the log shows the value for every hour and that value is the value at the start of the hour.

{"command":"udevice", "idx":1234, "svalue":"3.45"}

The tricky part is that the type of counter determines what number you should upload:

  • Energy, upload per Wh, displayed in kWh
  • Gas, upload per 0.01 m3, displayed in m3
  • Water, upload per 10 l, display in l (and in m3 below the main display)
  • Counter, upload per 1 something, also displayed in the same format
  • Energy generated, upload per Wh, displayed in kWh
  • Time, have not figured out how to use this yet

Counter incremental

The counter incremental sensor will show the same thing as its counterpart counter but every time a value is send, it is added to the amount instead of replacing the amount.

Managed counter

Haven’t figured out yet what makes this different but it seems to act like a normal counter as described above.

One thought on “MQTT out for Domoticz

  1. I used this to update a Managed Counter History in the DB
    { “command”: “udevice”, “idx”: 2, “nvalue”: 0, “svalue”: “-1;26740;2023-07-27” }

    Like

Leave a comment