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

[FR] Ability to set departure times from HA #352

Closed
JBoye opened this issue Jan 21, 2022 · 28 comments · Fixed by #395
Closed

[FR] Ability to set departure times from HA #352

JBoye opened this issue Jan 21, 2022 · 28 comments · Fixed by #395
Labels
enhancement New feature or request

Comments

@JBoye
Copy link

JBoye commented Jan 21, 2022

Is your feature request related to a problem? Please describe.

Currently, it is not possible to see or enabled/disable Departure times in Home Assistant.

Describe the solution you'd like

I want to enable or disable Departure Time 1/2/3 and possibly change the date/time for next departure, according to Home Assistant sensors

Describe alternatives you've considered

Alternatives is keep using the VW app, or trigger charging and air conditioning at a specific time before, but that will not show on the car UI

Additional context

IMG_DB89BD8607E0-1
IMG_DB89BD8607E0-2

@JBoye JBoye added the enhancement New feature or request label Jan 21, 2022
@tubalainen
Copy link
Collaborator

Yes please <3

@milkboy
Copy link
Collaborator

milkboy commented Feb 19, 2022

The underlying library does not (yet?) support this..

@milkboy
Copy link
Collaborator

milkboy commented Feb 19, 2022

But I started looking into if it would be easy enough to implement

@milkboy
Copy link
Collaborator

milkboy commented Feb 20, 2022

Just realized that if we want to be able to edit multiple attributes for a timer (or many timers), HA would by default send one update to the car / changed attribute.. I have "something" working now (read-only though still), but need to figure out the update procedure.. Don't want to waste 10 requests for changing 2 schedules

@milkboy
Copy link
Collaborator

milkboy commented Feb 20, 2022

Small teaser:

2022-02-20 14:51:56 DEBUG (MainThread) [volkswagencarnet.vw_dashboard] WVWZZZAUZFW000000 Charging is supported
2022-02-20 14:55:07 DEBUG (MainThread) [volkswagencarnet.vw_dashboard] WVWZZZAUZFW000000 Departure Schedule 1 is supported
2022-02-20 14:55:08 DEBUG (MainThread) [volkswagencarnet.vw_dashboard] WVWZZZAUZFW000000 Departure Schedule 2 is supported
2022-02-20 14:55:08 DEBUG (MainThread) [volkswagencarnet.vw_dashboard] WVWZZZAUZFW000000 Departure Schedule 3 is supported
2022-02-20 14:55:09 DEBUG (MainThread) [volkswagencarnet.vw_dashboard] WVWZZZAUZFW000000 Request results is supported
2022-02-20 14:55:10 DEBUG (MainThread) [volkswagencarnet.vw_dashboard] WVWZZZAUZFW000000 Odometer is supported

image

@milkboy
Copy link
Collaborator

milkboy commented Feb 20, 2022

okay. managed to actually get it working. departure timers 1..3 can be turned on and off from HA. The only problem seems to be that the new devices are not automatically detected, and I had to remove and re-add the integration for them to show up.. @robinostlund halp!? Is there some magic trick to reconfigure the selected sensors etc for this integration without having to set it up from scratch?

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

Ookay.. Got something working (for my e-Golf that is).. Will still need to add a service for updating the actual data for the schedules, but it should not be too hard. Just need a little bit of spare time 🤔

Also need to figure out how to present that schedule data in HA, unless just having the attributes in the switch is "fine"..
image
image

timers-2022-02-24_00.37.34.mp4

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

It's alive!!!

image
image
image

@robinostlund
Copy link
Owner

Damn, nice work @milkboy :)

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

Not sure which all combinations are working, or if something is not working.. Ran out of requests, and won't be able to continue until someone digs out the car from the huge pile if snow.

image

@milkboy milkboy mentioned this issue Feb 24, 2022
4 tasks
@JBoye
Copy link
Author

JBoye commented Feb 24, 2022

Fantastic! How can i test it?

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

Fantastic! How can i test it?

well.. uhm... until there is an official (alpha/beta) release, you'd need to get the sources from 'timerprogramming" branches in both the lib and HA repositories and install the needed files in the correct places 😒

You might want to make sure to have proper backups before trying that though 😉

Anyway, I'm about 80% sure that something will explode for PHEVs, as I suspect they have slightly differing data in the messages, but... 🤷

@JBoye
Copy link
Author

JBoye commented Feb 24, 2022

Haven't tried in HA yet, but this is my json using the lib

timer.txt

It looks very similar to https://github.com/robinostlund/volkswagencarnet/blob/timerprogramming/tests/fixtures/resources/responses/timer.json

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

hmm. yea. might need to fix those unnamed profiles :D Apparently they always exist in the response from the backend.
name == '' apparently means "I don't exist"

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

okay. pushed a new version that should not accidentally "create" the unused profiles when any change is saved again

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

Oh, and only made it possible to edit one schedule / request for now. Not sure if there is a need to update many at the same time, and/or edit the profiles also. Maybe it's fine to just switch profile for a timer for now? I've not edited those at all since I switched to using a Node RED flow for deciding which hours to charge on (which is super nice with hourly spot prices on electricity).

In theory, the flow could maybe use 1-3 departure schedules as needed, and update the contiguous off-peak (aka cheap) hours to the location for each schedule, and thus "waste" only a single request to the car, but it's maybe overdoing it slightly 😆

@JBoye
Copy link
Author

JBoye commented Feb 24, 2022

Got this working in a dev environment

image

@milkboy
Copy link
Collaborator

milkboy commented Feb 24, 2022

used these in dev env to visualize the attributes

type: entities
entities:
  - type: attribute
    name: Departure time
    entity: switch.test1_departure_schedule_1
    attribute: departure_time
    icon: mdi:calendar-clock
  - type: attribute
    name: Timer ID
    entity: switch.test1_departure_schedule_1
    attribute: timer_id
  - type: attribute
    name: Profile ID
    entity: switch.test1_departure_schedule_1
    attribute: profile_id
  - type: attribute
    name: Frequency
    entity: switch.test1_departure_schedule_1
    attribute: frequency
    icon: mdi:calendar-sync
  - type: attribute
    name: Weekday mask
    entity: switch.test1_departure_schedule_1
    attribute: weekday_mask
    icon: mdi:calendar-range
title: Schedule 1

and

type: entities
entities:
  - type: attribute
    name: Departure time
    entity: switch.test1_departure_schedule_2
    attribute: departure_time
    icon: mdi:calendar-clock
  - type: attribute
    name: Timer ID
    entity: switch.test1_departure_schedule_2
    attribute: timer_id
  - type: attribute
    name: Frequency
    entity: switch.test1_departure_schedule_2
    attribute: frequency
    icon: mdi:calendar
title: Schedule 2

might need a custom card or something though, as the content depends on the frequency.. oh, and the services are easily callable from the developer ui, both using yaml and UI http://localhost:8123/developer-tools/service

@JBoye
Copy link
Author

JBoye commented Feb 24, 2022

My main goal was to set the next departure time, based on different sensors and calendars that i already have running in HA

This works perfectly

Screenshot 2022-02-24 at 23 01 33

Next on my wishing list would be to call a service to set nightRate on timerProfile (and other profile settings)

@milkboy
Copy link
Collaborator

milkboy commented Feb 25, 2022

Something like this?
image

@milkboy
Copy link
Collaborator

milkboy commented Feb 25, 2022

Should be possible to make it slightly smarter by importing the profiles also as entities, instead of just using the numeric id, but 🤷

@JBoye
Copy link
Author

JBoye commented Feb 25, 2022

Yes exactly! I love it 👍

My car has 5, 10, 13 and Max in charge values

This also solves this issue: robinostlund/volkswagencarnet#13

@milkboy
Copy link
Collaborator

milkboy commented Feb 25, 2022

Yes exactly! I love it +1

My car has 5, 10, 13 and Max in charge values

This also solves this issue: robinostlund/volkswagencarnet#13

Arf. The charge currents are a bit tricky 🤔

Anyway, there is a "global" max current setting, and then there is a setting / charging profile. Never checked how the logic works of there are multiple charging profiles active.. Is it the "next" departure time that selects which profile to use? Anyway, if no departure timer is active, I guess the "global" value is used.. But what if the global one is say 10, and you try to use 16 in a profile? So many questions 😆

@JBoye
Copy link
Author

JBoye commented Feb 25, 2022

I think that the global setting is used when charging is started manually and the profile is used when it's started by a timer

@milkboy
Copy link
Collaborator

milkboy commented Feb 25, 2022

I think that the global setting is used when charging is started manually and the profile is used when it's started by a timer

That would make sense 🙈

@milkboy
Copy link
Collaborator

milkboy commented Feb 25, 2022

Regarding robinostlund/volkswagencarnet#13, I added a service for setting that value also 🥳

There might be some rough edges though, as I've not tested either that or the profile changing with my car 😉

@JBoye
Copy link
Author

JBoye commented Feb 26, 2022

Fantastic! How can i test it?

well.. uhm... until there is an official (alpha/beta) release, you'd need to get the sources from 'timerprogramming" branches in both the lib and HA repositories and install the needed files in the correct places 😒

I got it working on a dev environment, but I can't figure out how to install the lib in my main HA. Do you think it would be possible to release a beta soon?

@milkboy
Copy link
Collaborator

milkboy commented Feb 28, 2022

There is a beta version available now (well, 4th try on getting it more or less correct). Normal "works for me, but might blow up your installation, so please make backups"-clause applies. Also, it's very likely that there are some cars it won't (yet) work with, and also note that not all options are available for all cars. If the app is not showing a setting, then it's probably not possible to set the value for it (BEVs don't have the option to use auxiliary heater etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants