Skip to content

Commit

Permalink
[tesla] Fix update timestamp and null exception for offline state (op…
Browse files Browse the repository at this point in the history
…enhab#15756)

Signed-off-by: Bill Forsyth <git@billforsyth.net>
  • Loading branch information
billfor authored and querdenker2k committed Oct 21, 2023
1 parent ee4c862 commit 33986c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public enum EventKeys {

public static final String CHANNEL_CHARGE = "charge";
public static final String CHANNEL_COMBINED_TEMP = "combinedtemp";
public static final String CHANNEL_EVENTSTAMP = "eventstamp";

// thing configurations
public static final String CONFIG_ALLOWWAKEUP = "allowWakeup";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.openhab.binding.tesla.internal.throttler.QueueChannelThrottler;
import org.openhab.binding.tesla.internal.throttler.Rate;
import org.openhab.core.io.net.http.WebSocketFactory;
import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.IncreaseDecreaseType;
import org.openhab.core.library.types.OnOffType;
Expand Down Expand Up @@ -834,6 +835,7 @@ public void parseAndUpdate(String request, String payLoad, String result) {
try {
if (request != null && result != null && !"null".equals(result)) {
updateStatus(ThingStatus.ONLINE);
updateState(CHANNEL_EVENTSTAMP, new DateTimeType());
// first, update state objects
if ("queryVehicle".equals(request)) {
if (vehicle != null) {
Expand All @@ -844,8 +846,8 @@ public void parseAndUpdate(String request, String payLoad, String result) {
return;
}

if (vehicle != null && "asleep".equals(vehicle.state)) {
logger.debug("Vehicle is asleep.");
if (vehicle != null && ("asleep".equals(vehicle.state) || "offline".equals(vehicle.state))) {
logger.debug("Vehicle is {}", vehicle.state);
return;
}

Expand Down

0 comments on commit 33986c3

Please sign in to comment.