]> git.basschouten.com Git - openhab-addons.git/commitdiff
[tesla] Add steering wheel heater command support for Model 3/Y (#13704)
authorKonstantin Polihronov <polychronov@gmail.com>
Mon, 14 Nov 2022 20:33:21 +0000 (22:33 +0200)
committerGitHub <noreply@github.com>
Mon, 14 Nov 2022 20:33:21 +0000 (21:33 +0100)
* Add steering wheel heater channel for Model Y
* Add command for steering wheel heater

Signed-off-by: Konstantin Polihronov <polychronov@gmail.com>
bundles/org.openhab.binding.tesla/README.md
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/TeslaChannelSelectorProxy.java
bundles/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/internal/handler/TeslaVehicleHandler.java
bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/i18n/tesla.properties
bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/channels.xml
bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/model3.xml
bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/thing/modely.xml

index d09b47ae8528e06fa82f8e4c5d0a393731e8930c..85ba33109652c33fc3cb0d70e2ad3dc5e9643634 100644 (file)
@@ -182,7 +182,7 @@ Additionally, these advanced channels are available (not all are available on al
 | smartpreconditioning      | Switch                   | Smart Preconditioning         | Indicates if smart preconditioning is switched on                                                                |
 | soc                       | Number                   | State of Charge               | State of Charge, in %                                                                                            |
 | state                     | String                   | State                         | “online”, “asleep”, “waking”                                                                                     |
-| steeringwheelheater       | Switch                   | Steering Wheel Heater         | Indicates if the steering wheel heater is switched on                                                            |
+| 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. |
index 372c0c2969c4725871a91417ad0f5b8d26e2b5d4..f75638e0cc866224971a2dc00b54f287eb34bc52 100644 (file)
@@ -65,6 +65,7 @@ public class TeslaBindingConstants {
     public static final String COMMAND_SET_SENTRY_MODE = "set_sentry_mode";
     public static final String COMMAND_SET_TEMP = "set_temps";
     public static final String COMMAND_SET_VALET_MODE = "set_valet_mode";
+    public static final String COMMAND_STEERING_WHEEL_HEATER = "remote_steering_wheel_heater_request";
     public static final String COMMAND_SUN_ROOF = "sun_roof_control";
     public static final String COMMAND_THROTTLE = "commandthrottle";
     public static final String COMMAND_WAKE_UP = "wake_up";
index ede61d1767cf6c0aa79b2ec06d5a50d56ea17823..7d76154d4be002a074bc3f7a01f1381e9f03b218 100644 (file)
@@ -1076,7 +1076,7 @@ public class TeslaChannelSelectorProxy {
                 }
             }
 
-            throw new IllegalArgumentException("Not valid value selector");
+            throw new IllegalArgumentException("Not valid value selector. Received Selector: " + valueSelectorText);
         }
 
         public static TeslaChannelSelector getValueSelectorFromRESTID(String valueSelectorText)
@@ -1087,7 +1087,7 @@ public class TeslaChannelSelectorProxy {
                 }
             }
 
-            throw new IllegalArgumentException("Not valid value selector");
+            throw new IllegalArgumentException("Not valid value selector. Received Selector: " + valueSelectorText);
         }
     }
 
index 8053d47ae1d48272926089b3944fa6fa79b16f4f..fff168e5051a8a68770a5e463b82ce31bec63e07 100644 (file)
@@ -448,6 +448,13 @@ public class TeslaVehicleHandler extends BaseThingHandler {
                             }
                             break;
                         }
+                        case STEERINGWHEEL_HEATER: {
+                            if (command instanceof OnOffType) {
+                                boolean commandBooleanValue = ((OnOffType) command) == OnOffType.ON ? true : false;
+                                setSteeringWheelHeater(commandBooleanValue);
+                            }
+                            break;
+                        }
                         default:
                             break;
                     }
@@ -799,6 +806,12 @@ public class TeslaVehicleHandler extends BaseThingHandler {
         sendCommand(COMMAND_WAKE_UP, account.wakeUpTarget);
     }
 
+    public void setSteeringWheelHeater(boolean isOn) {
+        JsonObject payloadObject = new JsonObject();
+        payloadObject.addProperty("on", isOn);
+        sendCommand(COMMAND_STEERING_WHEEL_HEATER, gson.toJson(payloadObject), account.commandTarget);
+    }
+
     protected Vehicle queryVehicle() {
         String authHeader = account.getAuthHeader();
 
index 2d33187b2c450ef9e7e835bc6d620a270318cab7..3dd21b338581e8c80e1825e62bc96a70b923377c 100644 (file)
@@ -269,7 +269,7 @@ channel-type.tesla.speed.description = Vehicle speed
 channel-type.tesla.state.label = State
 channel-type.tesla.state.description = “online”, “asleep”, “waking”
 channel-type.tesla.steeringwheelheater.label = Steering Wheel Heater
-channel-type.tesla.steeringwheelheater.description = Indicates if the steering wheel heater is switched on
+channel-type.tesla.steeringwheelheater.description = Turns On/Off the steering wheel heater
 channel-type.tesla.sunroof.label = Sunroof
 channel-type.tesla.sunroof.description = Indicates the opening state of the sunroof (0% closed, 100% fully open)
 channel-type.tesla.sunroofstate.label = Sunroof State
index f9ab8be21cdbc9669ce08c38419367b555f1e301..1d092f763f13e1140062f07eb87577387e9a220d 100644 (file)
        <channel-type id="steeringwheelheater" advanced="true">
                <item-type>Switch</item-type>
                <label>Steering Wheel Heater</label>
-               <description>Indicates if the steering wheel heater is switched on</description>
-               <state readOnly="true"></state>
+               <description>Turns On/Off the steering wheel heater</description>
+               <state readOnly="false"></state>
        </channel-type>
        <channel-type id="sunroofstate" advanced="true">
                <item-type>String</item-type>
index 50d9a626aa8fdfe96e092b20c2fcc92cab9b8064..fdd9b5c4ad29d4549ef20a94637e709e02152b1b 100644 (file)
                        <channel id="soc" typeId="soc"/>
                        <channel id="speed" typeId="speed"/>
                        <channel id="state" typeId="state"/>
+                       <channel id="steeringwheelheater" typeId="steeringwheelheater"/>
                        <channel id="combinedtemp" typeId="combinedtemp"/>
                        <channel id="timetofullcharge" typeId="timetofullcharge"/>
                        <channel id="tripcharging" typeId="tripcharging"/>
index 4aa802eff67308504c9056a81d8c2e14190c068a..46fb050f3644925b0c715fa55ad54e00228cb34c 100644 (file)
                        <channel id="shiftstate" typeId="shiftstate"/>
                        <channel id="sidemirrorheaters" typeId="sidemirrorheaters"/>
                        <channel id="smartpreconditioning" typeId="smartpreconditioning"/>
+                       <channel id="steeringwheelheater" typeId="steeringwheelheater"/>
                        <channel id="soc" typeId="soc"/>
                        <channel id="speed" typeId="speed"/>
                        <channel id="state" typeId="state"/>