Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public class TeslascopeBindingConstants {
public static final String CHANNEL_USABLE_BATTERY_LEVEL = "usable-battery-level";
public static final String CHANNEL_VALET_MODE = "valet-mode";
public static final String CHANNEL_WIPER_BLADE_HEATER = "wiper-blade-heater";
public static final String CHANNEL_SELF_DRIVING_MILES_SINCE_RESET = "self-driving-miles-since-reset";
public static final String CHANNEL_MILES_SINCE_RESET = "miles-since-reset";
public static final String CHANNEL_SELF_DRIVING_PERCENTAGE = "self-driving-percentage";

public static final Set<ThingTypeUID> BRIDGE_THING_TYPES_UIDS = Set.of(TESLASCOPE_ACCOUNT);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(TESLASCOPE_ACCOUNT, TESLASCOPE_VEHICLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
private void pollStatus() {
try {
String response = getDetailedInformation(config.publicID);
if (response == null || response.isBlank()) {

Check warning on line 203 in bundles/org.openhab.binding.teslascope/src/main/java/org/openhab/binding/teslascope/internal/TeslascopeVehicleHandler.java

View workflow job for this annotation

GitHub Actions / Build (Java 21, ubuntu-24.04)

Null comparison always yields false: The variable response cannot be null at this location
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error.empty-response");
return;
Expand Down Expand Up @@ -333,6 +333,12 @@
new StringType(detailedInformation.driveState.shiftState));
updateState(TeslascopeBindingConstants.CHANNEL_SPEED,
new QuantityType<>(detailedInformation.driveState.speed, ImperialUnits.MILES_PER_HOUR));
updateState(TeslascopeBindingConstants.CHANNEL_SELF_DRIVING_MILES_SINCE_RESET, new QuantityType<>(
detailedInformation.driveState.selfDrivingMilesSinceReset, ImperialUnits.MILE));
updateState(TeslascopeBindingConstants.CHANNEL_MILES_SINCE_RESET,
new QuantityType<>(detailedInformation.driveState.milesSinceReset, ImperialUnits.MILE));
updateState(TeslascopeBindingConstants.CHANNEL_SELF_DRIVING_PERCENTAGE,
new DecimalType(detailedInformation.driveState.selfDrivingPercentage));
}

// vehicle state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ public class DriveState {

public float speed = 0;

@SerializedName("self_driving_miles_since_reset")
public float selfDrivingMilesSinceReset;

@SerializedName("miles_since_reset")
public float milesSinceReset;

@SerializedName("self_driving_percentage")
public float selfDrivingPercentage;

private DriveState() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</channels>

<properties>
<property name="thingTypeVersion">2</property>
<property name="thingTypeVersion">3</property>
Comment thread
psmedley marked this conversation as resolved.
</properties>

<representation-property>publicID</representation-property>
Expand Down Expand Up @@ -682,4 +682,26 @@
<description>Indicates if the wiper blade heater is switched on</description>
<state readOnly="true"></state>
</channel-type>
<channel-type id="self-driving-miles-since-reset" advanced="true">
Comment thread
psmedley marked this conversation as resolved.
<item-type>Number:Length</item-type>
<label>Self Driving distance</label>
<description>Self Driving distance since reset</description>
<state pattern="%.1f %unit%" readOnly="true"></state>
</channel-type>
<channel-type id="miles-since-reset" advanced="true">
<item-type>Number:Length</item-type>
<label>Driving distance</label>
<description>Driving distance since reset</description>
<state pattern="%.1f %unit%" readOnly="true"></state>
</channel-type>
<channel-type id="self-driving-percentage" advanced="true">
<item-type unitHint="%">Number:Dimensionless</item-type>
<label>Self Driving %</label>
<description>Percentage of driving that is on FSD</description>
<tags>
<tag>Status</tag>
<tag>Level</tag>
</tags>
<state readOnly="true" pattern="%d %unit%"/>
</channel-type>
</thing:thing-descriptions>
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@
<type>teslascope:charge-limit-soc-standard</type>
</update-channel>
</instruction-set>
<instruction-set targetVersion="3">
<add-channel id="self-driving-miles-since-reset">
<type>teslascope:self-driving-miles-since-reset</type>
</add-channel>
<add-channel id="miles-since-reset">
<type>teslascope:miles-since-reset</type>
</add-channel>
<add-channel id="self-driving-percentage">
<type>teslascope:self-driving-percentage</type>
</add-channel>
</instruction-set>

</thing-type>

Expand Down
Loading