Skip to content

Commit

Permalink
Shelly EM #18: Compensate missing timestamp/lastUpdate with system
Browse files Browse the repository at this point in the history
timestamp (like for sensors)

Signed-off-by: Markus Michels <[email protected]>
  • Loading branch information
markus7017 committed Dec 30, 2019
1 parent 9d9001a commit 31e7d61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ public static class ShellySettingsEMeter { // ShellyEM meter
public Double total; // Total consumed energy, Wh
@SerializedName("total_returned")
public Double totalReturned; // Total returned energy, Wh
public Long timestamp;
}

public static class ShellySettingsUpdate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ private void handleStatusUpdate(String devId, String payload, int serial) throws
String mGroup = profile.numMeters == 1 ? CHANNEL_GROUP_METER : CHANNEL_GROUP_METER + rIndex;
updateChannel(updates, mGroup, CHANNEL_METER_CURRENTWATTS,
toQuantityType(s.value, DIGITS_WATT, SmartHomeUnits.WATT));
if (profile.isEMeter) {
updateChannel(updates, mGroup, CHANNEL_LAST_UPDATE, getTimestamp());
}
break;
case "o": // Overtemp
// will be handled by status update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public static boolean updateMeters(ShellyBaseHandler th, ShellySettingsStatus st
updated |= th.updateChannel(groupName, CHANNEL_EMETER_VOLTAGE,
toQuantityType(getDouble(emeter.voltage), DIGITS_VOLT, SmartHomeUnits.VOLT));
if (updated) {
th.updateChannel(groupName, CHANNEL_LAST_UPDATE,
getTimestamp(getString(profile.settings.timezone), getLong(emeter.timestamp)));
th.updateChannel(groupName, CHANNEL_LAST_UPDATE, getTimestamp());
}
m++;
}
Expand Down

0 comments on commit 31e7d61

Please sign in to comment.