mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[tesla] Cleanup code (#14833)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
513de69153
commit
2119cebf33
@ -48,10 +48,10 @@ public class TeslaChannelSelectorProxy {
|
||||
AUTO_COND("is_auto_conditioning_on", "autoconditioning", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -64,10 +64,10 @@ public class TeslaChannelSelectorProxy {
|
||||
BATTERY_HEATER("battery_heater_on", "batteryheater", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -76,10 +76,10 @@ public class TeslaChannelSelectorProxy {
|
||||
BATTERY_HEATER_NO_POWER("battery_heater_no_power", "batteryheaternopower", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -97,10 +97,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CALENDAR_SUPPORTED("calendar_supported", "calendarsupported", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -109,10 +109,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CALENDAR_ENABLED("calendar_enabled", "calendarenabled", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -123,10 +123,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CHARGE(null, "charge", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -138,10 +138,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CHARGE_ENABLE_REQUEST("charge_enable_request", "chargeenablerequest", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -184,10 +184,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CHARGE_TO_MAX("charge_to_max_range", "chargetomax", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -197,10 +197,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CHARGEPORT("charge_port_door_open", "chargeport", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -214,10 +214,10 @@ public class TeslaChannelSelectorProxy {
|
||||
CLIMATE_ON("is_climate_on", "climate", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -229,10 +229,10 @@ public class TeslaChannelSelectorProxy {
|
||||
DARK_RIMS("dark_rims", "darkrims", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -242,10 +242,10 @@ public class TeslaChannelSelectorProxy {
|
||||
DF("df", "driverfrontdoor", OpenClosedType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("OPEN");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("CLOSED");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -254,10 +254,10 @@ public class TeslaChannelSelectorProxy {
|
||||
DOOR_LOCK("locked", "doorlock", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -266,10 +266,10 @@ public class TeslaChannelSelectorProxy {
|
||||
DR("dr", "driverreardoor", OpenClosedType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("OPEN");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("CLOSED");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -319,10 +319,10 @@ public class TeslaChannelSelectorProxy {
|
||||
EU_VEHICLE("eu_vehicle", "european", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -332,10 +332,10 @@ public class TeslaChannelSelectorProxy {
|
||||
FAST_CHARGER("fast_charger_present", "fastcharger", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -346,10 +346,10 @@ public class TeslaChannelSelectorProxy {
|
||||
FLASH(null, "flashlights", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -358,10 +358,10 @@ public class TeslaChannelSelectorProxy {
|
||||
FRONT_DEFROSTER("is_front_defroster_on", "frontdefroster", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -370,10 +370,10 @@ public class TeslaChannelSelectorProxy {
|
||||
FT("ft", "fronttrunk", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -397,10 +397,10 @@ public class TeslaChannelSelectorProxy {
|
||||
HAS_SPOILER("has_spoiler", "spoiler", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -417,10 +417,10 @@ public class TeslaChannelSelectorProxy {
|
||||
HONK_HORN(null, "honkhorn", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -429,10 +429,10 @@ public class TeslaChannelSelectorProxy {
|
||||
HOMELINK_NEARBY("homelink_nearby", "homelink", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -491,10 +491,10 @@ public class TeslaChannelSelectorProxy {
|
||||
MANAGED_CHARGING("managed_charging_active", "managedcharging", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true")) {
|
||||
if ("true".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false")) {
|
||||
if ("false".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -504,10 +504,10 @@ public class TeslaChannelSelectorProxy {
|
||||
false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true")) {
|
||||
if ("true".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false")) {
|
||||
if ("false".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -517,10 +517,10 @@ public class TeslaChannelSelectorProxy {
|
||||
MOBILE_ENABLED(TeslaBindingConstants.MOBILE_ENABLED_STATE, "mobileenabled", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true")) {
|
||||
if ("true".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false")) {
|
||||
if ("false".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -529,10 +529,10 @@ public class TeslaChannelSelectorProxy {
|
||||
MOTORIZED_CHARGE_PORT("motorized_charge_port", "motorizedchargeport", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -555,10 +555,10 @@ public class TeslaChannelSelectorProxy {
|
||||
NATIVE_LOCATION_SUPPORTED("native_location_supported", "nativelocationsupported", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -568,10 +568,10 @@ public class TeslaChannelSelectorProxy {
|
||||
NOT_ENOUGH_POWER_TO_HEAT("not_enough_power_to_heat", "notenoughpower", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -580,10 +580,10 @@ public class TeslaChannelSelectorProxy {
|
||||
NOTIFICATIONS_ENABLED("notifications_enabled", "notificationsenabled", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -592,10 +592,10 @@ public class TeslaChannelSelectorProxy {
|
||||
NOTIFICATIONS_SUPPORTED("notifications_supported", "notificationssupported", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -612,10 +612,10 @@ public class TeslaChannelSelectorProxy {
|
||||
OPEN_FRUNK(null, "openfrunk", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -624,10 +624,10 @@ public class TeslaChannelSelectorProxy {
|
||||
OPEN_TRUNK(null, "opentrunk", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -645,10 +645,10 @@ public class TeslaChannelSelectorProxy {
|
||||
PARSED_CALENDAR("parsed_calendar_supported", "parsedcalendar", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -666,10 +666,10 @@ public class TeslaChannelSelectorProxy {
|
||||
PF("pf", "passengerfrontdoor", OpenClosedType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("OPEN");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("CLOSED");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -679,10 +679,10 @@ public class TeslaChannelSelectorProxy {
|
||||
PR("pr", "passengerreardoor", OpenClosedType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("OPEN");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("CLOSED");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -691,10 +691,10 @@ public class TeslaChannelSelectorProxy {
|
||||
PRECONDITIONING("is_preconditioning", "preconditioning", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -705,7 +705,7 @@ public class TeslaChannelSelectorProxy {
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
State someState = super.getState(s);
|
||||
BigDecimal value = ((DecimalType) someState).toBigDecimal();
|
||||
if (properties.containsKey("distanceunits") && properties.get("distanceunits").equals("km/hr")) {
|
||||
if (properties.containsKey("distanceunits") && "km/hr".equals(properties.get("distanceunits"))) {
|
||||
return new QuantityType<>(value, MetricPrefix.KILO(SIUnits.METRE));
|
||||
} else {
|
||||
return new QuantityType<>(value, ImperialUnits.MILE);
|
||||
@ -715,10 +715,10 @@ public class TeslaChannelSelectorProxy {
|
||||
REAR_DEFROSTER("is_rear_defroster_on", "reardefroster", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -727,10 +727,10 @@ public class TeslaChannelSelectorProxy {
|
||||
REAR_SEAT_HEATERS("rear_seat_heaters", "rearseatheaters", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -739,10 +739,10 @@ public class TeslaChannelSelectorProxy {
|
||||
REMOTE_START("remote_start", "remotestart", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -751,10 +751,10 @@ public class TeslaChannelSelectorProxy {
|
||||
REMOTE_START_ENABLED("remote_start_enabled", "remotestartenabled", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -763,10 +763,10 @@ public class TeslaChannelSelectorProxy {
|
||||
REMOTE_START_SUPPORTED("remote_start_supported", "remotestartsupported", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -775,10 +775,10 @@ public class TeslaChannelSelectorProxy {
|
||||
RESET_VALET_PIN(null, "resetvaletpin", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -787,10 +787,10 @@ public class TeslaChannelSelectorProxy {
|
||||
RHD("rhd", "rhd", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -801,10 +801,10 @@ public class TeslaChannelSelectorProxy {
|
||||
RT("rt", "reartrunk", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -821,10 +821,10 @@ public class TeslaChannelSelectorProxy {
|
||||
SCHEDULED_CHARGING_PENDING("scheduled_charging_pending", "scheduledchargingpending", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -844,10 +844,10 @@ public class TeslaChannelSelectorProxy {
|
||||
SENTRY_MODE("sentry_mode", "sentrymode", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -856,10 +856,10 @@ public class TeslaChannelSelectorProxy {
|
||||
SENTRY_MODE_AVAILABLE("sentry_mode_available", "sentrymodeavailable", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -869,10 +869,10 @@ public class TeslaChannelSelectorProxy {
|
||||
SIDEMIRROR_HEATING("side_mirror_heaters", "sidemirrorheaters", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -881,10 +881,10 @@ public class TeslaChannelSelectorProxy {
|
||||
SMART_PRECONDITIONING("smart_preconditioning", "smartpreconditioning", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -907,10 +907,10 @@ public class TeslaChannelSelectorProxy {
|
||||
STEERINGWHEEL_HEATER("steering_wheel_heater", "steeringwheelheater", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -919,10 +919,10 @@ public class TeslaChannelSelectorProxy {
|
||||
SUN_ROOF_PRESENT("sun_roof_installed", "sunroofinstalled", OnOffType.class, true) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -942,7 +942,7 @@ public class TeslaChannelSelectorProxy {
|
||||
TIMESTAMP("timestamp", "eventstamp", DateTimeType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
Date date = new Date(Long.valueOf(s));
|
||||
Date date = new Date(Long.parseLong(s));
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
return super.getState(dateFormatter.format(date));
|
||||
}
|
||||
@ -950,10 +950,10 @@ public class TeslaChannelSelectorProxy {
|
||||
TRIP_CARGING("trip_charging", "tripcharging", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -970,10 +970,10 @@ public class TeslaChannelSelectorProxy {
|
||||
VALET_MODE("valet_mode", "valetmode", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -982,10 +982,10 @@ public class TeslaChannelSelectorProxy {
|
||||
VALET_PIN("valet_pin_needed", "valetpin", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -995,10 +995,10 @@ public class TeslaChannelSelectorProxy {
|
||||
WAKEUP(null, "wakeup", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -1007,10 +1007,10 @@ public class TeslaChannelSelectorProxy {
|
||||
WIPERBLADE_HEATER("wiper_blade_heater", "wiperbladeheater", OnOffType.class, false) {
|
||||
@Override
|
||||
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
|
||||
if (s.equals("true") || s.equals("1")) {
|
||||
if ("true".equals(s) || "1".equals(s)) {
|
||||
return super.getState("ON");
|
||||
}
|
||||
if (s.equals("false") || s.equals("0")) {
|
||||
if ("false".equals(s) || "0".equals(s)) {
|
||||
return super.getState("OFF");
|
||||
}
|
||||
return super.getState(s);
|
||||
@ -1059,10 +1059,8 @@ public class TeslaChannelSelectorProxy {
|
||||
if (state != null) {
|
||||
return state;
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (NoSuchMethodException | IllegalArgumentException | IllegalAccessException
|
||||
| InvocationTargetException e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -68,7 +68,7 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
public static final int API_MAXIMUM_ERRORS_IN_INTERVAL = 3;
|
||||
public static final int API_ERROR_INTERVAL_SECONDS = 15;
|
||||
private static final int CONNECT_RETRY_INTERVAL = 15000;
|
||||
private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(TeslaAccountHandler.class);
|
||||
@ -148,7 +148,7 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
}
|
||||
|
||||
public void scanForVehicles() {
|
||||
scheduler.execute(() -> queryVehicles());
|
||||
scheduler.execute(this::queryVehicles);
|
||||
}
|
||||
|
||||
public void addVehicleListener(VehicleListener listener) {
|
||||
@ -184,7 +184,6 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
ThingStatusInfo authenticationResult = authenticate();
|
||||
updateStatus(authenticationResult.getStatus(), authenticationResult.getStatusDetail(),
|
||||
authenticationResult.getDescription());
|
||||
return false;
|
||||
} else {
|
||||
apiIntervalErrors++;
|
||||
if (immediatelyFail || apiIntervalErrors >= API_MAXIMUM_ERRORS_IN_INTERVAL) {
|
||||
@ -245,7 +244,6 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
thingTypeMigrationService.migrateThingType(vehicleThing, vehicleConfig.identifyModel(),
|
||||
vehicleThing.getConfiguration());
|
||||
break;
|
||||
|
||||
}
|
||||
logger.debug("Querying the vehicle: VIN {}", vehicle.vin);
|
||||
String vehicleJSON = gson.toJson(vehicle);
|
||||
@ -270,13 +268,13 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
TokenResponse token = logonToken;
|
||||
|
||||
boolean hasExpired = true;
|
||||
logger.debug("Current authentication time {}", dateFormatter.format(Instant.now()));
|
||||
logger.debug("Current authentication time {}", DATE_FORMATTER.format(Instant.now()));
|
||||
|
||||
if (token != null) {
|
||||
Instant tokenCreationInstant = Instant.ofEpochMilli(token.created_at * 1000);
|
||||
Instant tokenExpiresInstant = Instant.ofEpochMilli((token.created_at + token.expires_in) * 1000);
|
||||
logger.debug("Found a request token from {}", dateFormatter.format(tokenCreationInstant));
|
||||
logger.debug("Access token expiration time {}", dateFormatter.format(tokenExpiresInstant));
|
||||
logger.debug("Found a request token from {}", DATE_FORMATTER.format(tokenCreationInstant));
|
||||
logger.debug("Access token expiration time {}", DATE_FORMATTER.format(tokenExpiresInstant));
|
||||
|
||||
if (tokenExpiresInstant.isBefore(Instant.now())) {
|
||||
logger.debug("The access token has expired");
|
||||
@ -322,15 +320,13 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
.header("Authorization", "Bearer " + logonToken.access_token)
|
||||
.post(Entity.entity(payLoad, MediaType.APPLICATION_JSON_TYPE));
|
||||
}
|
||||
} else if (command != null) {
|
||||
response = target.resolveTemplate("cmd", command).resolveTemplate("vid", vehicleId)
|
||||
.request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.header("Authorization", "Bearer " + logonToken.access_token).get();
|
||||
} else {
|
||||
if (command != null) {
|
||||
response = target.resolveTemplate("cmd", command).resolveTemplate("vid", vehicleId)
|
||||
.request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.header("Authorization", "Bearer " + logonToken.access_token).get();
|
||||
} else {
|
||||
response = target.resolveTemplate("vid", vehicleId).request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.header("Authorization", "Bearer " + logonToken.access_token).get();
|
||||
}
|
||||
response = target.resolveTemplate("vid", vehicleId).request(MediaType.APPLICATION_JSON_TYPE)
|
||||
.header("Authorization", "Bearer " + logonToken.access_token).get();
|
||||
}
|
||||
|
||||
if (!checkResponse(response, false)) {
|
||||
@ -344,7 +340,6 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
logger.debug("Retrying to send the command {}.", command);
|
||||
return invokeAndParse(vehicleId, command, payLoad, target, noOfretries - 1);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -409,19 +404,16 @@ public class TeslaAccountHandler extends BaseBridgeHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (response != null) {
|
||||
logger.error("Error fetching the list of vehicles : {}:{}", response.getStatus(),
|
||||
response.getStatusInfo());
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
}
|
||||
} else if (response != null) {
|
||||
logger.error("Error fetching the list of vehicles : {}:{}", response.getStatus(),
|
||||
response.getStatusInfo());
|
||||
updateStatus(ThingStatus.OFFLINE);
|
||||
}
|
||||
} else if (authenticationResult.getStatusDetail() == ThingStatusDetail.CONFIGURATION_ERROR) {
|
||||
// make sure to set thing to CONFIGURATION_ERROR in case of failed authentication in order not to
|
||||
// hit request limit on retries on the Tesla SSO endpoints.
|
||||
updateStatus(ThingStatus.OFFLINE, authenticationResult.getStatusDetail());
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("An exception occurred while connecting to the Tesla back-end: '{}'", e.getMessage(), e);
|
||||
|
@ -46,7 +46,7 @@ public class TeslaSSOHandler {
|
||||
private final HttpClient httpClient;
|
||||
private final Gson gson = new Gson();
|
||||
private final Logger logger = LoggerFactory.getLogger(TeslaSSOHandler.class);
|
||||
private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
public TeslaSSOHandler(HttpClient httpClient) {
|
||||
@ -74,7 +74,7 @@ public class TeslaSSOHandler {
|
||||
|
||||
if (tokenResponse != null && tokenResponse.access_token != null && !tokenResponse.access_token.isEmpty()) {
|
||||
tokenResponse.created_at = Instant.now().getEpochSecond();
|
||||
logger.debug("Access token expires in {} seconds at {}", tokenResponse.expires_in, dateFormatter
|
||||
logger.debug("Access token expires in {} seconds at {}", tokenResponse.expires_in, DATE_FORMATTER
|
||||
.format(Instant.ofEpochMilli((tokenResponse.created_at + tokenResponse.expires_in) * 1000)));
|
||||
return tokenResponse;
|
||||
} else {
|
||||
|
@ -168,7 +168,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
|
||||
account = (TeslaAccountHandler) getBridge().getHandler();
|
||||
lock = new ReentrantLock();
|
||||
scheduler.execute(() -> queryVehicleAndUpdate());
|
||||
scheduler.execute(this::queryVehicleAndUpdate);
|
||||
|
||||
lock.lock();
|
||||
try {
|
||||
@ -197,7 +197,6 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
eventThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
@ -257,219 +256,214 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
// Request the state of all known variables. This is sub-optimal, but the requests get scheduled and
|
||||
// throttled so we are safe not to break the Tesla SLA
|
||||
requestAllData();
|
||||
} else {
|
||||
if (selector != null) {
|
||||
if (!isAwake() && allowWakeUpForCommands) {
|
||||
logger.debug("Waking vehicle to send command.");
|
||||
wakeUp();
|
||||
setActive();
|
||||
}
|
||||
try {
|
||||
switch (selector) {
|
||||
case CHARGE_LIMIT_SOC: {
|
||||
if (command instanceof PercentType) {
|
||||
setChargeLimit(((PercentType) command).intValue());
|
||||
} else if (command instanceof OnOffType && command == OnOffType.ON) {
|
||||
setChargeLimit(100);
|
||||
} else if (command instanceof OnOffType && command == OnOffType.OFF) {
|
||||
setChargeLimit(0);
|
||||
} else if (command instanceof IncreaseDecreaseType
|
||||
&& command == IncreaseDecreaseType.INCREASE) {
|
||||
setChargeLimit(Math.min(chargeState.charge_limit_soc + 1, 100));
|
||||
} else if (command instanceof IncreaseDecreaseType
|
||||
&& command == IncreaseDecreaseType.DECREASE) {
|
||||
setChargeLimit(Math.max(chargeState.charge_limit_soc - 1, 0));
|
||||
}
|
||||
break;
|
||||
} else if (selector != null) {
|
||||
if (!isAwake() && allowWakeUpForCommands) {
|
||||
logger.debug("Waking vehicle to send command.");
|
||||
wakeUp();
|
||||
setActive();
|
||||
}
|
||||
try {
|
||||
switch (selector) {
|
||||
case CHARGE_LIMIT_SOC: {
|
||||
if (command instanceof PercentType) {
|
||||
setChargeLimit(((PercentType) command).intValue());
|
||||
} else if (command instanceof OnOffType && command == OnOffType.ON) {
|
||||
setChargeLimit(100);
|
||||
} else if (command instanceof OnOffType && command == OnOffType.OFF) {
|
||||
setChargeLimit(0);
|
||||
} else if (command instanceof IncreaseDecreaseType
|
||||
&& command == IncreaseDecreaseType.INCREASE) {
|
||||
setChargeLimit(Math.min(chargeState.charge_limit_soc + 1, 100));
|
||||
} else if (command instanceof IncreaseDecreaseType
|
||||
&& command == IncreaseDecreaseType.DECREASE) {
|
||||
setChargeLimit(Math.max(chargeState.charge_limit_soc - 1, 0));
|
||||
}
|
||||
case CHARGE_AMPS:
|
||||
Integer amps = null;
|
||||
if (command instanceof DecimalType) {
|
||||
amps = ((DecimalType) command).intValue();
|
||||
}
|
||||
if (command instanceof QuantityType<?>) {
|
||||
QuantityType<?> qamps = ((QuantityType<?>) command).toUnit(Units.AMPERE);
|
||||
if (qamps != null) {
|
||||
amps = qamps.intValue();
|
||||
}
|
||||
}
|
||||
if (amps != null) {
|
||||
if (amps < 5 || amps > 32) {
|
||||
logger.warn("Charging amps can only be set in a range of 5-32A, but not to {}A.",
|
||||
amps);
|
||||
return;
|
||||
}
|
||||
setChargingAmps(amps);
|
||||
}
|
||||
break;
|
||||
case COMBINED_TEMP: {
|
||||
QuantityType<Temperature> quantity = commandToQuantityType(command);
|
||||
if (quantity != null) {
|
||||
setCombinedTemperature(quanityToRoundedFloat(quantity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DRIVER_TEMP: {
|
||||
QuantityType<Temperature> quantity = commandToQuantityType(command);
|
||||
if (quantity != null) {
|
||||
setDriverTemperature(quanityToRoundedFloat(quantity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PASSENGER_TEMP: {
|
||||
QuantityType<Temperature> quantity = commandToQuantityType(command);
|
||||
if (quantity != null) {
|
||||
setPassengerTemperature(quanityToRoundedFloat(quantity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SENTRY_MODE: {
|
||||
if (command instanceof OnOffType) {
|
||||
setSentryMode(command == OnOffType.ON);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SUN_ROOF_STATE: {
|
||||
if (command instanceof StringType) {
|
||||
setSunroof(command.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGE_TO_MAX: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
setMaxRangeCharging(true);
|
||||
} else {
|
||||
setMaxRangeCharging(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGE: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
charge(true);
|
||||
} else {
|
||||
charge(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLASH: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
flashLights();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HONK_HORN: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
honkHorn();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGEPORT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
openChargePort();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DOOR_LOCK: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
lockDoors(true);
|
||||
} else {
|
||||
lockDoors(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUTO_COND: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
autoConditioning(true);
|
||||
} else {
|
||||
autoConditioning(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WAKEUP: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
wakeUp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
openFrunk();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (vehicleState.rt == 0) {
|
||||
openTrunk();
|
||||
}
|
||||
} else {
|
||||
if (vehicleState.rt == 1) {
|
||||
closeTrunk();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VALET_MODE: {
|
||||
if (command instanceof OnOffType) {
|
||||
int valetpin = ((BigDecimal) getConfig().get(VALETPIN)).intValue();
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
setValetMode(true, valetpin);
|
||||
} else {
|
||||
setValetMode(false, valetpin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RESET_VALET_PIN: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
resetValetPin();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STEERINGWHEEL_HEATER: {
|
||||
if (command instanceof OnOffType) {
|
||||
boolean commandBooleanValue = ((OnOffType) command) == OnOffType.ON ? true : false;
|
||||
setSteeringWheelHeater(commandBooleanValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warn(
|
||||
"An error occurred while trying to set the read-only variable associated with channel '{}' to '{}'",
|
||||
channelID, command.toString());
|
||||
case CHARGE_AMPS:
|
||||
Integer amps = null;
|
||||
if (command instanceof DecimalType) {
|
||||
amps = ((DecimalType) command).intValue();
|
||||
}
|
||||
if (command instanceof QuantityType<?>) {
|
||||
QuantityType<?> qamps = ((QuantityType<?>) command).toUnit(Units.AMPERE);
|
||||
if (qamps != null) {
|
||||
amps = qamps.intValue();
|
||||
}
|
||||
}
|
||||
if (amps != null) {
|
||||
if (amps < 5 || amps > 32) {
|
||||
logger.warn("Charging amps can only be set in a range of 5-32A, but not to {}A.", amps);
|
||||
return;
|
||||
}
|
||||
setChargingAmps(amps);
|
||||
}
|
||||
break;
|
||||
case COMBINED_TEMP: {
|
||||
QuantityType<Temperature> quantity = commandToQuantityType(command);
|
||||
if (quantity != null) {
|
||||
setCombinedTemperature(quanityToRoundedFloat(quantity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DRIVER_TEMP: {
|
||||
QuantityType<Temperature> quantity = commandToQuantityType(command);
|
||||
if (quantity != null) {
|
||||
setDriverTemperature(quanityToRoundedFloat(quantity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PASSENGER_TEMP: {
|
||||
QuantityType<Temperature> quantity = commandToQuantityType(command);
|
||||
if (quantity != null) {
|
||||
setPassengerTemperature(quanityToRoundedFloat(quantity));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SENTRY_MODE: {
|
||||
if (command instanceof OnOffType) {
|
||||
setSentryMode(command == OnOffType.ON);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SUN_ROOF_STATE: {
|
||||
if (command instanceof StringType) {
|
||||
setSunroof(command.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGE_TO_MAX: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
setMaxRangeCharging(true);
|
||||
} else {
|
||||
setMaxRangeCharging(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGE: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
charge(true);
|
||||
} else {
|
||||
charge(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FLASH: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
flashLights();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HONK_HORN: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
honkHorn();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHARGEPORT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
openChargePort();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DOOR_LOCK: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
lockDoors(true);
|
||||
} else {
|
||||
lockDoors(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUTO_COND: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
autoConditioning(true);
|
||||
} else {
|
||||
autoConditioning(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WAKEUP: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
wakeUp();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
openFrunk();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RT: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
if (vehicleState.rt == 0) {
|
||||
openTrunk();
|
||||
}
|
||||
} else if (vehicleState.rt == 1) {
|
||||
closeTrunk();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VALET_MODE: {
|
||||
if (command instanceof OnOffType) {
|
||||
int valetpin = ((BigDecimal) getConfig().get(VALETPIN)).intValue();
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
setValetMode(true, valetpin);
|
||||
} else {
|
||||
setValetMode(false, valetpin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RESET_VALET_PIN: {
|
||||
if (command instanceof OnOffType) {
|
||||
if (((OnOffType) command) == OnOffType.ON) {
|
||||
resetValetPin();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STEERINGWHEEL_HEATER: {
|
||||
if (command instanceof OnOffType) {
|
||||
boolean commandBooleanValue = ((OnOffType) command) == OnOffType.ON ? true : false;
|
||||
setSteeringWheelHeater(commandBooleanValue);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warn(
|
||||
"An error occurred while trying to set the read-only variable associated with channel '{}' to '{}'",
|
||||
channelID, command.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendCommand(String command, String payLoad, WebTarget target) {
|
||||
if (command.equals(COMMAND_WAKE_UP) || isAwake() || allowWakeUpForCommands) {
|
||||
if (COMMAND_WAKE_UP.equals(command) || isAwake() || allowWakeUpForCommands) {
|
||||
Request request = account.newRequest(this, command, payLoad, target, allowWakeUpForCommands);
|
||||
if (stateThrottler != null) {
|
||||
stateThrottler.submit(COMMAND_THROTTLE, request);
|
||||
@ -482,7 +476,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
public void sendCommand(String command, String payLoad) {
|
||||
if (command.equals(COMMAND_WAKE_UP) || isAwake() || allowWakeUpForCommands) {
|
||||
if (COMMAND_WAKE_UP.equals(command) || isAwake() || allowWakeUpForCommands) {
|
||||
Request request = account.newRequest(this, command, payLoad, account.commandTarget, allowWakeUpForCommands);
|
||||
if (stateThrottler != null) {
|
||||
stateThrottler.submit(COMMAND_THROTTLE, request);
|
||||
@ -491,7 +485,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
public void sendCommand(String command, WebTarget target) {
|
||||
if (command.equals(COMMAND_WAKE_UP) || isAwake() || allowWakeUpForCommands) {
|
||||
if (COMMAND_WAKE_UP.equals(command) || isAwake() || allowWakeUpForCommands) {
|
||||
Request request = account.newRequest(this, command, "{}", target, allowWakeUpForCommands);
|
||||
if (stateThrottler != null) {
|
||||
stateThrottler.submit(COMMAND_THROTTLE, request);
|
||||
@ -500,7 +494,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
public void requestData(String command, String payLoad) {
|
||||
if (command.equals(COMMAND_WAKE_UP) || isAwake() || allowWakeUpForCommands) {
|
||||
if (COMMAND_WAKE_UP.equals(command) || isAwake() || allowWakeUpForCommands) {
|
||||
Request request = account.newRequest(this, command, payLoad, account.dataRequestTarget, false);
|
||||
if (stateThrottler != null) {
|
||||
stateThrottler.submit(DATA_THROTTLE, request);
|
||||
@ -650,7 +644,6 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
} else if (response != null && response.getStatus() == 401) {
|
||||
logger.debug("The access token has expired, trying to get a new one.");
|
||||
account.authenticate();
|
||||
return false;
|
||||
} else {
|
||||
apiIntervalErrors++;
|
||||
if (immediatelyFail || apiIntervalErrors >= TeslaAccountHandler.API_MAXIMUM_ERRORS_IN_INTERVAL) {
|
||||
@ -696,7 +689,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
public void setSunroof(String state) {
|
||||
if (state.equals("vent") || state.equals("close")) {
|
||||
if ("vent".equals(state) || "close".equals(state)) {
|
||||
JsonObject payloadObject = new JsonObject();
|
||||
payloadObject.addProperty("state", state);
|
||||
sendCommand(COMMAND_SUN_ROOF, gson.toJson(payloadObject), account.commandTarget);
|
||||
@ -859,7 +852,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
|
||||
public void parseAndUpdate(String request, String payLoad, String result) {
|
||||
final Double LOCATION_THRESHOLD = .0000001;
|
||||
final double locationThreshold = .0000001;
|
||||
|
||||
JsonObject jsonObject = null;
|
||||
|
||||
@ -871,8 +864,8 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
case DRIVE_STATE: {
|
||||
driveState = gson.fromJson(result, DriveState.class);
|
||||
|
||||
if (Math.abs(lastLatitude - driveState.latitude) > LOCATION_THRESHOLD
|
||||
|| Math.abs(lastLongitude - driveState.longitude) > LOCATION_THRESHOLD) {
|
||||
if (Math.abs(lastLatitude - driveState.latitude) > locationThreshold
|
||||
|| Math.abs(lastLongitude - driveState.longitude) > locationThreshold) {
|
||||
logger.debug("Vehicle moved, resetting last location timestamp");
|
||||
|
||||
lastLatitude = driveState.latitude;
|
||||
@ -985,15 +978,15 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
// is provided
|
||||
if (jsonObject.get("reason") != null && jsonObject.get("reason").getAsString() != null) {
|
||||
boolean requestResult = jsonObject.get("result").getAsBoolean();
|
||||
logger.debug("The request ({}) execution was {}, and reported '{}'", new Object[] { request,
|
||||
requestResult ? "successful" : "not successful", jsonObject.get("reason").getAsString() });
|
||||
logger.debug("The request ({}) execution was {}, and reported '{}'", request,
|
||||
requestResult ? "successful" : "not successful", jsonObject.get("reason").getAsString());
|
||||
} else {
|
||||
Set<Map.Entry<String, JsonElement>> entrySet = jsonObject.entrySet();
|
||||
|
||||
long resultTimeStamp = 0;
|
||||
for (Map.Entry<String, JsonElement> entry : entrySet) {
|
||||
if ("timestamp".equals(entry.getKey())) {
|
||||
resultTimeStamp = Long.valueOf(entry.getValue().getAsString());
|
||||
resultTimeStamp = Long.parseLong(entry.getValue().getAsString());
|
||||
if (logger.isTraceEnabled()) {
|
||||
Date date = new Date(resultTimeStamp);
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
@ -1028,16 +1021,14 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
} else {
|
||||
updateState(selector.getChannelID(), UnDefType.UNDEF);
|
||||
}
|
||||
} else {
|
||||
if (!entry.getValue().isJsonNull()) {
|
||||
Map<String, String> properties = editProperties();
|
||||
properties.put(selector.getChannelID(), entry.getValue().getAsString());
|
||||
updateProperties(properties);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace(
|
||||
"The variable/value pair '{}':'{}' is successfully used to set property '{}'",
|
||||
entry.getKey(), entry.getValue(), selector.getChannelID());
|
||||
}
|
||||
} else if (!entry.getValue().isJsonNull()) {
|
||||
Map<String, String> properties = editProperties();
|
||||
properties.put(selector.getChannelID(), entry.getValue().getAsString());
|
||||
updateProperties(properties);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace(
|
||||
"The variable/value pair '{}':'{}' is successfully used to set property '{}'",
|
||||
entry.getKey(), entry.getValue(), selector.getChannelID());
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -1088,16 +1079,12 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
requestData(CLIMATE_STATE);
|
||||
requestData(GUI_STATE);
|
||||
queryVehicle(MOBILE_ENABLED_STATE);
|
||||
} else if (allowWakeUp) {
|
||||
wakeUp();
|
||||
} else if (isAwake()) {
|
||||
logger.debug("slowpoll: Throttled to allow sleep, occupied/idle, or in a console mode");
|
||||
} else {
|
||||
if (allowWakeUp) {
|
||||
wakeUp();
|
||||
} else {
|
||||
if (isAwake()) {
|
||||
logger.debug("slowpoll: Throttled to allow sleep, occupied/idle, or in a console mode");
|
||||
} else {
|
||||
lastAdvModesTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
lastAdvModesTimestamp = System.currentTimeMillis();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Exception occurred in slowStateRunnable", e);
|
||||
@ -1111,14 +1098,10 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
if (allowQuery) {
|
||||
requestData(DRIVE_STATE);
|
||||
requestData(VEHICLE_STATE);
|
||||
} else {
|
||||
if (allowWakeUp) {
|
||||
wakeUp();
|
||||
} else {
|
||||
if (isAwake()) {
|
||||
logger.debug("fastpoll: Throttled to allow sleep, occupied/idle, or in a console mode");
|
||||
}
|
||||
}
|
||||
} else if (allowWakeUp) {
|
||||
wakeUp();
|
||||
} else if (isAwake()) {
|
||||
logger.debug("fastpoll: Throttled to allow sleep, occupied/idle, or in a console mode");
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1143,7 +1126,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
logger.debug("Event : Received an update: '{}'", event.value);
|
||||
|
||||
String vals[] = event.value.split(",");
|
||||
long currentTimeStamp = Long.valueOf(vals[0]);
|
||||
long currentTimeStamp = Long.parseLong(vals[0]);
|
||||
long systemTimeStamp = System.currentTimeMillis();
|
||||
if (logger.isDebugEnabled()) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
@ -1154,7 +1137,7 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
if (systemTimeStamp - currentTimeStamp < EVENT_TIMESTAMP_AGE_LIMIT) {
|
||||
if (currentTimeStamp > lastTimeStamp) {
|
||||
lastTimeStamp = Long.valueOf(vals[0]);
|
||||
lastTimeStamp = Long.parseLong(vals[0]);
|
||||
if (logger.isDebugEnabled()) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
@ -1190,15 +1173,13 @@ public class TeslaVehicleHandler extends BaseThingHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
logger.debug(
|
||||
"Event : Discarding an event with an out of sync timestamp {} (last is {})",
|
||||
dateFormatter.format(new Date(currentTimeStamp)),
|
||||
dateFormatter.format(new Date(lastTimeStamp)));
|
||||
}
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
SimpleDateFormat dateFormatter = new SimpleDateFormat(
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS");
|
||||
logger.debug(
|
||||
"Event : Discarding an event with an out of sync timestamp {} (last is {})",
|
||||
dateFormatter.format(new Date(currentTimeStamp)),
|
||||
dateFormatter.format(new Date(lastTimeStamp)));
|
||||
}
|
||||
} else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
Loading…
Reference in New Issue
Block a user