Skip to content

Commit a373750

Browse files
authored
Merge pull request #46 from ShellyUSA/DanielWinks
Daniel winks
2 parents 68f301f + 996bb35 commit a373750

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

PackageManifests/ShellyWebhookDrivers/packageManifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"packageName": "Shelly Webhook/Websocket Drivers",
33
"author": "ShellyUSA, Daniel Winks",
4-
"version": "2.0.4",
5-
"releaseNotes": "2.0.4 Fix null issue on setting parent energy totals\r\n2.0.3 Fix for cover child devices not getting coverId properly from device data\r\n2.0.3 Add drivers for Pro2PM, Pro3, Uni gen1 and gen2 to HPM. \r\n2.0.1 Change logging level on a few things to keep logs from warning about Shelly auth related messages. \r\n2.0.0 Added support for many more devices. Major rewrite of library code. 🥳\r\n1.2.0 Added Shelly Flood, Shelly PM Mini Gen3\r\n1.1.0 Added support for Bluetooth Gateway, Blu devices (button, motion, door/window), H&T (gen 1)\r\n1.0.0 Release of Shelly Plug US, Button 1, Motion 2, Shelly H&T (gen 2 and 3), and Shelly Gas",
4+
"version": "2.0.5",
5+
"releaseNotes": "2.0.5 Fix overflow issue on setting parent energy totals.\r\nFix null issue on setting parent energy totals\r\n2.0.3 Fix for cover child devices not getting coverId properly from device data\r\n2.0.3 Add drivers for Pro2PM, Pro3, Uni gen1 and gen2 to HPM. \r\n2.0.1 Change logging level on a few things to keep logs from warning about Shelly auth related messages. \r\n2.0.0 Added support for many more devices. Major rewrite of library code. 🥳\r\n1.2.0 Added Shelly Flood, Shelly PM Mini Gen3\r\n1.1.0 Added support for Bluetooth Gateway, Blu devices (button, motion, door/window), H&T (gen 1)\r\n1.0.0 Release of Shelly Plug US, Button 1, Motion 2, Shelly H&T (gen 2 and 3), and Shelly Gas",
66
"minimumHEVersion": "2.3.7.114",
77
"dateReleased": "2024-02-10",
88
"licenseFile": "https://raw.githubusercontent.com/ShellyUSA/Hubitat-Drivers/master/LICENSE",

ShellyDriverLibrary/ShellyUSA.ShellyUSA_Driver_Library.groovy

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@ BigDecimal getVoltage(Integer id = 0) {
831831
void setEnergy(BigDecimal value, Integer id = 0) {
832832
value = value.setScale(2, BigDecimal.ROUND_HALF_UP)
833833

834-
835834
ChildDeviceWrapper c = getSwitchChildById(id)
836835
if(value == -1) {
837836
if(c != null) { sendChildDeviceEvent([name: 'energy', value: null, unit:'kWh'], c) }
@@ -848,9 +847,16 @@ void setEnergy(BigDecimal value, Integer id = 0) {
848847

849848
@CompileStatic
850849
void updateParentEnergyTotal() {
851-
List<ChildDeviceWrapper> energySwitchChildren = getEnergySwitchChildren()
852-
List<BigDecimal> childEnergies = energySwitchChildren.findAll{it.currentValue('energy') != null}.collect{it.currentValue('energy') as BigDecimal}
853-
setEnergy(childEnergies.sum() as BigDecimal)
850+
if(hasChildren() == true) {
851+
List<ChildDeviceWrapper> energySwitchChildren = getEnergySwitchChildren().findAll{it.currentValue('energy') != null}
852+
List<BigDecimal> childEnergies = []
853+
logDebug("energySwitchChildren: ${energySwitchChildren}")
854+
if(energySwitchChildren != null && energySwitchChildren?.size() > 0) {
855+
childEnergies = energySwitchChildren.collect{it.currentValue('energy') as BigDecimal}
856+
logDebug("ChildEnergies: ${childEnergies}")
857+
}
858+
sendDeviceEvent([name: 'energy', value: childEnergies.sum() as BigDecimal, unit:'kWh'])
859+
}
854860
}
855861

856862
@CompileStatic
@@ -1482,7 +1488,7 @@ void setInputAnalogState(BigDecimal value, Integer id = 0) {
14821488

14831489
@CompileStatic
14841490
void setLastUpdated() {
1485-
sendDeviceEvent([name: 'lastUpdated', value: nowFormatted()])
1491+
if(hasCapabilityBattery() == true) {sendDeviceEvent([name: 'lastUpdated', value: nowFormatted()])}
14861492
}
14871493

14881494
void sendEventToShellyBluetoothHelper(String loc, Object value, String dni) {

0 commit comments

Comments
 (0)