[tesla] Fix update timestamp and null exception for offline state (#15756)

Signed-off-by: Bill Forsyth <git@billforsyth.net>
This commit is contained in:
billfor 2023-10-17 01:40:50 -04:00 committed by GitHub
parent 43f5b216f1
commit 118afa31fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View 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";

View 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;
}