weixin_39705850
weixin_39705850
2020-11-28 13:07

[tesla] Allow vehicle to sleep to fix vampire drain

This is a bugfix that includes the following:

  1. This fixes the wake up of the vehicle once it did get to sleep, the command was sent to the wrong endpoint so the vehicle never woke up
  2. If allow wake up is set to false, the binding will stop polling the vehicle for updates once it detects that the vehicle is not charging and not on the move. After that, it will stop polling for 15 minutes to allow the vehicle to go to sleep. If the vehicle did not go to sleep in that period, it is polled again and the process starts over again.
  3. This also adds a new channel "force refresh" that can be used to forcefully refresh vehicle state even if the binding is in the process of trying to let the car go to sleep. I use this to update the states once my wife's or my phone have detected that they have an active bluetooth connection to the car (using taskr and the openhab rest api).

This saves about 4kWh/day for my tesla model S and makes it possible to park the vehicle at an airport for a week without arriving to a dead battery (or disabling the binding).

Also, the initial value for the allowWakeUp has been set to false, so a value restored from a mapdb or sth like this will then override that setting with true, if desired. Same applied for the event stream, we only start that once the setting changed to true. This is needed to not wake the vehicle on startup of openHAB.

Note: for now, if you want to avoid vampire drain, please disable allowWakeUp and the eventStream. Both cause the vehicle to be constantly awake. I'll address those things in a later change.

该提问来源于开源项目:openhab/openhab-addons

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

11条回答

  • weixin_39705850 weixin_39705850 5月前

    I think that's it for the first round, I'll do a second later where I plan to move all this power saving stuff to a separate channel that can be turned on or off.

    This would mean that you could allow the wake up of your car to do certain thing (i.e. set charge limit, start charging, honk the horn, whatever) and after that, the car would go to sleep again.

    Another thing that still needs work is the fact that during startup, my odometer and range items (basically everything related to imperial/metric units) change to miles. This causes data corruption for statistics and could be avoided by either having the units configurable in the thing configuration or waiting to update the states of those items until the unit configuration from the vehicle was read.

    I'll create a separate PR for those features once I get some additional time.

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    I think that's it for now, I'm not sure if I can remove the "work in progress" label myself.

    点赞 评论 复制链接分享
  • weixin_39576018 weixin_39576018 5月前

    May I ask you for a quick review?

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    Anything I can do to speed up this process?

    For me, my vehicles sleeps most of day now. Since receiving the V9 update (car is on 2018.46.2), it even stays asleep for over 24 hours now. Together with those "on bluetooth connected, force refresh"-rules, I also don't miss any drive data at all.

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    That was quick, thanks!

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    One thing I noticed tonight: The car seems to wake up after exactly one hour of sleep every hour. I'm not sure if it's detecting the keyfobs (altough passive entry is turned off, so it should not do that) or something else. Others seem to have had the same issue about a year ago, but no solution... https://teslamotorsclub.com/tmc/threads/waking-up-every-hour-or-so-at-night.104479/page-2

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    Ok, some more test results: Car wakes up almost exactly after 1 hour of sleep and then goes to sleep about 15 minutes after (it would probably go to sleep even faster, but the binding needs to check the drive/charging state to know if the vehicle has started to move, so that keeps it awake for at least 10 minutes).

    It seems to also wake up for a longer period of time after it slept for 6 hours (with those 15 minute breaks in between). Not sure if anyone else sees the same behavior as I, maybe they fixed this with a new firmware (I'm stuck on 34.1 for now)...

    Also, while the vehicle is attached to a charger, it goes to the state "asleep" whereas when parked somewhere without a charger attached, it goes to "offline" when sleeping.

    点赞 评论 复制链接分享
  • weixin_39771301 weixin_39771301 5月前

    I have added an Item and connected to the Channel "Allow Wake up" and I turn it off. but after every reboot or changes the setting goes back to "ON" state. Secondly, I still see the log that shows the events being captured so technically the car still never goes to sleep for me. if can guide me for any additional settings I need to enable for this to test properly let me know. thanks

    Log: 2018-11-15 15:50:22.567 [vent.ItemStateChangedEvent] - Falcon_ONE_Event_Timestamp changed from 2018-11-15T15:50:21.536-0500 to 2018-11-15T15:50:22.387-0500 This is after running for over 50 mins on a fresh reboot of Pi.

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    Thanks for the test. You might also need to disable the event stream by creating an item connected to the "Event stream" channel and turn that off. This will /not/ disable updates from the car, it just disables an event stream directly from the vehicle. For now, enabling this will prevent the car from going to sleep.

    Once I have the basics working (which I'm pretty close on my car, your car might behave differently), I'll add a power save option for the event stream as well.

    In case that does also not help, make sure that nothing else is polling the car and then please post a log with DEBUG turned on for the org.openhab.binding.tesla namespace. Also, what car do you have and which firmware?

    点赞 评论 复制链接分享
  • weixin_39771301 weixin_39771301 5月前

    I added an item for “Enable Events” and turned it off. Will report back what happens. Other than OpenHab instance and Tesla App i dont have anything polling the car. It is an AP 2 Model X with latest firmware (which I hate the UI btw!). How do I retain the item state for Enable Event and Allow Wake Up items after a restart?

    点赞 评论 复制链接分享
  • weixin_39705850 weixin_39705850 5月前

    Restoring the item state could be done by using the mapdb persistence plugin.

    点赞 评论 复制链接分享

相关推荐