diff --git a/bundles/org.openhab.binding.tesla/README.md b/bundles/org.openhab.binding.tesla/README.md index 86bf7825256..4387fdc0b51 100644 --- a/bundles/org.openhab.binding.tesla/README.md +++ b/bundles/org.openhab.binding.tesla/README.md @@ -182,9 +182,12 @@ Additionally, these advanced channels are available (not all are available on al | shiftstate | String | Shift State | Indicates the state of the transmission, “P”, “D”, “R”, or “N” | | sidemirrorheaters | Switch | Side Mirror Heaters | Indicates if the side mirror heaters are switched on | | smartpreconditioning | Switch | Smart Preconditioning | Indicates if smart preconditioning is switched on | +| softwareupdateavailable | Switch | Update Available | Car software update available, automatically generated on non-empty "update version" | +| softwareupdatestatus | String | Update Status | Car software update status, e.g. "downloading_wifi_wait", "installing" | +| softwareupdateversion | String | Update Version | Car software version to update to, e.g. "2023.32.9" or empty | | soc | Number | State of Charge | State of Charge, in % | | state | String | State | “online”, “asleep”, “waking” | -| steeringwheelheater | Switch | Steering Wheel Heater | Turns On/Off the steering wheel heater | +| steeringwheelheater | Switch | Steering Wheel Heater | Turns On/Off the steering wheel heater | | sunroofstate | String | Sunroof State | Valid states are “unknown”, “open”, “closed”, “vent”, “comfort”. Accepts commands "close" and "vent". | | sunroof | Dimmer | Sunroof | Indicates the opening state of the sunroof (0% closed, 100% fully open) | | temperature | Number:Temperature | Temperature | Set the temperature of the autoconditioning system. The temperature for the driver and passenger will be synced. | diff --git a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaBindingConstants.java b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaBindingConstants.java index 09c1cf3d3d3..c752c8ea084 100644 --- a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaBindingConstants.java +++ b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaBindingConstants.java @@ -101,6 +101,8 @@ public class TeslaBindingConstants { public static final String CHANNEL_COMBINED_TEMP = "combinedtemp"; public static final String CHANNEL_EVENTSTAMP = "eventstamp"; + public static final String CHANNEL_SOFTWARE_UPDATE_AVAILABLE = "softwareupdateavailable"; + // thing configurations public static final String CONFIG_ALLOWWAKEUP = "allowWakeup"; public static final String CONFIG_ALLOWWAKEUPFORCOMMANDS = "allowWakeupForCommands"; diff --git a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaChannelSelectorProxy.java b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaChannelSelectorProxy.java index 69ed9afc50e..8b0bec3bad4 100644 --- a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaChannelSelectorProxy.java +++ b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/TeslaChannelSelectorProxy.java @@ -933,6 +933,8 @@ public class TeslaChannelSelectorProxy { } }, SOC("soc", "soc", PercentType.class, false), + SOFTWARE_UPDATE_STATUS("status", "softwareupdatestatus", StringType.class, false), + SOFTWARE_UPDATE_VERSION("version", "softwareupdateversion", StringType.class, false), SPEED("speed", "speed", DecimalType.class, false) { @Override public State getState(String s, TeslaChannelSelectorProxy proxy, Map properties) { diff --git a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java index 440b5e6da2a..88ce230ee6e 100644 --- a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java +++ b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java @@ -48,6 +48,7 @@ import org.openhab.binding.tesla.internal.protocol.ClimateState; import org.openhab.binding.tesla.internal.protocol.DriveState; import org.openhab.binding.tesla.internal.protocol.Event; import org.openhab.binding.tesla.internal.protocol.GUIState; +import org.openhab.binding.tesla.internal.protocol.SoftwareUpdate; import org.openhab.binding.tesla.internal.protocol.Vehicle; import org.openhab.binding.tesla.internal.protocol.VehicleData; import org.openhab.binding.tesla.internal.protocol.VehicleState; @@ -111,6 +112,7 @@ public class TeslaVehicleHandler extends BaseThingHandler { protected VehicleState vehicleState; protected ChargeState chargeState; protected ClimateState climateState; + protected SoftwareUpdate softwareUpdate; protected boolean allowWakeUp; protected boolean allowWakeUpForCommands; @@ -922,6 +924,8 @@ public class TeslaVehicleHandler extends BaseThingHandler { (climateState.driver_temp_setting + climateState.passenger_temp_setting) / 2.0f)); updateState(CHANNEL_COMBINED_TEMP, new QuantityType<>(avgtemp, SIUnits.CELSIUS)); + softwareUpdate = vehicleState.software_update; + try { lock.lock(); @@ -932,6 +936,8 @@ public class TeslaVehicleHandler extends BaseThingHandler { entrySet.addAll(gson.toJsonTree(vehicleState, VehicleState.class).getAsJsonObject().entrySet()); entrySet.addAll(gson.toJsonTree(chargeState, ChargeState.class).getAsJsonObject().entrySet()); entrySet.addAll(gson.toJsonTree(climateState, ClimateState.class).getAsJsonObject().entrySet()); + entrySet.addAll( + gson.toJsonTree(softwareUpdate, SoftwareUpdate.class).getAsJsonObject().entrySet()); for (Map.Entry entry : entrySet) { try { @@ -966,6 +972,12 @@ public class TeslaVehicleHandler extends BaseThingHandler { e.getMessage(), e); } } + + if (softwareUpdate.version == null || softwareUpdate.version.isBlank()) { + updateState(CHANNEL_SOFTWARE_UPDATE_AVAILABLE, OnOffType.OFF); + } else { + updateState(CHANNEL_SOFTWARE_UPDATE_AVAILABLE, OnOffType.ON); + } } finally { lock.unlock(); } diff --git a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/SoftwareUpdate.java b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/SoftwareUpdate.java new file mode 100644 index 00000000000..d6139c5a5a4 --- /dev/null +++ b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/SoftwareUpdate.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.tesla.internal.protocol; + +/** + * The {@link SoftwareUpdate} is a datastructure to capture + * variables sent by the Tesla Vehicle + * + * @author Hakan Tandogan - Initial contribution + */ +public class SoftwareUpdate { + + public int download_perc; + public int expected_duration_sec; + public int install_perc; + public String status; + public String version; + + SoftwareUpdate() { + } +} diff --git a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/VehicleState.java b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/VehicleState.java index b4fe8b8c104..98f66a7367c 100644 --- a/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/VehicleState.java +++ b/bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/protocol/VehicleState.java @@ -57,6 +57,8 @@ public class VehicleState { public String vehicle_name; public String wheel_type; + public SoftwareUpdate software_update; + VehicleState() { } } diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/i18n/tesla.properties b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/i18n/tesla.properties index ce45237ac0e..cdf0ab7d8c8 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/i18n/tesla.properties +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/i18n/tesla.properties @@ -322,6 +322,12 @@ channel-type.tesla.smartpreconditioning.label = Smart Preconditioning channel-type.tesla.smartpreconditioning.description = Indicates if smart preconditioning is switched on channel-type.tesla.soc.label = State of Charge channel-type.tesla.soc.description = State of Charge, in % +channel-type.tesla.softwareupdateavailable.label = Update Available +channel-type.tesla.softwareupdateavailable.description = Car software update available +channel-type.tesla.softwareupdatestatus.label = Update Status +channel-type.tesla.softwareupdatestatus.description = Car software update status +channel-type.tesla.softwareupdateversion.label = Update Version +channel-type.tesla.softwareupdateversion.description = Car software version to update to channel-type.tesla.speed.label = Speed channel-type.tesla.speed.description = Vehicle speed channel-type.tesla.state.label = State diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/channels.xml index a24c283e189..5facdaffb60 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/channels.xml @@ -4,6 +4,24 @@ xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> + + Switch + + Car software update available + + + + String + + Car software update status + + + + String + + Car software version to update to + + String diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/model3.xml b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/model3.xml index 2a892589c93..ff1c073d4d9 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/model3.xml +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/model3.xml @@ -112,6 +112,9 @@ + + + @@ -126,7 +129,7 @@ - 1 + 2 diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/models.xml b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/models.xml index 2251bdc6047..b6d6394fdf8 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/models.xml +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/models.xml @@ -115,6 +115,9 @@ + + + @@ -132,7 +135,7 @@ - 1 + 2 diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modelx.xml b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modelx.xml index 6d3074a9872..4440b6e4fa9 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modelx.xml +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modelx.xml @@ -115,6 +115,9 @@ + + + @@ -132,7 +135,7 @@ - 1 + 2 diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modely.xml b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modely.xml index 647d592b928..781bc6a6fcc 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modely.xml +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modely.xml @@ -115,6 +115,9 @@ + + + @@ -128,7 +131,7 @@ - 1 + 2 diff --git a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/update/instructions.xml index e21eda2f56d..ef59ce2a2a5 100644 --- a/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/update/instructions.xml +++ b/bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/update/instructions.xml @@ -21,6 +21,18 @@ tesla:trafficminutesdelay + + + + tesla:softwareupdateavailable + + + tesla:softwareupdatestatus + + + tesla:softwareupdateversion + + @@ -41,6 +53,18 @@ tesla:trafficminutesdelay + + + + tesla:softwareupdateavailable + + + tesla:softwareupdatestatus + + + tesla:softwareupdateversion + + @@ -61,6 +85,18 @@ tesla:trafficminutesdelay + + + + tesla:softwareupdateavailable + + + tesla:softwareupdatestatus + + + tesla:softwareupdateversion + + @@ -81,5 +117,17 @@ tesla:trafficminutesdelay + + + + tesla:softwareupdateavailable + + + tesla:softwareupdatestatus + + + tesla:softwareupdateversion + +