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

Add services to Renault integration #18981

Merged
merged 4 commits into from
Sep 1, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions source/_integrations/renault.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,48 @@ You need two API keys: one for Gigya and one for Kamereon and they shouldn't be
{% include integrations/config_flow.md %}

All vehicles linked to the account should then get added as devices, with sensors added as linked entity.

## Services

### Service `renault.ac_start`

Start A/C on vehicle.

| Service data attribute | Required | Description | Example |
| ---------------------- | -------- | ----------- | ------- |
| `vehicle`| yes | device_id of the vehicle | |
| `temperature` | yes | Target A/C temperature in °C | |
| `when` | no | Timestamp for the start of the A/C (optional - defaults to now) | `2020-05-01T17:45:00` |

### Service `renault.ac_cancel`

Cancel A/C on vehicle.

| Service data attribute | Required | Description |
| ---------------------- | -------- | ----------- |
| `vehicle`| yes | device_id of the vehicle |

### Service `renault.charge_set_schedules`

Update charge schedule on vehicle.

| Service data attribute | Required | Description | Example |
| ---------------------- | -------- | ----------- | ------- |
| `vehicle`| yes | device_id of the vehicle |
| `schedules` | yes | Schedule details. Can be a single schedule or a list of schedules | `[{'id':1,'activated':true,'monday':{'startTime':'T12:00Z','duration':15}},<br>{'id':2,'activated':false,'monday':{'startTime':'T12:00Z','duration':240}}<br>]` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed in the preview that the br tag doesn't work.

https://deploy-preview-18981--home-assistant-docs.netlify.app/integrations/renault/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to generate a preview, but I've moved the example out of the grid to gain some space.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preview is generated automatically by the CI build. It's linked below among the PR checks.


Notes:

- `schedules` can be in the form `{'id':1,...}` when updating a single schedules, or in the form `[{'id':1,...},{'id':2,...},...]` when updating multiple schedules within the same call
- the `id` is compulsory on each `schedule` (should be 1 to 5 depending on the vehicle)
- the `activated` flag is an optional boolean. If it is not provided, then the existing flag will be kept as is.
- the `monday` to `sunday` elements are optional. If they are not provided, then the existing settings will be kept for each day. If they are provided as None, then the existing setting will be cleared. If a value is provided, it must conform to this format `{'startTime':'T12:00Z','duration':15}` where start time is in UTC format and the duration is in minutes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed now that we only validate the time string as string in the service schema. Could we use the time validator to help users use the correct time string?

https://github.com/home-assistant/core/blob/33fb080c1e7dc5db8e24cc142fd9b1972ef337f3/homeassistant/helpers/config_validation.py#L351-L364

Then we can format the final string from the returned datetime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CLI version of RenaultAPI has some validation/conversion built in: https://github.com/hacf-fr/renault-api/blob/7c2336c52ed0298a3ed2b8e7dbb77b839676dced/src/renault_api/cli/charge/schedule.py#L202

There is also a draft PR to add validation to the non-CLI version: hacf-fr/renault-api#157

There are some extra rules like the minutes of startTime needs to be in (00,15,30,45) and the total duration needs to be a multiple of 15 minutes (eg. 240 is valid but not 245)
There are also some overlap rules (Monday 23:45 for 120 minutes and Tuesday 00:15 for 30 minutes is invalid)

I'll have a go at a follow-up PR.

Copy link
Contributor Author

@epenet epenet Sep 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure when I'll get a chance to work on the new PR (there is also a request from @frenck to implement re-auth).
Should this documentation PR be merged anyway in the meantime?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! The docs are fine.


### Service `renault.charge_start`

Start charge on vehicle.

| Service data attribute | Required | Description |
| ---------------------- | -------- | ----------- |
| `vehicle`| yes | device_id of the vehicle |