From 4e4ab30912774ee0bb8384c1f88605c128ec6383 Mon Sep 17 00:00:00 2001 From: SwoopX Date: Thu, 14 Dec 2023 23:27:32 +0100 Subject: [PATCH] Add further Danfoss specific resource items (#6175) --- devices/danfoss/etrv0100_thermostat.json | 118 ++++++++++++++++++ .../items/config_lastchange_amount_item.json | 11 ++ .../items/config_lastchange_source_item.json | 11 ++ .../items/config_lastchange_time_item.json | 11 ++ .../items/config_loadbalancing_item.json | 9 ++ .../items/config_radiatorcovered_item.json | 9 ++ ...onfig_windowopendetectionenabled_item.json | 9 ++ resource.cpp | 6 + resource.h | 3 + rest_sensors.cpp | 27 ++++ 10 files changed, 214 insertions(+) create mode 100644 devices/generic/items/config_lastchange_amount_item.json create mode 100644 devices/generic/items/config_lastchange_source_item.json create mode 100644 devices/generic/items/config_lastchange_time_item.json create mode 100644 devices/generic/items/config_loadbalancing_item.json create mode 100644 devices/generic/items/config_radiatorcovered_item.json create mode 100644 devices/generic/items/config_windowopendetectionenabled_item.json diff --git a/devices/danfoss/etrv0100_thermostat.json b/devices/danfoss/etrv0100_thermostat.json index bb2d1d2556..41b2dc10f7 100644 --- a/devices/danfoss/etrv0100_thermostat.json +++ b/devices/danfoss/etrv0100_thermostat.json @@ -26,6 +26,11 @@ "0x0B05" ] }, + "meta": { + "values": { + "config/mode": {"off": 0, "heat": 1} + } + }, "items": [ { "name": "attr/id" @@ -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, @@ -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" }, @@ -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, diff --git a/devices/generic/items/config_lastchange_amount_item.json b/devices/generic/items/config_lastchange_amount_item.json new file mode 100644 index 0000000000..da288d9569 --- /dev/null +++ b/devices/generic/items/config_lastchange_amount_item.json @@ -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 +} \ No newline at end of file diff --git a/devices/generic/items/config_lastchange_source_item.json b/devices/generic/items/config_lastchange_source_item.json new file mode 100644 index 0000000000..4764a54d16 --- /dev/null +++ b/devices/generic/items/config_lastchange_source_item.json @@ -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 +} \ No newline at end of file diff --git a/devices/generic/items/config_lastchange_time_item.json b/devices/generic/items/config_lastchange_time_item.json new file mode 100644 index 0000000000..2b0d114836 --- /dev/null +++ b/devices/generic/items/config_lastchange_time_item.json @@ -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 +} \ No newline at end of file diff --git a/devices/generic/items/config_loadbalancing_item.json b/devices/generic/items/config_loadbalancing_item.json new file mode 100644 index 0000000000..37eb023e99 --- /dev/null +++ b/devices/generic/items/config_loadbalancing_item.json @@ -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 +} \ No newline at end of file diff --git a/devices/generic/items/config_radiatorcovered_item.json b/devices/generic/items/config_radiatorcovered_item.json new file mode 100644 index 0000000000..388b06f9ef --- /dev/null +++ b/devices/generic/items/config_radiatorcovered_item.json @@ -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 +} \ No newline at end of file diff --git a/devices/generic/items/config_windowopendetectionenabled_item.json b/devices/generic/items/config_windowopendetectionenabled_item.json new file mode 100644 index 0000000000..8e467b0601 --- /dev/null +++ b/devices/generic/items/config_windowopendetectionenabled_item.json @@ -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 +} \ No newline at end of file diff --git a/resource.cpp b/resource.cpp index 11720e47b4..35ac882654 100644 --- a/resource.cpp +++ b/resource.cpp @@ -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"; @@ -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"; @@ -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" @@ -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)); @@ -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)); @@ -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) diff --git a/resource.h b/resource.h index 44a3875b76..9ee20646c9 100644 --- a/resource.h +++ b/resource.h @@ -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; @@ -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; @@ -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 diff --git a/rest_sensors.cpp b/rest_sensors.cpp index 65e1ad2c42..db4c4520ce 100644 --- a/rest_sensors.cpp +++ b/rest_sensors.cpp @@ -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);