| 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 |
-| sunroofstate | String | Sunroof State | “unknown”, “open”, “closed”, “vent”, “comfort” |
-| sunroof | Dimmer | Sunroof | Open or close the sunroof to provided % (0 closed, 100 fully open) |
+| 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. |
| timetofullcharge | Number | Time To Full Charge | Number of hours to fully charge the battery |
| tripcharging | Switch | Trip Charging | Not documented / To be defined |
}
break;
}
- case SUN_ROOF: {
- if (command instanceof PercentType) {
- moveSunroof(((PercentType) command).intValue());
- } else if (command instanceof OnOffType && command == OnOffType.ON) {
- moveSunroof(100);
- } else if (command instanceof OnOffType && command == OnOffType.OFF) {
- moveSunroof(0);
- } else if (command instanceof IncreaseDecreaseType
- && command == IncreaseDecreaseType.INCREASE) {
- moveSunroof(Math.min(vehicleState.sun_roof_percent_open + 1, 100));
- } else if (command instanceof IncreaseDecreaseType
- && command == IncreaseDecreaseType.DECREASE) {
- moveSunroof(Math.max(vehicleState.sun_roof_percent_open - 1, 0));
- }
- break;
- }
case CHARGE_TO_MAX: {
if (command instanceof OnOffType) {
if (((OnOffType) command) == OnOffType.ON) {
}
public void setSunroof(String state) {
- JsonObject payloadObject = new JsonObject();
- payloadObject.addProperty("state", state);
- sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
- requestData(VEHICLE_STATE);
- }
-
- public void moveSunroof(int percent) {
- JsonObject payloadObject = new JsonObject();
- payloadObject.addProperty("state", "move");
- payloadObject.addProperty("percent", percent);
- sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
- requestData(VEHICLE_STATE);
+ if (state.equals("vent") || state.equals("close")) {
+ JsonObject payloadObject = new JsonObject();
+ payloadObject.addProperty("state", state);
+ sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
+ requestData(VEHICLE_STATE);
+ } else {
+ logger.warn("Ignoring invalid command '{}' for sunroof.", state);
+ }
}
/**
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.sunroof.label = Sunroof
-channel-type.tesla.sunroof.description = Open or close the sunroof to provided % (0 closed, 100 fully open)
+channel-type.tesla.sunroof.description = Indicates the opening state of the sunroof (0% closed, 100% fully open)
channel-type.tesla.sunroofstate.label = Sunroof State
-channel-type.tesla.sunroofstate.description = “unknown”, “open”, “closed”, “vent”, “comfort”
+channel-type.tesla.sunroofstate.description = Valid states are “unknown”, “open”, “closed”, “vent”, “comfort”. Accepts commands "close" and "vent".
+channel-type.tesla.sunroofstate.command.option.close = close
+channel-type.tesla.sunroofstate.command.option.vent = vent
channel-type.tesla.timetofullcharge.label = Time To Full Charge
channel-type.tesla.timetofullcharge.description = Number of hours to fully charge the battery
channel-type.tesla.tripcharging.label = Trip Charging
<channel-type id="sunroofstate" advanced="true">
<item-type>String</item-type>
<label>Sunroof State</label>
- <description>“unknown”, “open”, “closed”, “vent”, “comfort”</description>
- <state readOnly="true"></state>
+ <description>Valid states are “unknown”, “open”, “closed”, “vent”, “comfort”. Accepts commands "close" and "vent".</description>
+ <command>
+ <options>
+ <option value="close">close</option>
+ <option value="vent">vent</option>
+ </options>
+ </command>
</channel-type>
<channel-type id="sunroof">
<item-type>Dimmer</item-type>
<label>Sunroof</label>
- <description>Open or close the sunroof to provided % (0 closed, 100 fully open)</description>
- <state pattern="%d %%"></state>
+ <description>Indicates the opening state of the sunroof (0% closed, 100% fully open)</description>
+ <state pattern="%d %%" readOnly="true"></state>
</channel-type>
<channel-type id="combinedtemp" advanced="true">
<item-type>Number:Temperature</item-type>