Update sunroof feature to changed Tesla API (#12031)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
parent
a925fb52d0
commit
b7e78e3a0d
@ -180,8 +180,8 @@ Additionally, these advanced channels are available (not all are available on al
|
|||||||
| soc | Number | State of Charge | State of Charge, in % |
|
| soc | Number | State of Charge | State of Charge, in % |
|
||||||
| state | String | State | “online”, “asleep”, “waking” |
|
| 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 | Indicates if the steering wheel heater is switched on |
|
||||||
| sunroofstate | String | Sunroof State | “unknown”, “open”, “closed”, “vent”, “comfort” |
|
| sunroofstate | String | Sunroof State | Valid states are “unknown”, “open”, “closed”, “vent”, “comfort”. Accepts commands "close" and "vent". |
|
||||||
| sunroof | Dimmer | Sunroof | Open or close the sunroof to provided % (0 closed, 100 fully open) |
|
| 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. |
|
| 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 |
|
| timetofullcharge | Number | Time To Full Charge | Number of hours to fully charge the battery |
|
||||||
| tripcharging | Switch | Trip Charging | Not documented / To be defined |
|
| tripcharging | Switch | Trip Charging | Not documented / To be defined |
|
||||||
|
|||||||
@ -290,22 +290,6 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
break;
|
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: {
|
case CHARGE_TO_MAX: {
|
||||||
if (command instanceof OnOffType) {
|
if (command instanceof OnOffType) {
|
||||||
if (((OnOffType) command) == OnOffType.ON) {
|
if (((OnOffType) command) == OnOffType.ON) {
|
||||||
@ -582,18 +566,14 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSunroof(String state) {
|
public void setSunroof(String state) {
|
||||||
JsonObject payloadObject = new JsonObject();
|
if (state.equals("vent") || state.equals("close")) {
|
||||||
payloadObject.addProperty("state", state);
|
JsonObject payloadObject = new JsonObject();
|
||||||
sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
|
payloadObject.addProperty("state", state);
|
||||||
requestData(VEHICLE_STATE);
|
sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
|
||||||
}
|
requestData(VEHICLE_STATE);
|
||||||
|
} else {
|
||||||
public void moveSunroof(int percent) {
|
logger.warn("Ignoring invalid command '{}' for sunroof.", state);
|
||||||
JsonObject payloadObject = new JsonObject();
|
}
|
||||||
payloadObject.addProperty("state", "move");
|
|
||||||
payloadObject.addProperty("percent", percent);
|
|
||||||
sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
|
|
||||||
requestData(VEHICLE_STATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -252,9 +252,11 @@ channel-type.tesla.state.description = “online”, “asleep”, “waking”
|
|||||||
channel-type.tesla.steeringwheelheater.label = Steering Wheel Heater
|
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 = Indicates if the steering wheel heater is switched on
|
||||||
channel-type.tesla.sunroof.label = Sunroof
|
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.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.label = Time To Full Charge
|
||||||
channel-type.tesla.timetofullcharge.description = Number of hours to fully charge the battery
|
channel-type.tesla.timetofullcharge.description = Number of hours to fully charge the battery
|
||||||
channel-type.tesla.tripcharging.label = Trip Charging
|
channel-type.tesla.tripcharging.label = Trip Charging
|
||||||
|
|||||||
@ -583,14 +583,19 @@
|
|||||||
<channel-type id="sunroofstate" advanced="true">
|
<channel-type id="sunroofstate" advanced="true">
|
||||||
<item-type>String</item-type>
|
<item-type>String</item-type>
|
||||||
<label>Sunroof State</label>
|
<label>Sunroof State</label>
|
||||||
<description>“unknown”, “open”, “closed”, “vent”, “comfort”</description>
|
<description>Valid states are “unknown”, “open”, “closed”, “vent”, “comfort”. Accepts commands "close" and "vent".</description>
|
||||||
<state readOnly="true"></state>
|
<command>
|
||||||
|
<options>
|
||||||
|
<option value="close">close</option>
|
||||||
|
<option value="vent">vent</option>
|
||||||
|
</options>
|
||||||
|
</command>
|
||||||
</channel-type>
|
</channel-type>
|
||||||
<channel-type id="sunroof">
|
<channel-type id="sunroof">
|
||||||
<item-type>Dimmer</item-type>
|
<item-type>Dimmer</item-type>
|
||||||
<label>Sunroof</label>
|
<label>Sunroof</label>
|
||||||
<description>Open or close the sunroof to provided % (0 closed, 100 fully open)</description>
|
<description>Indicates the opening state of the sunroof (0% closed, 100% fully open)</description>
|
||||||
<state pattern="%d %%"></state>
|
<state pattern="%d %%" readOnly="true"></state>
|
||||||
</channel-type>
|
</channel-type>
|
||||||
<channel-type id="combinedtemp" advanced="true">
|
<channel-type id="combinedtemp" advanced="true">
|
||||||
<item-type>Number:Temperature</item-type>
|
<item-type>Number:Temperature</item-type>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user