Skip to content

Commit

Permalink
Add further Danfoss specific resource items (#6175)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwoopX authored Dec 14, 2023
1 parent d0c8339 commit 4e4ab30
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 0 deletions.
118 changes: 118 additions & 0 deletions devices/danfoss/etrv0100_thermostat.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"0x0B05"
]
},
"meta": {
"values": {
"config/mode": {"off": 0, "heat": 1}
}
},
"items": [
{
"name": "attr/id"
Expand Down Expand Up @@ -166,10 +171,67 @@
"name": "config/heatsetpoint",
"refresh.interval": 3660
},
{
"name": "config/loadbalancing",
"refresh.interval": 3660,
"read": {
"at": "0x4032",
"cl": "0x0201",
"ep": 1,
"fn": "zcl:attr",
"mf": "0x1246"
},
"parse": {
"at": "0x4032",
"cl": "0x0201",
"ep": 1,
"eval": "Item.val = Attr.val;",
"fn": "zcl:attr",
"mf": "0x1246"
},
"write": {
"at": "0x4032",
"cl": "0x0201",
"dt": "0x10",
"ep": 1,
"eval": "Item.val",
"fn": "zcl:attr",
"mf": "0x1246"
}
},
{
"name": "config/locked",
"refresh.interval": 3660
},
{
"name": "config/mode",
"refresh.interval": 3660,
"read": {
"at": "0x4030",
"cl": "0x0201",
"ep": 1,
"fn": "zcl:attr",
"mf": "0x1246"
},
"parse": {
"at": "0x4030",
"cl": "0x0201",
"ep": 1,
"eval": "if (Attr.val == 0) { Item.val = 'off' } else if (Attr.val == 1) { Item.val = 'heat' };",
"fn": "zcl:attr",
"mf": "0x1246"
},
"write": {
"at": "0x4030",
"cl": "0x0201",
"dt": "0x10",
"ep": 1,
"eval": "if (Item.val == 'off') { 0 } else if (Item.val == 'heat') { 1 };",
"fn": "zcl:attr",
"mf": "0x1246"
},
"default": "heat"
},
{
"name": "config/mountingmode",
"refresh.interval": 3660,
Expand Down Expand Up @@ -232,6 +294,34 @@
{
"name": "config/on"
},
{
"name": "config/radiatorcovered",
"refresh.interval": 3660,
"read": {
"at": "0x4016",
"cl": "0x0201",
"ep": 1,
"fn": "zcl:attr",
"mf": "0x1246"
},
"parse": {
"at": "0x4016",
"cl": "0x0201",
"ep": 1,
"eval": "Item.val = Attr.val;",
"fn": "zcl:attr",
"mf": "0x1246"
},
"write": {
"at": "0x4016",
"cl": "0x0201",
"dt": "0x10",
"ep": 1,
"eval": "Item.val",
"fn": "zcl:attr",
"mf": "0x1246"
}
},
{
"name": "config/reachable"
},
Expand All @@ -242,6 +332,34 @@
"name": "config/schedule_on",
"refresh.interval": 3660
},
{
"name": "config/windowopendetectionenabled",
"refresh.interval": 3660,
"read": {
"at": "0x4051",
"cl": "0x0201",
"ep": 1,
"fn": "zcl:attr",
"mf": "0x1246"
},
"parse": {
"at": "0x4051",
"cl": "0x0201",
"ep": 1,
"eval": "Item.val = Attr.val;",
"fn": "zcl:attr",
"mf": "0x1246"
},
"write": {
"at": "0x4051",
"cl": "0x0201",
"dt": "0x10",
"ep": 1,
"eval": "Item.val",
"fn": "zcl:attr",
"mf": "0x1246"
}
},
{
"name": "state/errorcode",
"refresh.interval": 3660,
Expand Down
11 changes: 11 additions & 0 deletions devices/generic/items/config_lastchange_amount_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schema": "resourceitem1.schema.json",
"id": "config/lastchange_amount",
"datatype": "Int16",
"access": "R",
"public": true,
"description": "Specifies the delta between the current active setpoint and the previous active setpoint.",
"parse": {"at": "0x0031", "cl": "0x0201","ep": 0, "eval": "Item.val = Attr.val", "fn": "zcl:attr"},
"read": {"at": "0x0031", "cl": "0x0201", "ep": 0, "fn": "zcl:attr"},
"default": 0
}
11 changes: 11 additions & 0 deletions devices/generic/items/config_lastchange_source_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schema": "resourceitem1.schema.json",
"id": "config/lastchange_source",
"datatype": "UInt8",
"access": "R",
"public": true,
"description": "Determine whether changes to setpoints were initiated by manual interaction, scheduled programming or some other source.",
"parse": {"at": "0x0030", "cl": "0x0201","ep": 0, "eval": "Item.val = Attr.val", "fn": "zcl:attr"},
"read": {"at": "0x0030", "cl": "0x0201", "ep": 0, "fn": "zcl:attr"},
"default": 0
}
11 changes: 11 additions & 0 deletions devices/generic/items/config_lastchange_time_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"schema": "resourceitem1.schema.json",
"id": "config/lastchange_time",
"datatype": "ISO 8601 timestamp",
"access": "R",
"public": true,
"description": "Specifies the time in UTC at which the setpoint change was recorded.",
"parse": {"at": "0x0032", "cl": "0x0201","ep": 0, "eval": "Item.val = Attr.val", "fn": "zcl:attr"},
"read": {"at": "0x0032", "cl": "0x0201", "ep": 0, "fn": "zcl:attr"},
"default": 0
}
9 changes: 9 additions & 0 deletions devices/generic/items/config_loadbalancing_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"schema": "resourceitem1.schema.json",
"id": "config/loadbalancing",
"datatype": "Bool",
"access": "RW",
"public": true,
"description": "Thermostat runs stand alone (false) or shares load with others in the same room (true).",
"default": false
}
9 changes: 9 additions & 0 deletions devices/generic/items/config_radiatorcovered_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"schema": "resourceitem1.schema.json",
"id": "config/radiatorcovered",
"datatype": "Bool",
"access": "RW",
"public": true,
"description": "Radiator is standing freely (false) or is covered (true). Set this to true for Danfoss Ally to use external temp sensor.",
"default": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"schema": "resourceitem1.schema.json",
"id": "config/windowopendetectionenabled",
"datatype": "Bool",
"access": "RW",
"public": true,
"description": "Turns the window open detection feature on or off.",
"default": true
}
6 changes: 6 additions & 0 deletions resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ const char *RConfigLastChangeSource = "config/lastchange_source";
const char *RConfigLastChangeTime = "config/lastchange_time";
const char *RConfigLat = "config/lat";
const char *RConfigLedIndication = "config/ledindication";
const char *RConfigLoadBalancing = "config/loadbalancing";
const char *RConfigLocalTime = "config/localtime";
const char *RConfigLock = "config/lock";
const char *RConfigLocked = "config/locked";
Expand All @@ -301,6 +302,7 @@ const char *RConfigOnStartup = "config/on/startup";
const char *RConfigPending = "config/pending";
const char *RConfigPreset = "config/preset";
const char *RConfigPulseConfiguration = "config/pulseconfiguration";
const char *RConfigRadiatorCovered = "config/radiatorcovered";
const char *RConfigReachable = "config/reachable";
const char *RConfigReportGrid = "config/reportgrid";
const char *RConfigResetPresence = "config/resetpresence";
Expand Down Expand Up @@ -345,6 +347,7 @@ const char *RConfigUsertest = "config/usertest";
const char *RConfigVolume = "config/volume";
const char *RConfigWindowCoveringType = "config/windowcoveringtype";
const char *RConfigWindowOpen = "config/windowopen_set";
const char *RConfigWindowOpenDetectionEnabled = "config/windowopendetectionenabled";

const QStringList RConfigDeviceModeValues({
"singlerocker", "singlepushbutton", "dualrocker", "dualpushbutton"
Expand Down Expand Up @@ -588,6 +591,7 @@ void initResourceDescriptors()
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeTime, QVariant::String, RConfigLastChangeTime));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeString, QVariant::String, RConfigLat));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigLedIndication));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigLoadBalancing));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeTime, QVariant::String, RConfigLocalTime));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigLock));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigLocked));
Expand All @@ -601,6 +605,7 @@ void initResourceDescriptors()
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeUInt16, QVariant::Double, RConfigPending));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeString, QVariant::String, RConfigPreset));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeUInt16, QVariant::Double, RConfigPulseConfiguration));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigRadiatorCovered));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigReachable));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigReportGrid));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigResetPresence));
Expand Down Expand Up @@ -644,6 +649,7 @@ void initResourceDescriptors()
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeUInt8, QVariant::Double, RConfigVolume));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeUInt8, QVariant::Double, RConfigWindowCoveringType));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigWindowOpen));
rItemDescriptors.emplace_back(ResourceItemDescriptor(DataTypeBool, QVariant::Bool, RConfigWindowOpenDetectionEnabled));
}

const char *getResourcePrefix(const QString &str)
Expand Down
3 changes: 3 additions & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ extern const char *RConfigLastChangeSource;
extern const char *RConfigLastChangeTime;
extern const char *RConfigLat;
extern const char *RConfigLedIndication;
extern const char *RConfigLoadBalancing;
extern const char *RConfigLocalTime;
extern const char *RConfigLock;
extern const char *RConfigLocked;
Expand All @@ -315,6 +316,7 @@ extern const char *RConfigOnStartup;
extern const char *RConfigPending;
extern const char *RConfigPreset;
extern const char *RConfigPulseConfiguration;
extern const char *RConfigRadiatorCovered;
extern const char *RConfigReachable;
extern const char *RConfigReportGrid;
extern const char *RConfigResetPresence;
Expand Down Expand Up @@ -359,6 +361,7 @@ extern const char *RConfigUsertest;
extern const char *RConfigVolume;
extern const char *RConfigWindowCoveringType;
extern const char *RConfigWindowOpen;
extern const char *RConfigWindowOpenDetectionEnabled;

#define R_ALERT_DEFAULT QVariant(QLatin1String("none"))
#define R_SENSITIVITY_MAX_DEFAULT 2
Expand Down
27 changes: 27 additions & 0 deletions rest_sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,33 @@ int DeRestPluginPrivate::changeSensorConfig(const ApiRequest &req, ApiResponse &
updated = true;
}
}
else if (rid.suffix == RConfigWindowOpenDetectionEnabled) // Boolean
{
if (devManaged && rsub)
{
change.addTargetValue(rid.suffix, data.boolean);
rsub->addStateChange(change);
updated = true;
}
}
else if (rid.suffix == RConfigRadiatorCovered) // Boolean
{
if (devManaged && rsub)
{
change.addTargetValue(rid.suffix, data.boolean);
rsub->addStateChange(change);
updated = true;
}
}
else if (rid.suffix == RConfigLoadBalancing) // Boolean
{
if (devManaged && rsub)
{
change.addTargetValue(rid.suffix, data.boolean);
rsub->addStateChange(change);
updated = true;
}
}
else if (rid.suffix == RConfigSwingMode) // String
{
const auto match = matchKeyValue(data.string, RConfigSwingModeValues);
Expand Down

0 comments on commit 4e4ab30

Please sign in to comment.