# Node-red-contrib-tesla setScheduldedDeparture: TypeError: tjs.setScheduledDepartureAsync is not a function

**URL:** <https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942>\
**Category:** General\
**Created:** [7 February 2022 17:53 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942 "2022-02-07T17:53:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MAK](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MAK](https://discourse.nodered.org/u/MAK)\
**Post date:** [7 February 2022 17:53 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/1 "2022-02-07T17:53:48Z")

</div>

Hi, I'm building a simple solution to turn on ScheduledDeparture for one day only (which the Tesla app cannot do).

flow is simple: setScheduledDeparture on, wait for next day, setScheduledDeparture off

My problem: the tesla node throws

```auto
TypeError: tjs.setScheduledDepartureAsync is not a function

```

My setup:

- the node is configured, selected command is " setScheduledDeparture".
- I inject this message

```auto
{"_msgid":"c7e5c2b645ea2f52",
"payload":1644252929966,
"topic":"",
"commandArgs":{
     "enable":true,
     "departure_time":420,
     "preconditioning_enabled":true,
     "preconditioning_weekdays_only":false,
     "off_peak_charging_enabled":false,
     "off_peak_charging_weekdays_only":false,
     "end_off_peak_time":360
     }
}

```

- I also tried with only one commandArgs: "enable", still not working, same error
- I also tried with no commandArgs and get another error: "TypeError: Cannot read property 'enable' of undefined" (which is expected)
- every other tesla node (eg setChargeLimit) is working
- car is awake

Any hint where to start debugging?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [7 February 2022 18:14 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/2 "2022-02-07T18:14:13Z")

</div>

Are you using the latest version of this node?

---

<div class="post-metadata">

**Author:** ![MAK](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MAK](https://discourse.nodered.org/u/MAK)\
**Post date:** [7 February 2022 20:35 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/3 "2022-02-07T20:35:24Z")

</div>

node-red-contrib-tesla 2.0.0 on node red 2.1.5

---

<div class="post-metadata">

**Author:** ![MAK](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MAK](https://discourse.nodered.org/u/MAK)\
**Post date:** [8 February 2022 19:44 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/4 "2022-02-08T19:44:58Z")

</div>

Can anyone please confirm that the node is working with setScheduledDeparture and post a working json for the parameter?

Thanks

---

<div class="post-metadata">

**Author:** ![m661](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@m661](https://discourse.nodered.org/u/m661)\
**Post date:** [8 February 2022 22:34 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/5 "2022-02-08T22:34:54Z")

</div>

Hi @MAK

I tried just with enable, and it is not working for me. I also tried the same command with setScheduledCharging, and it is working.

Using version 2.0 and Nodered 2.1.4

Mario

---

<div class="post-metadata">

**Author:** ![MAK](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MAK](https://discourse.nodered.org/u/MAK)\
**Post date:** [8 February 2022 23:31 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/6 "2022-02-08T23:31:15Z")

</div>

Thanks for confirming. I created an issue on Github.

> <https://github.com/onokje/node-red-contrib-tesla/issues/43>
>
> Hi, I'm building a simple solution to turn on ScheduledDeparture for one day onl…y (which the Tesla app cannot do).
> My flow is a simple one: setScheduledDeparture on, wait for next day 11pm , setScheduledDeparture off
> 
> My problem: I can't get the Command setScheduledDeparture to work. The node throws
> \`TypeError: tjs.setScheduledDepartureAsync is not a function\`
> 
> My setup:
> 
> \- the node is configured, selected command is " setScheduledDeparture".
> \- I inject this message
> \`\`\`
> {"\_msgid":"c7e5c2b645ea2f52",
> "payload":1644252929966,
> "topic":"",
> "commandArgs":{
> "enable":true,
> "departure\_time":420,
> "preconditioning\_enabled":true,
> "preconditioning\_weekdays\_only":false,
> "off\_peak\_charging\_enabled":false,
> "off\_peak\_charging\_weekdays\_only":false,
> "end\_off\_peak\_time":360
> }
> }
> \`\`\`
> \- I also tried with only one commandArgs: "enable", still not working, same error
> \- I also tried with no commandArgs and get another error: "TypeError: Cannot read property 'enable' of undefined" (which is expected)
> \- every other tesla node (eg setChargeLimit) is working
> \- car is awake
> 
> What would be a working json inject? Or is this a defect?

---

<div class="post-metadata">

**Author:** ![GaPhi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaphi/32/56094_2.png) [@GaPhi](https://discourse.nodered.org/u/GaPhi)\
**Post date:** [9 February 2022 10:58 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/7 "2022-02-09T10:58:12Z")

</div>

Use the compatible teslajs library I have updated (@gaphi/teslajs). The pull to the main branch is not available yet I think.

This command works perfectly as I use it every day with a much more complex logic (use my Google calendar events, electricity tariff, location of the car, day-off, state of the car, etc...)

---

<div class="post-metadata">

**Author:** ![MAK](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@MAK](https://discourse.nodered.org/u/MAK)\
**Post date:** [9 February 2022 23:15 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/8 "2022-02-09T23:15:17Z")

</div>

so I should use your node red node (1.0.6-0) instead of the regular (2.0.0)? Does it have auto-wakeup already?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 April 2022 23:16 UTC](https://discourse.nodered.org/t/node-red-contrib-tesla-setscheduldeddeparture-typeerror-tjs-setscheduleddepartureasync-is-not-a-function/57942/9 "2022-04-10T23:16:26Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
