Domoticz temperatures,switches and utility

Hi all,

Current Setup:

RPI with Domoticz. Has temperature sensors, switches and 1 utility (ultrasonic sensor).
Managed to setup MQTT hardward domoticz/out and forward events to another RPI with Openhabian.
Installed Mosquitto and it receives the Domoticz stuff. So far so good.
Now the tricky parts.

mqtt.items

I can query the broker eg, mosquitto_sub -h localhost -t “#” -u user -P password -q 1
Example output below.

OUTPUT:

{
“Battery” : 100,
“RSSI” : 5,
“description” : “”,
“dtype” : “Temp”,
“id” : “33280”,
“idx” : 128,
“meterType” : “Energy”,
“name” : “Outdoor - Garage”,
“nvalue” : 0,
“stype” : “Viking 02811/02813, Proove TSS330”,
“svalue1” : “15.3”,
“unit” : 0
}

{
“Battery” : 255,
“RSSI” : 12,
“description” : “stripped out”,
“dtype” : “General”,
“id” : “00082125”,
“idx” : 125,
“meterType” : “Energy”,
“name” : “Ultrasonic”,
“nvalue” : 0,
“stype” : “Distance”,
“svalue1” : “88”,
“unit” : 1
}

{
“Battery” : 255,
“RSSI” : 12,
“description” : “”,
“dtype” : “Lighting 2”,
“id” : “0BB44DA”,
“idx” : 66,
“name” : “Switch #1”,
“nvalue” : 1,
“stype” : “AC”,
“svalue1” : “0”,
“switchType” : “On/Off”,
“unit” : 1
}

Is there any good tutorial post (I did seach) describing how to convert/populate the mosquitto_sub output into items syntax configuration? I know that domoticz/out (handler?) should be involved.

Anyone that can help me with getting the temperarure sensors, the switches and the utility meter running is a hero! :slight_smile:

Hello,
I’m unclear about what all of this has to do with Domoticz.

If the above are three JSON formatted messages you are seeing on your MQTT broker, they can be easily read and used by openHAB. You need to install the MQTT binding and JSONPATH transformation first, then define items per value of the JSON you are interested in.

An example that should show all of that can be found at https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB#integration
Pay special attention to the mosquitto_sub example and the item example “Wifi Signal Strength in Percent”

Furthermore:

Thanks for your feedback.

I have problems filtering out the correct value based on name.

The example at http://jsonpath.com/ is the similiar in structure as Domoticz JSON.

Can anyone guide for the JSON Syntax on http://jsonpath.com/ to filter out “number” where type is “iPhone”. I can’t get that to work with example expressions.

/Daniel

Anyone can assist with my JSON output above?
An example how to use “name” to extract the specific value would be appreciated. I tried with some JSONPATH regex example but couldn’t get it to work…

Thanks in advance
Daniel

Did you follow along the links I’ve posted above? They should be pretty easy to comprehend. Besides that you didn’t post all the details needed to help you. There are for example no topics given for the JSON output you’ve provided. I’m also not sure what your question has to do with “iPhone”. Answers in the forum can only be as good as the provided details and you can’t expect answers without a clear question.

Let’s assume your MQTT broker is called “broker” in your configuration. Let’s further assume your OUTPUT was published to three different MQTT topics of the form mydevices/device1/status (same for device2 and device3). Last but not least let’s assume the data you want to extract is the field “RSSI” of the first device (the one with the name “Outdoor-Garage”). You’d define an openHAB like so:

Number Garage_Energy_Device "Garage Energy Device RSSI [%d]" { mqtt="<[broker:mydevices/device1/status:state:JSONPATH($.RSSI)]" }

Looking at the example output from your first post, the item would be populated with the value “5”.

Please study the links I’ve posted above to learn more.

Hi,

I am more or less in the same situation, being in transition between Domoticz and OpenHab, Domoticz will probably continue to work for some times but things will move to OpenHab step by step.

Domoticz allow to push every sensors data on a specific topic (domoticz/out), so these devices does not rely on specific topic structure. It’s possible to have a floor/map topic structure, but having multiple devices on each floor that does not help much.

For exemple in my case, some of these message looks like this:

{
“Battery” : 255,
“RSSI” : 12,
“description” : “”,
“dtype” : “Current”,
“id” : “10”,
“idx” : 195,
“meterType” : “Energy”,
“name” : “Teleinfo Courant”,
“nvalue” : 0,
“stype” : “CM113, Electrisave”,
“svalue1” : “12.0”,
“svalue2” : “0.0”,
“svalue3” : “0.0”,
“unit” : 0
}

{
“Battery” : 255,
“RSSI” : 12,
“description” : “”,
“dtype” : “General”,
“id” : “00000001”,
“idx” : 196,
“meterType” : “Energy”,
“name” : “Teleinfo Pourcentage de Charge”,
“nvalue” : 0,
“stype” : “Percentage”,
“svalue1” : “26.67”,
“unit” : 1
}

The way Domoticz works, the “idx” data is unique for each devices. So I try to use a regex in my thing definition, like this:

Number EnergyHousePercent "Teleinfo Pourcentage de Charge [%.1f %%]" {mqtt="<[nasmqtt:domoticz/out:state:JSONPATH($.svalue1):REGEX(.*\"idx\".*196,$)]"}
Number EnergyHouseCurrent "Teleinfo Courant [%d A]" {mqtt="<[nasmqtt:domoticz/out:state:JSONPATH($.svalue1):REGEX(.*\"idx\".*195,$)]"}

The way I understand it, the message is parsed by the Regex, and if it matched, it’s parsed by the JSONPATH transformation.

I tried several syntax, the character ‘:’ seems not escapable, but having idx and 196 on the same line should be enough to tell this is the message for this specific item, however I do not get yet the data in the item … But it seems so close !

I think I get why it does not work, it looks like it’s the result of the REGEX that is provided to the JSONPATH, and that only one line is matched and provided by the REGEX.

But how to get a multi line result ?

Since my issue is a bit different from the initial one, I created a new message instead, sorry to have hijacked this thread.

1 Like