Skip to content

Commit

Permalink
1.4.2
Browse files Browse the repository at this point in the history
Added user presence for car device (flow trigger and condition).
  • Loading branch information
RonnyWinkler committed Apr 24, 2024
1 parent 6ddfeb7 commit 4719abc
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .homeychangelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,8 @@
},
"1.4.1": {
"en": "Added car state check before sending commands."
},
"1.4.2": {
"en": "Added user presence for car device (flow trigger and condition)."
}
}
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "com.tesla.car",
"version": "1.4.1",
"version": "1.4.2",
"compatibility": ">=5.0.0",
"platforms": ["local"],
"sdk": 3,
Expand Down
33 changes: 33 additions & 0 deletions .homeycompose/capabilities/car_user_present.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "boolean",
"title": {
"en": "User is present",
"de": "Benutzer anwesend",
"nl": "Gebruiker aanwezig"
},
"titleTrue":{
"en": "User is present",
"de": "Benutzer anwesend",
"nl": "Gebruiker aanwezig"
},
"titleFasle":{
"en": "User is absent",
"de": "Benutzer abwesend",
"nl": "Gebruiker afwezig"
},
"insightsTitleTrue":{
"en": "User is present",
"de": "Benutzer anwesend",
"nl": "Gebruiker aanwezig"
},
"insightsTitleFalse":{
"en": "User is absent",
"de": "Benutzer abwesend",
"nl": "Gebruiker afwezig"
},
"insights": false,
"getable": true,
"setable": true,
"uiComponent": null,
"icon": "./assets/capability_icons/car_user_present.svg"
}
14 changes: 14 additions & 0 deletions .homeycompose/flow/conditions/car_user_present.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"title": {
"en": "User !{{is|isn't}} present",
"de": "Benutzer !{{ist|ist nicht}} anwesend",
"nl": "Gebruiker !{{is|is niet}} aanwezig"
},
"args": [
{
"name": "device",
"type": "device",
"filter": "driver_id=car"
}
]
}
14 changes: 14 additions & 0 deletions .homeycompose/flow/triggers/car_user_present_false.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"title": {
"en": "User detected as absent",
"de": "Benutzer als abwesend erkannt",
"nl": "Gebruiker gedetecteerd als afwezig"
},
"args": [
{
"name": "device",
"type": "device",
"filter": "driver_id=car"
}
]
}
14 changes: 14 additions & 0 deletions .homeycompose/flow/triggers/car_user_present_true.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"title": {
"en": "User detected as present",
"de": "Benutzer als anwesend erkannt",
"nl": "Gebruiker gedetecteerd als aanwezig"
},
"args": [
{
"name": "device",
"type": "device",
"filter": "driver_id=car"
}
]
}
5 changes: 5 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ module.exports = class TeslaApp extends TeslaOAuth2App {
return (args.device.getCapabilityValue('car_sentry_mode'));
})

this.homey.flow.getConditionCard('car_user_present')
.registerRunListener(async (args, state) => {
return (args.device.getCapabilityValue('car_user_present'));
})

this.homey.flow.getConditionCard('climate_steering_wheel_heat_level')
.registerRunListener(async (args, state) => {
return (args.device.getCapabilityValue('climate_steering_wheel_heat_level') == args.level);
Expand Down
83 changes: 81 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
"id": "com.tesla.car",
"version": "1.4.1",
"version": "1.4.2",
"compatibility": ">=5.0.0",
"platforms": [
"local"
Expand Down Expand Up @@ -381,6 +381,36 @@
],
"id": "car_state_changed"
},
{
"title": {
"en": "User detected as absent",
"de": "Benutzer als abwesend erkannt",
"nl": "Gebruiker gedetecteerd als afwezig"
},
"args": [
{
"name": "device",
"type": "device",
"filter": "driver_id=car"
}
],
"id": "car_user_present_false"
},
{
"title": {
"en": "User detected as present",
"de": "Benutzer als anwesend erkannt",
"nl": "Gebruiker gedetecteerd als aanwezig"
},
"args": [
{
"name": "device",
"type": "device",
"filter": "driver_id=car"
}
],
"id": "car_user_present_true"
},
{
"highlight": true,
"title": {
Expand Down Expand Up @@ -1960,6 +1990,21 @@
],
"id": "car_state"
},
{
"title": {
"en": "User !{{is|isn't}} present",
"de": "Benutzer !{{ist|ist nicht}} anwesend",
"nl": "Gebruiker !{{is|is niet}} aanwezig"
},
"args": [
{
"name": "device",
"type": "device",
"filter": "driver_id=car"
}
],
"id": "car_user_present"
},
{
"title": {
"en": "Charge port !{{is|isn't}} open",
Expand Down Expand Up @@ -4070,7 +4115,8 @@
"car_doors_locked",
"car_sentry_mode",
"car_trunk_rear",
"car_trunk_front"
"car_trunk_front",
"car_user_present"
],
"energy": {
"batteries": [
Expand Down Expand Up @@ -5241,6 +5287,39 @@
"uiComponent": "button",
"icon": "./assets/capability_icons/car_trunk_rear.svg"
},
"car_user_present": {
"type": "boolean",
"title": {
"en": "User is present",
"de": "Benutzer anwesend",
"nl": "Gebruiker aanwezig"
},
"titleTrue": {
"en": "User is present",
"de": "Benutzer anwesend",
"nl": "Gebruiker aanwezig"
},
"titleFasle": {
"en": "User is absent",
"de": "Benutzer abwesend",
"nl": "Gebruiker afwezig"
},
"insightsTitleTrue": {
"en": "User is present",
"de": "Benutzer anwesend",
"nl": "Gebruiker aanwezig"
},
"insightsTitleFalse": {
"en": "User is absent",
"de": "Benutzer abwesend",
"nl": "Gebruiker afwezig"
},
"insights": false,
"getable": true,
"setable": true,
"uiComponent": null,
"icon": "./assets/capability_icons/car_user_present.svg"
},
"car_wake_up": {
"type": "boolean",
"title": {
Expand Down
1 change: 1 addition & 0 deletions assets/capability_icons/car_user_present.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions drivers/car/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,18 @@ module.exports = class CarDevice extends TeslaOAuth2Device {

async _updateDevice(data){
// Car state
if (this.hasCapability('car_doors_locked') && data.charge_state && data.vehicle_state.locked != undefined){
if (this.hasCapability('car_doors_locked') && data.vehicle_state.locked != undefined){
await this.setCapabilityValue('car_doors_locked', !data.vehicle_state.locked);
}
if (this.hasCapability('car_sentry_mode') && data.charge_state && data.vehicle_state.sentry_mode != undefined){
if (this.hasCapability('car_sentry_mode') && data.vehicle_state.sentry_mode != undefined){
await this.setCapabilityValue('car_sentry_mode', data.vehicle_state.sentry_mode);
}

// User prersent?
if (this.hasCapability('car_user_present') && data.vehicle_state.is_user_present != undefined){
await this.setCapabilityValue('car_user_present', data.vehicle_state.is_user_present);
}

// Battery
if (this.hasCapability('measure_battery') && data.charge_state && data.charge_state.battery_level != undefined){
await this.setCapabilityValue('measure_battery', data.charge_state.battery_level);
Expand Down
4 changes: 3 additions & 1 deletion drivers/car/driver.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
"car_sentry_mode",

"car_trunk_rear",
"car_trunk_front"
"car_trunk_front",

"car_user_present"
],
"energy": {
"batteries": [
Expand Down

0 comments on commit 4719abc

Please sign in to comment.