Virtual sensor in Domoticz for BME680

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 341
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: 5514
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: 341
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: 5514
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: 341
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
Normal 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: 341
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
Normal 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: 341
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
Normal 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: 341
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 380 times
Screenshot_20211012_142225.jpg
Screenshot_20211012_142225.jpg (90.08 KiB) Viewed 380 times
Screenshot_20211012_142233.jpg
Screenshot_20211012_142233.jpg (92.58 KiB) Viewed 380 times

User avatar
Ath
Normal user
Posts: 1155
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

mackowiakp
Normal user
Posts: 341
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
Normal 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: 5514
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.

Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests