mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[tesla] Add channels for software update (#15816)
* [tesla] Add value holders for Software Update state Signed-off-by: Hakan Tandogan <hakan@tandogan.com>
This commit is contained in:
parent
e2b03dea75
commit
59c3135ccb
@ -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. |
|
||||
|
@ -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";
|
||||
|
@ -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<String, String> properties) {
|
||||
|
@ -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<String, JsonElement> 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();
|
||||
}
|
||||
|
@ -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() {
|
||||
}
|
||||
}
|
@ -57,6 +57,8 @@ public class VehicleState {
|
||||
public String vehicle_name;
|
||||
public String wheel_type;
|
||||
|
||||
public SoftwareUpdate software_update;
|
||||
|
||||
VehicleState() {
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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">
|
||||
|
||||
<channel-type id="softwareupdateavailable">
|
||||
<item-type>Switch</item-type>
|
||||
<label>Update Available</label>
|
||||
<description>Car software update available</description>
|
||||
<state readOnly="true"></state>
|
||||
</channel-type>
|
||||
<channel-type id="softwareupdatestatus">
|
||||
<item-type>String</item-type>
|
||||
<label>Update Status</label>
|
||||
<description>Car software update status</description>
|
||||
<state readOnly="true"></state>
|
||||
</channel-type>
|
||||
<channel-type id="softwareupdateversion">
|
||||
<item-type>String</item-type>
|
||||
<label>Update Version</label>
|
||||
<description>Car software version to update to</description>
|
||||
<state readOnly="true"></state>
|
||||
</channel-type>
|
||||
<channel-type id="destinationname">
|
||||
<item-type>String</item-type>
|
||||
<label>Route Destination</label>
|
||||
|
@ -112,6 +112,9 @@
|
||||
<channel id="sidemirrorheaters" typeId="sidemirrorheaters"/>
|
||||
<channel id="smartpreconditioning" typeId="smartpreconditioning"/>
|
||||
<channel id="soc" typeId="soc"/>
|
||||
<channel id="softwareupdateavailable" typeId="softwareupdateavailable"/>
|
||||
<channel id="softwareupdatestatus" typeId="softwareupdatestatus"/>
|
||||
<channel id="softwareupdateversion" typeId="softwareupdateversion"/>
|
||||
<channel id="speed" typeId="speed"/>
|
||||
<channel id="state" typeId="state"/>
|
||||
<channel id="steeringwheelheater" typeId="steeringwheelheater"/>
|
||||
@ -126,7 +129,7 @@
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="thingTypeVersion">1</property>
|
||||
<property name="thingTypeVersion">2</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
|
@ -115,6 +115,9 @@
|
||||
<channel id="sidemirrorheaters" typeId="sidemirrorheaters"/>
|
||||
<channel id="smartpreconditioning" typeId="smartpreconditioning"/>
|
||||
<channel id="soc" typeId="soc"/>
|
||||
<channel id="softwareupdateavailable" typeId="softwareupdateavailable"/>
|
||||
<channel id="softwareupdatestatus" typeId="softwareupdatestatus"/>
|
||||
<channel id="softwareupdateversion" typeId="softwareupdateversion"/>
|
||||
<channel id="speed" typeId="speed"/>
|
||||
<channel id="state" typeId="state"/>
|
||||
<channel id="steeringwheelheater" typeId="steeringwheelheater"/>
|
||||
@ -132,7 +135,7 @@
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="thingTypeVersion">1</property>
|
||||
<property name="thingTypeVersion">2</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
|
@ -115,6 +115,9 @@
|
||||
<channel id="sidemirrorheaters" typeId="sidemirrorheaters"/>
|
||||
<channel id="smartpreconditioning" typeId="smartpreconditioning"/>
|
||||
<channel id="soc" typeId="soc"/>
|
||||
<channel id="softwareupdateavailable" typeId="softwareupdateavailable"/>
|
||||
<channel id="softwareupdatestatus" typeId="softwareupdatestatus"/>
|
||||
<channel id="softwareupdateversion" typeId="softwareupdateversion"/>
|
||||
<channel id="speed" typeId="speed"/>
|
||||
<channel id="state" typeId="state"/>
|
||||
<channel id="steeringwheelheater" typeId="steeringwheelheater"/>
|
||||
@ -132,7 +135,7 @@
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="thingTypeVersion">1</property>
|
||||
<property name="thingTypeVersion">2</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
|
@ -115,6 +115,9 @@
|
||||
<channel id="smartpreconditioning" typeId="smartpreconditioning"/>
|
||||
<channel id="steeringwheelheater" typeId="steeringwheelheater"/>
|
||||
<channel id="soc" typeId="soc"/>
|
||||
<channel id="softwareupdateavailable" typeId="softwareupdateavailable"/>
|
||||
<channel id="softwareupdatestatus" typeId="softwareupdatestatus"/>
|
||||
<channel id="softwareupdateversion" typeId="softwareupdateversion"/>
|
||||
<channel id="speed" typeId="speed"/>
|
||||
<channel id="state" typeId="state"/>
|
||||
<channel id="combinedtemp" typeId="combinedtemp"/>
|
||||
@ -128,7 +131,7 @@
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="thingTypeVersion">1</property>
|
||||
<property name="thingTypeVersion">2</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
|
@ -21,6 +21,18 @@
|
||||
<type>tesla:trafficminutesdelay</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
|
||||
<instruction-set targetVersion="2">
|
||||
<add-channel id="softwareupdateavailable" typeId="softwareupdateavailable">
|
||||
<type>tesla:softwareupdateavailable</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdatestatus" typeId="softwareupdatestatus">
|
||||
<type>tesla:softwareupdatestatus</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdateversion" typeId="softwareupdateversion">
|
||||
<type>tesla:softwareupdateversion</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
</thing-type>
|
||||
|
||||
<thing-type uid="tesla:models">
|
||||
@ -41,6 +53,18 @@
|
||||
<type>tesla:trafficminutesdelay</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
|
||||
<instruction-set targetVersion="2">
|
||||
<add-channel id="softwareupdateavailable" typeId="softwareupdateavailable">
|
||||
<type>tesla:softwareupdateavailable</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdatestatus" typeId="softwareupdatestatus">
|
||||
<type>tesla:softwareupdatestatus</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdateversion" typeId="softwareupdateversion">
|
||||
<type>tesla:softwareupdateversion</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
</thing-type>
|
||||
|
||||
<thing-type uid="tesla:modelx">
|
||||
@ -61,6 +85,18 @@
|
||||
<type>tesla:trafficminutesdelay</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
|
||||
<instruction-set targetVersion="2">
|
||||
<add-channel id="softwareupdateavailable" typeId="softwareupdateavailable">
|
||||
<type>tesla:softwareupdateavailable</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdatestatus" typeId="softwareupdatestatus">
|
||||
<type>tesla:softwareupdatestatus</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdateversion" typeId="softwareupdateversion">
|
||||
<type>tesla:softwareupdateversion</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
</thing-type>
|
||||
|
||||
<thing-type uid="tesla:modely">
|
||||
@ -81,5 +117,17 @@
|
||||
<type>tesla:trafficminutesdelay</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
|
||||
<instruction-set targetVersion="2">
|
||||
<add-channel id="softwareupdateavailable" typeId="softwareupdateavailable">
|
||||
<type>tesla:softwareupdateavailable</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdatestatus" typeId="softwareupdatestatus">
|
||||
<type>tesla:softwareupdatestatus</type>
|
||||
</add-channel>
|
||||
<add-channel id="softwareupdateversion" typeId="softwareupdateversion">
|
||||
<type>tesla:softwareupdateversion</type>
|
||||
</add-channel>
|
||||
</instruction-set>
|
||||
</thing-type>
|
||||
</update:update-descriptions>
|
||||
|
Loading…
Reference in New Issue
Block a user