Page 1 of 2

Multiple similar sensors to one MySensors node

Posted: Friday 11 December 2015 12:12
by mvdbro
I'm experimenting with an ESP module using the MySensors library (1.6.0 beta). I have these devices attached to the ESP module:

Dallas DS18B20
BMP085
BH1750
DHT11
SI7021
Input Switch

In Domoticz i get this child list for this MySensors gateway node:
Childs.png
Childs.png (9.04 KiB) Viewed 13421 times
So this seems to work fine, but Domoticz seems to try to make combined devices from these child id's:

262 Lux sensor with id 0000 and unit 0
263 TempHumBaro with id 0000 and unit 8
264 TempHumBaro with id 0005 and unit 5
266 TempHumBaro with id 0011 and unit 17
267 TempHumBaro with id 000D and unit 13

And it looks like humidity values are mixed up. I can image that Domoticz has no way to tell how these child id's should be combined, because I think that the MySensors protocol has no support for this?

Or can I configure somehow which child id's belong to a certain device in Domoticz?

Re: Multiple similar sensors to one MySensors node

Posted: Saturday 12 December 2015 9:30
by Timdgr
But why would you connect more than one sensor that reads the same thing?

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 13 December 2015 3:00
by andriej01
Timdgr wrote:But why would you connect more than one sensor that reads the same thing?
Why would you like to read multiple temperature... Et cetera...

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 13 December 2015 8:43
by NietGiftig
Timdgr wrote:But why would you connect more than one sensor that reads the same thing?
Possible answer is in the original post
I'm experimenting with an ESP module using the MySensors library
The word experimenting gives the clue

Sometimes a part is giving 2 outputs, a DHT11 part is giving Temp and Humidity , a BMP05 baro is giving Hpa and Temp
So 2 times a temp on the same ESP

Sometimes you have 1 ESP and a temp-sensor outside and 1 temp-sensor inside

Re: Multiple similar sensors to one MySensors node

Posted: Friday 18 December 2015 15:54
by Timdgr
NietGiftig wrote:The word experimenting gives the clue
Sometimes you have 1 ESP and a temp-sensor outside and 1 temp-sensor inside
Ok I understand now why this could be useful. Is there any news on this? Is it a real issue and how to get around this?

I think that no one has done before with the Arduino/NRF versions of MySensors otherwise it would have been reported earlier. Maybe the only way to support inside and outside temp reading is by using two nodes.

Re: Multiple similar sensors to one MySensors node

Posted: Monday 21 December 2015 1:02
by Derik
thats what i like...
One arduino or my esp with multiple sensors...
Only i wil have more pushbuttons, for my pelletstove.

Please do you have a simple how to..[ or some thing ]
I got the stuff, only i do not get it to work.

The tutorials i can find, are for one gateway/sensor..

How do you make this..

Or when you have time..
A wiki.... ;)

Re: Multiple similar sensors to one MySensors node

Posted: Tuesday 29 December 2015 9:07
by Sevift
same problem. MySensors library 1.5.1 NRF24L01
incorrect values humidity sensors DHT22, when several devices

Re: Multiple similar sensors to one MySensors node

Posted: Tuesday 29 December 2015 9:19
by NietGiftig
Derik wrote:thats what i like...
The tutorials i can find, are for one gateway/sensor..

How do you make this..
I'm using Espeasy
http://www.esp8266.nu/index.php/Main_Page#Firmware

Works good with Domoticz
I think it's from the topic starter ;)

Re: Multiple similar sensors to one MySensors node

Posted: Tuesday 29 December 2015 11:33
by mvdbro
Sevift wrote:same problem. MySensors library 1.5.1 NRF24L01
incorrect values humidity sensors DHT22, when several devices
So it seems that I'm not the only one facing this issue.

So either:

1) We both don't know how to build this properly :mrgreen:
2) The MySensors gateway support in Domoticz does not support what we're trying to accomplish :(

Would be nice to learn which of them is true. I've launched a new ESP project that would be rather useless if this is not supported. So development is on hold as long as this remains unclear.

Re: Multiple similar sensors to one MySensors node

Posted: Wednesday 30 December 2015 11:19
by dakipro
I would just like to vote for this feature as I plan to make one refrigerator node that would have two separate dht22 sensors (one for fridge and one for freezer).
I am waiting for parts to arrive, it would be a bummer if we are limited to one sensor per node

Re: Multiple similar sensors to one MySensors node

Posted: Wednesday 30 December 2015 15:30
by Sevift
mvdbro wrote:
Sevift wrote:same problem. MySensors library 1.5.1 NRF24L01
incorrect values humidity sensors DHT22, when several devices
So it seems that I'm not the only one facing this issue.

So either:

1) We both don't know how to build this properly :mrgreen:
2) The MySensors gateway support in Domoticz does not support what we're trying to accomplish :oops:

Would be nice to learn which of them is true. I've launched a new ESP project that would be rather useless if this is not supported. So development is on hold as long as this remains unclear.
In MYSController displaying the correct values.

Re: Multiple similar sensors to one MySensors node

Posted: Wednesday 30 December 2015 23:03
by andriej
It's Domoticz that is mixing the values from different sensors on one node.
I was reporting this bug earlier.

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 03 January 2016 14:24
by Sevift
Maybe write it in the topic of bugs? This is a serious error. 3 sensors lie idle. They confuse the sensor reading in the bathroom.

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 17 January 2016 14:44
by Sevift
In MySensorsBase.cpp
void MySensorsBase::SendSensor2Domoticz(_tMySensorNode *pNode, _tMySensorChild *pChild, const _eSetType vType)
Errors in the code for multi devices.
If you make a single device (Replace on this code)

Code: Select all

case V_TEMP:
	{
		float Temp = 0;
		_tMySensorChild *pChildTemp = FindChildWithValueType(pChild->nodeID, V_TEMP);	

		if (pChildTemp) {
			bool bHaveTemp = pChild->GetValue(V_TEMP, Temp);
			if (bHaveTemp) {
				SendTempSensor(cNode, pChild->batValue, Temp, (!pChild->childName.empty()) ? pChild->childName : "Temp");
			}
		} 
	}
	break;
	case V_HUM:
	{
		int Humidity = 0;
		_tMySensorChild *pChildHum = FindChildWithValueType(pChild->nodeID, V_HUM);

		if (pChildHum) { 
			bool bHaveHum = pChild->GetValue(V_HUM, Humidity);
			if (bHaveHum){
				SendHumiditySensor(cNode, pChild->batValue, Humidity, (!pChild->childName.empty()) ? pChild->childName : "Hum");
			}
		} 
	}
	break;
then working

in DomoticzHardware.cpp

Code: Select all

void CDomoticzHardwareBase::SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity)
replaced by

Code: Select all

void CDomoticzHardwareBase::SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity, const std::string &defaultname)
in the same function

Code: Select all

sDecodeRXMessage(this, (const unsigned char *)&tsen.HUM, NULL, BatteryLevel);
replaced by

Code: Select all

sDecodeRXMessage(this, (const unsigned char *)&tsen.HUM, defaultname.c_str(), BatteryLevel);
in DomoticzHardware.h

Code: Select all

void SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity);
replaced by

Code: Select all

void SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity, const std::string &defaultname);
in RFLinkBase.cpp

Code: Select all

SendHumiditySensor(ID, BatteryLevel, humidity);
replaced by

Code: Select all

std::string tmp_Name = results[2]; 
SendHumiditySensor(ID, BatteryLevel, humidity, tmp_Name);
Снимок экрана 2016-01-17 в 13.42.16.png
Снимок экрана 2016-01-17 в 13.42.16.png (154.77 KiB) Viewed 12882 times
Снимок экрана 2016-01-17 в 13.41.39.png
Снимок экрана 2016-01-17 в 13.41.39.png (168.11 KiB) Viewed 12882 times

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 17 January 2016 14:58
by gizmocuz
@Sevift,
you want a default name for the humidity sensor ?
I will add support for this in the next commit, done, and also for all other sensors
It is better to create a git pull request next time, because we can not read all forum posts

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 17 January 2016 16:45
by Sevift
gizmocuz wrote:@Sevift,
you want a default name for the humidity sensor ?
I will add support for this in the next commit, done, and also for all other sensors
It is better to create a git pull request next time, because we can not read all forum posts
This is secondary.
It is important that humidity sensors begin to transmit the correct values. You have the code, written for multisensor - wrong. Confused values of humidity sensors, if there are several
I did that several sensors are not joined together into one.

p.s.
TempHumSensor - > TempSensor and HumSensor

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 17 January 2016 17:56
by gizmocuz
Thats not how domoticz work, we want to combine all when possible
there is a github issue already, and we working on this (will take some time)

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 17 January 2016 18:46
by Sevift
Thank you for your work.
Will wait. But now DHT22 sensors are useless if they are more than one. And with my patch work correctly, and as a temporary solution is suitable for those who are important.
Spoiler: show

Code: Select all

case V_TEMP:
   {
      float Temp = 0;
      _tMySensorChild *pChildTemp = FindChildWithValueType(pChild->nodeID, V_TEMP);   

      if (pChildTemp) {
         bool bHaveTemp = pChild->GetValue(V_TEMP, Temp);
         if (bHaveTemp) {
            SendTempSensor(cNode, pChild->batValue, Temp, (!pChild->childName.empty()) ? pChild->childName : "Temp");
         }
      } 
   }
   break;
   case V_HUM:
   {
      int Humidity = 0;
      _tMySensorChild *pChildHum = FindChildWithValueType(pChild->nodeID, V_HUM);

      if (pChildHum) { 
         bool bHaveHum = pChild->GetValue(V_HUM, Humidity);
         if (bHaveHum){
            SendHumiditySensor(cNode, pChild->batValue, Humidity, (!pChild->childName.empty()) ? pChild->childName : "Hum");
         }
      } 
   }
   break;

Re: Multiple similar sensors to one MySensors node

Posted: Sunday 17 January 2016 18:48
by gizmocuz
this is no patch !? (no offence taken!)
It is just sending individually the sensor data

if possible have a look at the github issue page, and make a correct patch

Re: Multiple similar sensors to one MySensors node

Posted: Monday 07 March 2016 18:45
by miljume
Sevift wrote:In MySensorsBase.cpp
void MySensorsBase::SendSensor2Domoticz(_tMySensorNode *pNode, _tMySensorChild *pChild, const _eSetType vType)
Errors in the code for multi devices.
If you make a single device (Replace on this code)

Code: Select all

case V_TEMP:
	{
		float Temp = 0;
		_tMySensorChild *pChildTemp = FindChildWithValueType(pChild->nodeID, V_TEMP);	

		if (pChildTemp) {
			bool bHaveTemp = pChild->GetValue(V_TEMP, Temp);
			if (bHaveTemp) {
				SendTempSensor(cNode, pChild->batValue, Temp, (!pChild->childName.empty()) ? pChild->childName : "Temp");
			}
		} 
	}
	break;
	case V_HUM:
	{
		int Humidity = 0;
		_tMySensorChild *pChildHum = FindChildWithValueType(pChild->nodeID, V_HUM);

		if (pChildHum) { 
			bool bHaveHum = pChild->GetValue(V_HUM, Humidity);
			if (bHaveHum){
				SendHumiditySensor(cNode, pChild->batValue, Humidity, (!pChild->childName.empty()) ? pChild->childName : "Hum");
			}
		} 
	}
	break;
then working

in DomoticzHardware.cpp

Code: Select all

void CDomoticzHardwareBase::SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity)
replaced by

Code: Select all

void CDomoticzHardwareBase::SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity, const std::string &defaultname)
in the same function

Code: Select all

sDecodeRXMessage(this, (const unsigned char *)&tsen.HUM, NULL, BatteryLevel);
replaced by

Code: Select all

sDecodeRXMessage(this, (const unsigned char *)&tsen.HUM, defaultname.c_str(), BatteryLevel);
in DomoticzHardware.h

Code: Select all

void SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity);
replaced by

Code: Select all

void SendHumiditySensor(const int NodeID, const int BatteryLevel, const int humidity, const std::string &defaultname);
in RFLinkBase.cpp

Code: Select all

SendHumiditySensor(ID, BatteryLevel, humidity);
replaced by

Code: Select all

std::string tmp_Name = results[2]; 
SendHumiditySensor(ID, BatteryLevel, humidity, tmp_Name);
Снимок экрана 2016-01-17 в 13.42.16.png
Снимок экрана 2016-01-17 в 13.41.39.png
@Sevift: When looking in MySensorsBase.cpp there is more code than you listed in your code (forecasting etc)
Have you deleted these lines or just left them out?
See actual code in MysensorsBase.cpp below

Code: Select all

case V_TEMP:
	{
		float Temp = 0;
		pChild->GetValue(V_TEMP, Temp);
		_tMySensorChild *pChildHum = FindChildWithValueType(pChild->nodeID, V_HUM);
		_tMySensorChild *pChildBaro = FindChildWithValueType(pChild->nodeID, V_PRESSURE);
		if (pChildHum && pChildBaro)
		{
			int Humidity;
			float Baro;
			bool bHaveHumidity = pChildHum->GetValue(V_HUM, Humidity);
			bool bHaveBaro = pChildBaro->GetValue(V_PRESSURE, Baro);
			if (bHaveHumidity && bHaveBaro)
			{
				int forecast = bmpbaroforecast_unknown;
				_tMySensorChild *pSensorForecast = FindChildWithValueType(pChild->nodeID, V_FORECAST);
				if (pSensorForecast)
				{
					pSensorForecast->GetValue(V_FORECAST, forecast);
				}
				if (forecast == bmpbaroforecast_cloudy)
				{
					if (Baro < 1010)
						forecast = bmpbaroforecast_rain;
				}

				//We are using the TempHumBaro Float type now, convert the forecast
				int nforecast = wsbaroforcast_some_clouds;
				if (Baro <= 980)
					nforecast = wsbaroforcast_heavy_rain;
				else if (Baro <= 995)
				{
					if (Temp > 1)
						nforecast = wsbaroforcast_rain;
					else
						nforecast = wsbaroforcast_snow;
				}
				else if (Baro >= 1029)
					nforecast = wsbaroforcast_sunny;
				switch (forecast)
				{
				case bmpbaroforecast_sunny:
					nforecast = wsbaroforcast_sunny;
					break;
				case bmpbaroforecast_cloudy:
					nforecast = wsbaroforcast_cloudy;
					break;
				case bmpbaroforecast_thunderstorm:
					nforecast = wsbaroforcast_heavy_rain;
					break;
				case bmpbaroforecast_rain:
					if (Temp>1)
						nforecast = wsbaroforcast_rain;
					else
						nforecast = wsbaroforcast_snow;
					break;
				}
				SendTempHumBaroSensorFloat(cNode, pChild->batValue, Temp, Humidity, Baro, nforecast, (!pChild->childName.empty()) ? pChild->childName : "TempHumBaro");
			}
		}
		else if (pChildHum) {
			int Humidity;
			bool bHaveHumidity = pChildHum->GetValue(V_HUM, Humidity);
			if (bHaveHumidity)
			{
				SendTempHumSensor(cNode, pChild->batValue, Temp, Humidity, (!pChild->childName.empty()) ? pChild->childName : "TempHum");
			}
		}
		else
		{
			SendTempSensor(cNode, pChild->batValue, Temp, (!pChild->childName.empty()) ? pChild->childName : "Temp");
		}
	}
	break;
	case V_HUM:
	{
		_tMySensorChild *pChildTemp = FindChildWithValueType(pChild->nodeID, V_TEMP);
		_tMySensorChild *pChildBaro = FindChildWithValueType(pChild->nodeID, V_PRESSURE);
		int forecast = bmpbaroforecast_unknown;
		_tMySensorChild *pSensorForecast = FindChildWithValueType(pChild->nodeID, V_FORECAST);
		if (pSensorForecast)
		{
			pSensorForecast->GetValue(V_FORECAST, forecast);
		}
		if (forecast == bmpbaroforecast_cloudy)
		{
			if (pChildBaro)
			{
				float Baro;
				if (pChildBaro->GetValue(V_PRESSURE, Baro))
				{
					if (Baro < 1010)
						forecast = bmpbaroforecast_rain;
				}
			}
		}
		float Temp;
		int Humidity;
		pChild->GetValue(V_HUM, Humidity);
		if (pChildTemp && pChildBaro)
		{
			float Baro;
			bool bHaveTemp = pChildTemp->GetValue(V_TEMP, Temp);
			bool bHaveBaro = pChildBaro->GetValue(V_PRESSURE, Baro);
			if (bHaveTemp && bHaveBaro)
			{
				cNode = (pChildTemp->nodeID << 8) | pChildTemp->childID;

				//We are using the TempHumBaro Float type now, convert the forecast
				int nforecast = wsbaroforcast_some_clouds;
				if (Baro <= 980)
					nforecast = wsbaroforcast_heavy_rain;
				else if (Baro <= 995)
				{
					if (Temp > 1)
						nforecast = wsbaroforcast_rain;
					else
						nforecast = wsbaroforcast_snow;
				}
				else if (Baro >= 1029)
					nforecast = wsbaroforcast_sunny;
				switch (forecast)
				{
				case bmpbaroforecast_sunny:
					nforecast = wsbaroforcast_sunny;
					break;
				case bmpbaroforecast_cloudy:
					nforecast = wsbaroforcast_cloudy;
					break;
				case bmpbaroforecast_thunderstorm:
					nforecast = wsbaroforcast_heavy_rain;
					break;
				case bmpbaroforecast_rain:
					if (Temp > 1)
						nforecast = wsbaroforcast_rain;
					else
						nforecast = wsbaroforcast_snow;
					break;
				}

				SendTempHumBaroSensorFloat(cNode, pChildTemp->batValue, Temp, Humidity, Baro, nforecast, (!pChild->childName.empty()) ? pChild->childName : "TempHumBaro");
			}
		}
		else if (pChildTemp) {
			bool bHaveTemp = pChildTemp->GetValue(V_TEMP, Temp);
			if (bHaveTemp)
			{
				cNode = (pChildTemp->nodeID << 8) | pChildTemp->childID;
				SendTempHumSensor(cNode, pChildTemp->batValue, Temp, Humidity, (!pChild->childName.empty()) ? pChild->childName : "TempHum");
			}
		}
		else
		{
			SendHumiditySensor(cNode, pChild->batValue, Humidity, (!pChild->childName.empty()) ? pChild->childName : "Hum");
		}
	}
	break;
I will try to adjust the source so that Temp and Hum values are reported separately