]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tesla] Fix update timestamp and null exception for offline state (#15756)
authorbillfor <billfor@users.noreply.github.com>
Tue, 17 Oct 2023 05:40:50 +0000 (01:40 -0400)
committerGitHub <noreply@github.com>
Tue, 17 Oct 2023 05:40:50 +0000 (07:40 +0200)
Signed-off-by: Bill Forsyth <git@billforsyth.net>
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaBindingConstants.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java

index 5f175a88967a71d597c48a453434b19f4a89ca2c..09c1cf3d3d351fb653c608634364c47ec40d173f 100644 (file)
@@ -99,6 +99,7 @@ public class TeslaBindingConstants {
 
     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";
index aa9525cff81cb9a64a39509611d81daa5390f942..440b5e6da2a506481d030658fbe50f18c326532a 100644 (file)
@@ -54,6 +54,7 @@ import org.openhab.binding.tesla.internal.protocol.VehicleState;
 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;
@@ -834,6 +835,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
         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) {
@@ -844,8 +846,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                         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;
                     }