G-Two / homeassistant-subaru

Subaru STARLINK custom component for Home Assistant.
Apache License 2.0
54 stars 7 forks source link

Feature Request: Option to enable vehicle polling only while charging #50

Closed ianwestcott closed 2 years ago

ianwestcott commented 2 years ago

Currently the option to poll the vehicle for new information has two settings: Poll every 2 hours, or disabled. Given the caveat about frequent polling potentially draining the 12V battery, it makes sense that this is disabled by default.

When charging a plug-in hybrid vehicle, it's useful to poll more frequently in order to display the charging status in Home Assistant. This can be accomplished with the following automation:

# request vehicle data updates from Subaru while charging
---
alias: 'Request Subaru data updates while charging'
trigger:
  - platform: time_pattern
    minutes: "/30"
condition:
  - condition: state
    entity_id: binary_sensor.subaru_ev_battery_charging
    state: 'on'
action:
  - service: button.press
    data:
      entity_id: button.subaru_locate

However, I suspect writing such an automation may not be intuitive to many users, since it requires pressing the "Locate" button". It would be nice if this functionality was instead presented to the user as a third polling option—"Poll only while charging"—which will poll at a 30-minute interval any time the battery charging state is on.

stboch commented 2 years ago

The only concern I have is having too many pollings will look abnormal and might lead to accounts flagged for abuse. We haven't seen this so far but it is possible. BTW your automation is basically the same function, poll on the backend is locate.

G-Two commented 2 years ago

@ianwestcott I'll try to add an option at some point. I think a 30 minute interval during charging will be fine. When I started writing this integration, I accidentally hammered my car every minute for a day, and I never got blocked (but my 12V battery did get fully depleted).

I'll probably rename things in v0.7.0 to make them more intuitive.

G-Two commented 2 years ago

@ianwestcott I've added this feature in v0.6.3rc1. Please give it a try and let me know if it works for you. See updated README

ianwestcott commented 1 year ago

@G-Two I finally had time to update my installation, so I'll be trying this feature out soon. Thank you for implementing it!