Skip to content

Commit 4c80dfd

Browse files
committed
ZWave, rain-rate as custom sensor
1 parent 6132251 commit 4c80dfd

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

hardware/OpenZWave.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ enum _eSensorScaleID
5656
SCALEID_CO2,
5757
SCALEID_WATER,
5858
SCALEID_MOISTRUE,
59-
SCALEID_TANK_CAPACITY
59+
SCALEID_TANK_CAPACITY,
60+
SCALEID_RAIN_RATE,
6061
};
6162

6263
struct _tAlarmNameToIndexMapping
@@ -2093,8 +2094,18 @@ void COpenZWave::AddValue(const OpenZWave::ValueID &vID, const NodeInfo *pNodeIn
20932094
}
20942095
else if (vLabel == "Rain Rate")
20952096
{
2096-
//Ignore
2097-
return;
2097+
if (vType == OpenZWave::ValueID::ValueType_Decimal)
2098+
{
2099+
if (m_pManager->GetValueAsFloat(vID, &fValue) == true)
2100+
{
2101+
_device.floatValue = fValue;
2102+
_device.scaleID = SCALEID_RAIN_RATE;
2103+
_device.scaleMultiply = 1;
2104+
_device.devType = ZDTYPE_SENSOR_CUSTOM;
2105+
_device.custom_label = "mm/h";
2106+
InsertDevice(_device);
2107+
}
2108+
}
20982109
}
20992110
else
21002111
{
@@ -2578,6 +2589,8 @@ void COpenZWave::UpdateValue(const OpenZWave::ValueID &vID)
25782589
scaleID = SCALEID_MOISTRUE;
25792590
else if (vLabel == "Tank Capacity")
25802591
scaleID = SCALEID_TANK_CAPACITY;
2592+
else if (vLabel == "Rain Rate")
2593+
scaleID = SCALEID_RAIN_RATE;
25812594

25822595
sstr << "." << scaleID;
25832596
}
@@ -3152,6 +3165,14 @@ void COpenZWave::UpdateValue(const OpenZWave::ValueID &vID)
31523165
pDevice->floatValue = fValue; //always set the value
31533166
}
31543167
break;
3168+
case ZDTYPE_SENSOR_CUSTOM:
3169+
{
3170+
if (vType != OpenZWave::ValueID::ValueType_Decimal)
3171+
return;
3172+
float oldvalue = pDevice->floatValue;
3173+
pDevice->floatValue = fValue;
3174+
}
3175+
break;
31553176
case ZDTYPE_SENSOR_MOISTURE:
31563177
{
31573178
if (vType != OpenZWave::ValueID::ValueType_Decimal)

hardware/ZWaveBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,10 @@ void ZWaveBase::SendDevice2Domoticz(const _tZWaveDevice *pDevice)
766766
sprintf(szTmp, "Alarm Type: %s %d(0x%02X)", pDevice->label.c_str(), pDevice->Alarm_Type, pDevice->Alarm_Type);
767767
sDecodeRXMessage(this, (const unsigned char *)&gDevice, szTmp, BatLevel);
768768
}
769+
else if (pDevice->devType == ZDTYPE_SENSOR_CUSTOM)
770+
{
771+
SendCustomSensor(ID3, ID4, BatLevel, pDevice->floatValue, pDevice->label, pDevice->custom_label);
772+
}
769773
}
770774

771775
ZWaveBase::_tZWaveDevice* ZWaveBase::FindDevice(const int nodeID, const int instanceID, const int indexID)

hardware/ZWaveBase.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class ZWaveBase : public CDomoticzHardwareBase
4444

4545
ZDTYPE_ALARM,
4646
ZDTYPE_CENTRAL_SCENE,
47+
48+
ZDTYPE_SENSOR_CUSTOM,
49+
4750
};
4851
struct _tZWaveDevice
4952
{
@@ -83,6 +86,7 @@ class ZWaveBase : public CDomoticzHardwareBase
8386

8487
//label
8588
std::string label;
89+
std::string custom_label;
8690

8791
time_t lastreceived;
8892
unsigned char sequence_number;

0 commit comments

Comments
 (0)