Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tesla] Add channel for raw JSON response from the upstream API #15889

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bundles/org.openhab.binding.tesla/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Additionally, these advanced channels are available (not all are available on al
| honkhorn | Switch | Honk the Horn | Honk the horn of the vehicle, when ON is received |
| homelink | Switch | Homelink Nearby | Indicates if the Home Link is nearby |
| idealbatteryrange | Number:Length | Ideal Battery Range | Indicates the Battery Range |
| jsonresponse | String | JSON response | JSON string as returned from the Tesla API |
| lefttempdirection | Number | Left Temperature Direction | Not documented / To be defined |
| lastautoparkerror | String | Last Autopark Error | Not documented / To be defined |
| location | Location | Location | The actual position of the vehicle |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public enum EventKeys {

public static final String CHANNEL_SOFTWARE_UPDATE_AVAILABLE = "softwareupdateavailable";

public static final String CHANNEL_JSON_RESPONSE = "jsonresponse";

// thing configurations
public static final String CONFIG_ALLOWWAKEUP = "allowWakeup";
public static final String CONFIG_ALLOWWAKEUPFORCOMMANDS = "allowWakeupForCommands";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,9 @@ public void parseAndUpdate(String request, String payLoad, String result) {
}
}
} else if ("vehicleData".equals(request)) {
// Put the response into the raw data channel even if it might not be mappable to VehicleData
updateState(CHANNEL_JSON_RESPONSE, new StringType(result));

VehicleData vehicleData = gson.fromJson(result, VehicleData.class);
if (vehicleData == null) {
logger.error("Not able to parse response '{}'", result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ channel-type.tesla.idealbatteryrange.label = Ideal Battery Range
channel-type.tesla.idealbatteryrange.description = Indicates the Batter Range
channel-type.tesla.insidetemp.label = Inside Temperature
channel-type.tesla.insidetemp.description = Indicates the inside temperature of the vehicle
channel-type.tesla.jsonresponse.label = JSON response
channel-type.tesla.jsonresponse.description = JSON string as returned from the Tesla API
channel-type.tesla.lastautoparkerror.label = Last Autopark Error
channel-type.tesla.lastautoparkerror.description = Not documented / To be defined
channel-type.tesla.leftrearbackseatheater.label = Left Rear Backseat Heater
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,14 @@
<item-type>Number:Temperature</item-type>
<label>Inside Temperature</label>
<description>Indicates the inside temperature of the vehicle</description>
<state pattern="%.1f %unit%" readOnly="true"></state>
<state readOnly="true"></state>
</channel-type>
<channel-type id="jsonresponse" advanced="true">
<item-type>String</item-type>
<label>JSON response</label>
<description>JSON string as returned from the Tesla API</description>
<category>Text</category>
<state readOnly="true"></state>
</channel-type>
<channel-type id="lefttempdirection" advanced="true">
<item-type>Number</item-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<channel id="honkhorn" typeId="honkhorn"/>
<channel id="idealbatteryrange" typeId="idealbatteryrange"/>
<channel id="insidetemp" typeId="insidetemp"/>
<channel id="jsonresponse" typeId="jsonresponse"/>
<channel id="leftrearbackseatheater" typeId="leftrearbackseatheater"/>
<channel id="leftrearseatheater" typeId="leftrearseatheater"/>
<channel id="leftseatheater" typeId="leftseatheater"/>
Expand Down Expand Up @@ -129,7 +130,7 @@
</channels>

<properties>
<property name="thingTypeVersion">2</property>
<property name="thingTypeVersion">3</property>
</properties>

<config-description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<channel id="honkhorn" typeId="honkhorn"/>
<channel id="idealbatteryrange" typeId="idealbatteryrange"/>
<channel id="insidetemp" typeId="insidetemp"/>
<channel id="jsonresponse" typeId="jsonresponse"/>
<channel id="leftrearbackseatheater" typeId="leftrearbackseatheater"/>
<channel id="leftrearseatheater" typeId="leftrearseatheater"/>
<channel id="leftseatheater" typeId="leftseatheater"/>
Expand Down Expand Up @@ -135,7 +136,7 @@
</channels>

<properties>
<property name="thingTypeVersion">2</property>
<property name="thingTypeVersion">3</property>
</properties>

<config-description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<channel id="homelink" typeId="homelink"/>
<channel id="honkhorn" typeId="honkhorn"/>
<channel id="idealbatteryrange" typeId="idealbatteryrange"/>
<channel id="jsonresponse" typeId="jsonresponse"/>
<channel id="insidetemp" typeId="insidetemp"/>
<channel id="leftrearbackseatheater" typeId="leftrearbackseatheater"/>
<channel id="leftrearseatheater" typeId="leftrearseatheater"/>
Expand Down Expand Up @@ -135,7 +136,7 @@
</channels>

<properties>
<property name="thingTypeVersion">2</property>
<property name="thingTypeVersion">3</property>
</properties>

<config-description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<channel id="honkhorn" typeId="honkhorn"/>
<channel id="idealbatteryrange" typeId="idealbatteryrange"/>
<channel id="insidetemp" typeId="insidetemp"/>
<channel id="jsonresponse" typeId="jsonresponse"/>
<channel id="leftrearbackseatheater" typeId="leftrearbackseatheater"/>
<channel id="leftrearseatheater" typeId="leftrearseatheater"/>
<channel id="leftseatheater" typeId="leftseatheater"/>
Expand Down Expand Up @@ -131,7 +132,7 @@
</channels>

<properties>
<property name="thingTypeVersion">2</property>
<property name="thingTypeVersion">3</property>
</properties>

<config-description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<type>tesla:softwareupdateversion</type>
</add-channel>
</instruction-set>

<instruction-set targetVersion="3">
<add-channel id="jsonresponse" typeId="jsonresponse">
<type>tesla:jsonresponse</type>
</add-channel>
</instruction-set>
</thing-type>

<thing-type uid="tesla:models">
Expand Down Expand Up @@ -65,6 +71,12 @@
<type>tesla:softwareupdateversion</type>
</add-channel>
</instruction-set>

<instruction-set targetVersion="3">
<add-channel id="jsonresponse" typeId="jsonresponse">
<type>tesla:jsonresponse</type>
</add-channel>
</instruction-set>
</thing-type>

<thing-type uid="tesla:modelx">
Expand Down Expand Up @@ -97,6 +109,12 @@
<type>tesla:softwareupdateversion</type>
</add-channel>
</instruction-set>

<instruction-set targetVersion="3">
<add-channel id="jsonresponse" typeId="jsonresponse">
<type>tesla:jsonresponse</type>
</add-channel>
</instruction-set>
</thing-type>

<thing-type uid="tesla:modely">
Expand Down Expand Up @@ -129,5 +147,11 @@
<type>tesla:softwareupdateversion</type>
</add-channel>
</instruction-set>

<instruction-set targetVersion="3">
<add-channel id="jsonresponse" typeId="jsonresponse">
<type>tesla:jsonresponse</type>
</add-channel>
</instruction-set>
</thing-type>
</update:update-descriptions>