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 channels for active routing #15705

Merged
merged 21 commits into from Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
57b62ea
[tesla] Add channels and documentation for active routing
hakan42 Oct 6, 2023
2c66f2d
Update bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/th…
hakan42 Oct 6, 2023
75ffb28
Update bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/th…
hakan42 Oct 6, 2023
c5bc7d9
Update bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/th…
hakan42 Oct 6, 2023
764e594
Update bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/th…
hakan42 Oct 6, 2023
7cd1d5c
Update bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/th…
hakan42 Oct 6, 2023
ab9257e
[tesla] added UoM as suggested on review
hakan42 Oct 6, 2023
498a92a
[tesla] added UoM and conversion as suggested on review
hakan42 Oct 6, 2023
279290a
[tesla] renamed channels as suggested on review
hakan42 Oct 6, 2023
f12fedc
[tesla] add update instructions as suggested on review
hakan42 Oct 6, 2023
b45a248
[tesla] renamed channels and their descriptions as suggested on review
hakan42 Oct 6, 2023
544e642
Update bundles/org.openhab.binding.tesla/src/main/resources/OH-INF/th…
hakan42 Oct 6, 2023
3c84dc8
Update bundles/org.openhab.binding.tesla/README.md
hakan42 Oct 6, 2023
8abc720
Update bundles/org.openhab.binding.tesla/src/main/java/org/openhab/bi…
hakan42 Oct 6, 2023
099fb1b
[tesla] add thingTypeVersion as shown by @jlaur
hakan42 Oct 6, 2023
a0b47e0
[tesla] adapted label case to other examples
hakan42 Oct 6, 2023
57aa02f
[tesla] aligned labels and descriptions with channels.xml
hakan42 Oct 6, 2023
51d9e17
Update bundles/org.openhab.binding.tesla/README.md
hakan42 Oct 7, 2023
4575dc7
Update bundles/org.openhab.binding.tesla/README.md
hakan42 Oct 7, 2023
4d346f8
[tesla] updated default sitemap as suggested on review
hakan42 Oct 7, 2023
457f70b
[tesla] expose navigation destination as channels instead of properties
hakan42 Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion bundles/org.openhab.binding.tesla/README.md
Expand Up @@ -90,6 +90,11 @@ Additionally, these advanced channels are available (not all are available on al

| Channel ID | Item Type | Label | Description |
|---------------------------|--------------------------|-------------------------------|------------------------------------------------------------------------------------------------------------------|
| destinationname | String | Route destination | Name of the destination |
| destinationlocation | Location | Route location | Location of the destination |
| distancetoarrival | Number:Length | Distance to arrival | Distance to drive to the destination (in miles) |
| minutestoarrival | Number:Time | Minutes to arrival | Minutes to drive to the destination |
| trafficminutesdelay | Number:Time | Traffic delay | Minutes of delay due to traffic |
| autoparkstate | String | Autopark State | Undocumented / To be defined |
| autoparkstyle | String | Autopark Style | Undocumented / To be defined |
| batterycurrent | Number:ElectricCurrent | Battery Current | Current (Ampere) floating into (+) or out (-) of the battery |
Expand Down Expand Up @@ -200,7 +205,6 @@ demo.Things:
Bridge tesla:account:myaccount "My Tesla Account" [ refreshToken="xxxx" ] {
model3 mycar "My favorite car" [ vin="5YJSA7H25FFP53736"]
}
```

demo.items:

Expand Down Expand Up @@ -263,6 +267,11 @@ Number:Temperature TeslaTemperature {channel="account:model3:myaccou
Number:Temperature TeslaTemperatureCombined {channel="account:model3:myaccount:mycar:combinedtemp"}
Number:Temperature TeslaInsideTemperature {channel="account:model3:myaccount:mycar:insidetemp"}
Number:Temperature TeslaOutsideTemperature {channel="account:model3:myaccount:mycar:outsidetemp"}

String TeslaDestinationName {channel="account:model3:myaccount:mycar:destinationname"}
Location TeslaDestinationLocation {channel="account:model3:myaccount:mycar:destinationlocation"}
Number:Time TeslaMinutesToArrival {channel="account:model3:myaccount:mycar:minutestoarrival", unit="min"}
Number:Length TeslaDistanceToArrival {channel="account:model3:myaccount:mycar:distancetoarrival"}
```

demo.sitemap:
Expand Down Expand Up @@ -339,6 +348,13 @@ sitemap main label="Main"
{
Mapview item=TeslaLocation height=10
}
Frame
{
Default item=TeslaDestinationName
Default item=TeslaMinutesToArrival
Default item=TeslaDistanceToArrival
Mapview item=TeslaDestinationLocation height=10
}
}
}
```
Expand Down
Expand Up @@ -45,6 +45,48 @@ public class TeslaChannelSelectorProxy {
public enum TeslaChannelSelector {

API("api_version", "api", DecimalType.class, true),
AR_DESTINATION("active_route_destination", "destinationname", StringType.class, false),
AR_LATITUDE("active_route_latitude", "destinationlocation", DecimalType.class, false) {
@Override
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
proxy.latitude = s;
return new PointType(new StringType(proxy.latitude), new StringType(proxy.longitude),
new StringType(proxy.elevation));
}
},
AR_LONGITUDE("active_route_longitude", "destinationlocation", DecimalType.class, false) {
@Override
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
proxy.longitude = s;
return new PointType(new StringType(proxy.latitude), new StringType(proxy.longitude),
new StringType(proxy.elevation));
}
},
AR_DISTANCE_TO_ARRIVAL("active_route_miles_to_arrival", "distancetoarrival", DecimalType.class, false) {
@Override
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
State someState = super.getState(s);
BigDecimal value = ((DecimalType) someState).toBigDecimal();
return new QuantityType<>(value, ImperialUnits.MILE);
}
},
AR_MINUTES_TO_ARRIVAL("active_route_minutes_to_arrival", "minutestoarrival", DecimalType.class, false) {
@Override
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
State someState = super.getState(s);
BigDecimal value = ((DecimalType) someState).toBigDecimal();
return new QuantityType<>(value, Units.MINUTE);
}
},
AR_TRAFFIC_MINUTES_DELAY("active_route_traffic_minutes_delay", "trafficminutesdelay", DecimalType.class,
false) {
@Override
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
State someState = super.getState(s);
BigDecimal value = ((DecimalType) someState).toBigDecimal();
return new QuantityType<>(value, Units.MINUTE);
}
},
AUTO_COND("is_auto_conditioning_on", "autoconditioning", OnOffType.class, false) {
@Override
public State getState(String s, TeslaChannelSelectorProxy proxy, Map<String, String> properties) {
Expand Down
Expand Up @@ -20,6 +20,12 @@
*/
public class DriveState {

public String active_route_destination;
public double active_route_latitude;
public double active_route_longitude;
public double active_route_miles_to_arrival;
public double active_route_minutes_to_arrival;
public double active_route_traffic_minutes_delay;
public double latitude;
public double longitude;
public double native_latitude;
Expand Down
Expand Up @@ -105,6 +105,17 @@ thing-type.config.tesla.vehicle.vin.description = VIN of the vehicle

# channel types

channel-type.tesla.destinationname.label = Route Destination
channel-type.tesla.destinationname.description = Name of the destination
channel-type.tesla.destinationlocation.label = Route Location
channel-type.tesla.destinationlocation.description = Location of the destination
channel-type.tesla.distancetoarrival.label = Distance To Arrival
channel-type.tesla.distancetoarrival.description = Distance to drive to the destination (in miles)
channel-type.tesla.minutestoarrival.label = Minutes To Arrival
channel-type.tesla.minutestoarrival.description = Minutes to drive to the destination
channel-type.tesla.trafficminutesdelay.label = Traffic Delay
channel-type.tesla.trafficminutesdelay.description = Delay to arrive at the destination due to traffic

channel-type.tesla.autoconditioning.label = Auto Conditioning
channel-type.tesla.autoconditioning.description = Turns on auto-conditioning (a/c or heating)
channel-type.tesla.autoparkstate.label = Autopark State
Expand Down
Expand Up @@ -4,6 +4,39 @@
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">

<channel-type id="destinationname">
<item-type>String</item-type>
<label>Route Destination</label>
<description>Name of the destination</description>
<state readOnly="true"></state>
</channel-type>
<channel-type id="destinationlocation" advanced="false">
<item-type>Location</item-type>
<label>Route Location</label>
<description>Location of the destination</description>
<state readOnly="true"></state>
</channel-type>
<channel-type id="distancetoarrival">
<item-type>Number:Length</item-type>
<label>Distance To Arrival</label>
<description>Distance to drive to the destination (in miles)</description>
<state pattern="%.1f %unit%" readOnly="true"></state>
hakan42 marked this conversation as resolved.
Show resolved Hide resolved
</channel-type>
<channel-type id="minutestoarrival">
<item-type>Number:Time</item-type>
<label>Minutes To Arrival</label>
<description>Minutes to drive to the destination</description>
hakan42 marked this conversation as resolved.
Show resolved Hide resolved
<category>Time</category>
<state pattern="%d %unit%" readOnly="true"></state>
</channel-type>
<channel-type id="trafficminutesdelay">
<item-type>Number:Time</item-type>
<label>Traffic Delay</label>
<description>Delay to arrive at the destination due to traffic</description>
hakan42 marked this conversation as resolved.
Show resolved Hide resolved
<category>Time</category>
<state pattern="%d %unit%" readOnly="true"></state>
</channel-type>

<channel-type id="autoconditioning">
<item-type>Switch</item-type>
<label>Auto Conditioning</label>
Expand Down
Expand Up @@ -14,6 +14,11 @@
<description>A Tesla Model 3 Vehicle</description>

<channels>
<channel id="destinationname" typeId="destinationname"/>
<channel id="destinationlocation" typeId="destinationlocation"/>
<channel id="distancetoarrival" typeId="distancetoarrival"/>
<channel id="minutestoarrival" typeId="minutestoarrival"/>
<channel id="trafficminutesdelay" typeId="trafficminutesdelay"/>
<channel id="autoconditioning" typeId="autoconditioning"/>
<channel id="autoparkstate" typeId="autoparkstate"/>
<channel id="autoparkstate2" typeId="autoparkstate"/>
Expand Down Expand Up @@ -120,6 +125,10 @@
<channel id="wakeup" typeId="wakeup"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<config-description>
<parameter name="vin" type="text" required="true">
<label>Vehicle Identification Number</label>
Expand Down
Expand Up @@ -14,6 +14,11 @@
<description>A Tesla Model S Vehicle</description>

<channels>
<channel id="destinationname" typeId="destinationname"/>
<channel id="destinationlocation" typeId="destinationlocation"/>
<channel id="distancetoarrival" typeId="distancetoarrival"/>
<channel id="minutestoarrival" typeId="minutestoarrival"/>
<channel id="trafficminutesdelay" typeId="trafficminutesdelay"/>
<channel id="autoconditioning" typeId="autoconditioning"/>
<channel id="autoparkstate" typeId="autoparkstate"/>
<channel id="autoparkstate2" typeId="autoparkstate"/>
Expand Down Expand Up @@ -126,6 +131,10 @@
<channel id="wiperbladeheater" typeId="wiperbladeheater"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<config-description>
<parameter name="vin" type="text" required="true">
<label>Vehicle Identification Number</label>
Expand Down
Expand Up @@ -14,6 +14,11 @@
<description>A Tesla Model X Vehicle</description>

<channels>
<channel id="destinationname" typeId="destinationname"/>
<channel id="destinationlocation" typeId="destinationlocation"/>
<channel id="distancetoarrival" typeId="distancetoarrival"/>
<channel id="minutestoarrival" typeId="minutestoarrival"/>
<channel id="trafficminutesdelay" typeId="trafficminutesdelay"/>
<channel id="autoconditioning" typeId="autoconditioning"/>
<channel id="autoparkstate" typeId="autoparkstate"/>
<channel id="autoparkstate2" typeId="autoparkstate"/>
Expand Down Expand Up @@ -126,6 +131,10 @@
<channel id="wiperbladeheater" typeId="wiperbladeheater"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<config-description>
<parameter name="vin" type="text" required="true">
<label>Vehicle Identification Number</label>
Expand Down
Expand Up @@ -14,6 +14,11 @@
<description>A Tesla Model Y Vehicle</description>

<channels>
<channel id="destinationname" typeId="destinationname"/>
<channel id="destinationlocation" typeId="destinationlocation"/>
<channel id="distancetoarrival" typeId="distancetoarrival"/>
<channel id="minutestoarrival" typeId="minutestoarrival"/>
<channel id="trafficminutesdelay" typeId="trafficminutesdelay"/>
<channel id="allowwakeup" typeId="allowwakeup"/>
<channel id="autoconditioning" typeId="autoconditioning"/>
<channel id="autoparkstate" typeId="autoparkstate"/>
Expand Down Expand Up @@ -122,6 +127,10 @@
<channel id="wakeup" typeId="wakeup"/>
</channels>

<properties>
<property name="thingTypeVersion">1</property>
</properties>

<config-description>
<parameter name="vin" type="text" required="true">
<label>Vehicle Identification Number</label>
Expand Down
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<update:update-descriptions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:update="https://openhab.org/schemas/update-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/update-description/v1.0.0 https://openhab.org/schemas/update-description-1.0.0.xsd">

<thing-type uid="tesla:model3">
<instruction-set targetVersion="1">
hakan42 marked this conversation as resolved.
Show resolved Hide resolved
<add-channel id="destinationname">
<type>tesla:destinationname</type>
</add-channel>
<add-channel id="destinationlocation">
<type>tesla:destinationlocation</type>
</add-channel>
<add-channel id="distancetoarrival">
<type>tesla:distancetoarrival</type>
</add-channel>
<add-channel id="minutestoarrival">
<type>tesla:minutestoarrival</type>
</add-channel>
<add-channel id="trafficminutesdelay">
<type>tesla:trafficminutesdelay</type>
</add-channel>
</instruction-set>
</thing-type>

<thing-type uid="tesla:models">
<instruction-set targetVersion="1">
<add-channel id="destinationname">
<type>tesla:destinationname</type>
</add-channel>
<add-channel id="destinationlocation">
<type>tesla:destinationlocation</type>
</add-channel>
<add-channel id="distancetoarrival">
<type>tesla:distancetoarrival</type>
</add-channel>
<add-channel id="minutestoarrival">
<type>tesla:minutestoarrival</type>
</add-channel>
<add-channel id="trafficminutesdelay">
<type>tesla:trafficminutesdelay</type>
</add-channel>
</instruction-set>
</thing-type>

<thing-type uid="tesla:modelx">
<instruction-set targetVersion="1">
<add-channel id="destinationname">
<type>tesla:destinationname</type>
</add-channel>
<add-channel id="destinationlocation">
<type>tesla:destinationlocation</type>
</add-channel>
<add-channel id="distancetoarrival">
<type>tesla:distancetoarrival</type>
</add-channel>
<add-channel id="minutestoarrival">
<type>tesla:minutestoarrival</type>
</add-channel>
<add-channel id="trafficminutesdelay">
<type>tesla:trafficminutesdelay</type>
</add-channel>
</instruction-set>
</thing-type>

<thing-type uid="tesla:modely">
<instruction-set targetVersion="1">
<add-channel id="destinationname">
<type>tesla:destinationname</type>
</add-channel>
<add-channel id="destinationlocation">
<type>tesla:destinationlocation</type>
</add-channel>
<add-channel id="distancetoarrival">
<type>tesla:distancetoarrival</type>
</add-channel>
<add-channel id="minutestoarrival">
<type>tesla:minutestoarrival</type>
</add-channel>
<add-channel id="trafficminutesdelay">
<type>tesla:trafficminutesdelay</type>
</add-channel>
</instruction-set>
</thing-type>
</update:update-descriptions>