Virtual sensor in Domoticz for BME680

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Virtual sensor in Domoticz for BME680

#1 Post by mackowiakp » 02 May 2021, 06:50

I have a BME680 connected to the ESP. The BME680 gives 4 parameters. In order: temperature, humidity, pressure and air quality index.
I would like to have a virtual sensor in Domoticz that shows only information about temperature and humidity, based on data from the BME860.
For this purpose, I have created a virtual temperature and humidity senator idx=143 and I enter the ESP data into it with the command:

Code: Select all

SendToHTTP 192.168.0.25,8080,/json.htm?type=command&param=udevice&idx=143&nvalue=0&svalue=[BME680#Temperature];[BME680#Humidity]
In the device list, this sensor "created" as

Code: Select all

THGN122/123/132,
THGR122/228/238/268
In the same list you can see that the above command sends data from BME but as received data something like this is shown:

Code: Select all

0,
12.15 C, 72.16%
Just like that. With '0' in first line and the rest of the measurements in the second.
The debug in ESP shows that measurements are passed correctly, without any leading "0" or so.
However, the sensor indications on the list in the dashboard are empty. Not zero, but just no values are displayed.
How can I correctly display the temperature and humidity data, as is the case with sensors such as DTH22?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Virtual sensor in Domoticz for BME680

#2 Post by TD-er » 02 May 2021, 15:21

Domoticz is very strict on the order of parameters along with the sensor type.
For example there are sensor types like TEMP_HUM, TEMP_HUM_BARO, TEMP_BARO.
So you have to check what exact sensor type you assigned to the dummy sensor you added in Domoticz and make sure you send the values exactly in that order and it also matters if a sensor type expects a value as "nvalue" or "svalue".
For example, I know ESPEasy does send the values in the wrong field for when you define a type "CO2 sensor", so for this reason you need to use a "custom" sensor for CO2 in Domoticz.

See here for specific info on how values should be formatted per sensor type in Domoticz: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Virtual sensor in Domoticz for BME680

#3 Post by mackowiakp » 02 May 2021, 16:05

OK. So in my case should be:

Code: Select all

/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=TEMP;HUM;HUM_STAT
where HUM_STAT should be 0=Normal 1=Comfortable 2=Dry 3=Wet

Have You ready routine how to count HUM_STAT from TEMP and HUM?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Virtual sensor in Domoticz for BME680

#4 Post by TD-er » 02 May 2021, 17:41

https://github.com/letscontrolit/ESPEas ... pp#L19-L37

It is not present as a single command to be used in the rules.

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

[SOLVED]Re: Virtual sensor in Domoticz for BME680

#5 Post by mackowiakp » 02 May 2021, 20:54

THX - Solved !

Paysan9136
New user
Posts: 4
Joined: 11 Oct 2021, 09:53

Re: Virtual sensor in Domoticz for BME680

#6 Post by Paysan9136 » 11 Oct 2021, 09:59

Hi mac, I did not know you can send this JSON String from an ESP.
I normally do this by using Python on a PI.
Do you have some more info around this statement please?

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Virtual sensor in Domoticz for BME680

#7 Post by mackowiakp » 11 Oct 2021, 10:53

For example sending AQI readout to virtual Domoticz sensor from physical BME680 connected to ESP

Code: Select all

SendToHTTP 192.168.0.25,8080,/json.htm?type=command&param=udevice&idx=142&nvalue=0&svalue=[BME680#AQI]
 else
192.168.0.25 - IP of Domoticz server
8080 - Domoticz port
142 - id of virtual sensor in Domoticz
BME680#AQI - name/parameter defined in ESP task config

This is ordinary HTTP call the only possible in ESP.

Paysan9136
New user
Posts: 4
Joined: 11 Oct 2021, 09:53

Re: Virtual sensor in Domoticz for BME680

#8 Post by Paysan9136 » 12 Oct 2021, 10:47

Mackowiakp, one more question.
Where is this format documented [BME680#Temperature];[BME680#Humidity]?

I know about this kind of statement but in Python I use it like this:

commando = 'curl -s \"http://192.168.2.235:8080/json.htm?type ... param=udev
ice&idx=1&nvalue=0&svalue=TEMP;HUM;HUM_STAT\"'
commando = commando.replace("TEMP",t)
commando = commando.replace("HUM_STAT",hum_stat)
commando = commando.replace("HUM",h)
print (commando)
os.system(commando)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Virtual sensor in Domoticz for BME680

#9 Post by mackowiakp » 12 Oct 2021, 13:59

Where is this format documented [BME680#Temperature];[BME680#Humidity]?
I think - nowhere. Domoticz has no 4 parameters virtual sensor, suitable for BME680. At least in the version I'm using.
So I SendToHTTP first temp, humidity and calculated value of environment condition in rule and separately pressure and AQI
.

Below part of rule code:

Code: Select all

..........
 SendToHTTP 192.168.0.25,8080,/json.htm?type=command&param=udevice&idx=117&nvalue=0&svalue=[BME680#Pressure]
 .........
 if [BME680#Humidity] < 59
  Let,1,1
 Endif
 if [BME680#Humidity] < 40
  Let,1,0
 Endif
 if [BME680#Humidity] < 30
  Let,1,2
 Endif
 SendToHTTP 192.168.0.25,8080,/json.htm?type=command&param=udevice&idx=59&nvalue=0&svalue=[BME680#Temperature];[BME680#Humidity];[INT#1]
EndIf
EndOn

Paysan9136
New user
Posts: 4
Joined: 11 Oct 2021, 09:53

Re: Virtual sensor in Domoticz for BME680

#10 Post by Paysan9136 » 12 Oct 2021, 14:04

I don't understand what is [BME650#Temperature]

Can you send me the complete source please?

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Virtual sensor in Domoticz for BME680

#11 Post by mackowiakp » 12 Oct 2021, 14:35

The name of parameters as define in task of device BME680. See screenshots:
Screenshot_20211012_142142.jpg
Screenshot_20211012_142142.jpg (182.63 KiB) Viewed 8518 times
Screenshot_20211012_142225.jpg
Screenshot_20211012_142225.jpg (90.08 KiB) Viewed 8518 times
Screenshot_20211012_142233.jpg
Screenshot_20211012_142233.jpg (92.58 KiB) Viewed 8518 times

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Virtual sensor in Domoticz for BME680

#12 Post by Ath » 12 Oct 2021, 14:39

mackowiakp wrote: 12 Oct 2021, 13:59
Where is this format documented [BME680#Temperature];[BME680#Humidity]?
I think - nowhere. Domoticz has no 4 parameters virtual sensor, suitable for BME680. At least in the version I'm using.
So I SendToHTTP first temp, humidity and calculated value of environment condition in rule and separately pressure and AQI
Well, actually that format is documented, for the Rules, over here and it also works in other places where you can enter related text, like in the Formula field
/Ton (PayPal.me)

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Virtual sensor in Domoticz for BME680

#13 Post by mackowiakp » 12 Oct 2021, 17:11

Well, actually that format is documented
Yep. I haven't looked into the documentation for a long time, so I don't know what was added.
Anyway, "Use RTFM Technology First" ! (Read The Fu..en Manual) :D :D :D

Paysan9136
New user
Posts: 4
Joined: 11 Oct 2021, 09:53

Re: Virtual sensor in Domoticz for BME680

#14 Post by Paysan9136 » 13 Oct 2021, 09:00

Mac, this is not my question.

I just want to know what this format is documented

BME680#Temperature

Why not just this Temperature

Like I do in my Python version.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Virtual sensor in Domoticz for BME680

#15 Post by TD-er » 13 Oct 2021, 09:08

You can have multiple instances of the same task.
For example when using the Dallas plugin, one often has multiple Dallas 1Wire sensors.
To distinguish among various tasks, one has to make an unique combination of taskname#taskvaluename
In the rules every occurence matching [taskname#taskvaluename] will be replaced with the current value of that taskvalue.
So if your task is called "bme680" and it has a value named "Temperature", you can refer to this value via [BME680#Temperature] (don't forget the square brackets)

N.B. since the events are not always handled immediately, and the [taskname#taskvaluename] replacement is done at the time the event is handled, you may want to use the %eventvalue1% notation to refer to the value it had when the event was generated.

abyrocks4sure
New user
Posts: 6
Joined: 19 Jun 2023, 19:13

Re: Virtual sensor in Domoticz for BME680

#16 Post by abyrocks4sure » 20 Jun 2023, 06:22

mackowiakp wrote: 11 Oct 2021, 10:53 For example sending AQI readout to virtual Domoticz sensor from physical BME680 connected to ESP

Code: Select all

SendToHTTP 192.168.0.25,8080,/json.htm?type=command&param=udevice&idx=142&nvalue=0&svalue=[BME680#AQI]
 else
192.168.0.25 - IP of Domoticz server
8080 - Domoticz port
142 - id of virtual sensor in Domoticz
BME680#AQI - name/parameter defined in ESP task config

This is ordinary HTTP call the only possible in ESP.
Can you provide the full code please, I am having problem sending the pressure values to domoticz using the following code:

Code: Select all

on BME680#AQI do
    SendToHTTP 192.168.0.115,8080,/json.htm?username=YWRtaW4=&password=ZG9tb3RpY3o=&type=command&param=udevice&idx=2&nvalue=0&svalue=[BME680#AQI]
endon

mackowiakp
Normal user
Posts: 527
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: Virtual sensor in Domoticz for BME680

#17 Post by mackowiakp » 20 Jun 2023, 07:26

I'd love to help, but I've already removed that code. The reason is that the next two BME680s only lasted a little over half a year each. Then it started showing some random readings. And this for each of the 4 measured values.
I don't know if BME680 has such a low durability or if it's the "legendary quality of Ali".
At the moment I use a set of three separate I2C sensors:
- SBGP30 (AQI)
- HTU21D (hum/temp)
- BMP180 (pressure and temperature backup)
And because I use them outdoors, they were placed in the so-called "Stevenson Weather Cage" (see photo). It is a 3D printout.
Next to it is another I2C sensor - BH1750 (Lux). It works on the same I2C bus as previously mentioned.
But your syntax looks correct.
The reason may be that Domoticz (especially in older versions) sometimes has problems with user/pass in the URL. I do not use SendToHTTP user/pass. I increase security by defining IP addresses in Domoticz that can communicate with it and filtering MAC addresses in the RPi itself using iptables.
IMG20230620071725.jpg
IMG20230620071725.jpg (2.33 MiB) Viewed 1969 times

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests