Skip to content

Commit

Permalink
Merge pull request #220 from itchannel/1.38
Browse files Browse the repository at this point in the history
1.38
  • Loading branch information
itchannel authored Nov 30, 2022
2 parents f360be2 + 0e1683f commit f4f8dd6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 26 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/combined.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ on:
schedule:
- cron: '0 0 * * *'
jobs:
ci:
runs-on: ubuntu-latest
hacs:
runs-on: "ubuntu-latest"
name: HACS
steps:
- uses: actions/checkout@v2
name: Download repo
- name: Check out the repository
uses: "actions/[email protected]"

- name: HACS validation
uses: "hacs/[email protected]"
with:
fetch-depth: 0
- uses: actions/setup-python@v2
name: Setup Python
- uses: actions/cache@v2
name: Cache
with:
path: |
~/.cache/pip
key: custom-component-ci
- uses: hacs/action@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CATEGORY: integration
category: "integration"

hassfest:
runs-on: "ubuntu-latest"
name: Hassfest
steps:
- name: Check out the repository
uses: "actions/[email protected]"

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ If you are experiencing any sign in issues, please trying clearing your tokens u
## Coming Soon

- Next service due

## Disclaimer

This integration is not officially supported by Ford and as such using this integration could result in your account being locked out!
14 changes: 10 additions & 4 deletions custom_components/fordpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
REGION,
VEHICLE,
VIN,
UPDATE_INTERVAL,
UPDATE_INTERVAL_DEFAULT
)
from .fordpass_new import Vehicle

Expand All @@ -34,7 +36,6 @@

_LOGGER = logging.getLogger(__name__)

SCAN_INTERVAL = timedelta(seconds=300)


async def async_setup(hass: HomeAssistant, config: dict):
Expand All @@ -48,6 +49,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
user = entry.data[CONF_USERNAME]
password = entry.data[CONF_PASSWORD]
vin = entry.data[VIN]
if UPDATE_INTERVAL in entry.options:
update_interval = entry.options[UPDATE_INTERVAL]
else:
update_interval = UPDATE_INTERVAL_DEFAULT
_LOGGER.debug(update_interval)
for ar in entry.data:
_LOGGER.debug(ar)
if REGION in entry.data.keys():
Expand All @@ -56,7 +62,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
else:
_LOGGER.debug("CANT GET REGION")
region = "North America & Canada"
coordinator = FordPassDataUpdateCoordinator(hass, user, password, vin, region, 1)
coordinator = FordPassDataUpdateCoordinator(hass, user, password, vin, region, update_interval, 1)

await coordinator.async_refresh() # Get initial data

Expand Down Expand Up @@ -144,7 +150,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
class FordPassDataUpdateCoordinator(DataUpdateCoordinator):
"""DataUpdateCoordinator to handle fetching new data about the vehicle."""

def __init__(self, hass, user, password, vin, region, saveToken=False):
def __init__(self, hass, user, password, vin, region, update_interval, saveToken=False):
"""Initialize the coordinator and set up the Vehicle object."""
self._hass = hass
self.vin = vin
Expand All @@ -156,7 +162,7 @@ def __init__(self, hass, user, password, vin, region, saveToken=False):
hass,
_LOGGER,
name=DOMAIN,
update_interval=SCAN_INTERVAL,
update_interval=timedelta(seconds=update_interval),
)

async def _async_update_data(self):
Expand Down
8 changes: 8 additions & 0 deletions custom_components/fordpass/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
REGION,
REGION_OPTIONS,
VIN,
UPDATE_INTERVAL,
UPDATE_INTERVAL_DEFAULT
)
from .fordpass_new import Vehicle

Expand Down Expand Up @@ -118,6 +120,12 @@ async def async_step_init(self, user_input=None):
CONF_DISTANCE_UNIT, DEFAULT_DISTANCE_UNIT
),
): vol.In(DISTANCE_UNITS),
vol.Optional(
UPDATE_INTERVAL,
default=self.config_entry.options.get(
UPDATE_INTERVAL, UPDATE_INTERVAL_DEFAULT
),
): int,
}

return self.async_show_form(step_id="init", data_schema=vol.Schema(options))
Expand Down
3 changes: 3 additions & 0 deletions custom_components/fordpass/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
PRESSURE_UNITS = ["PSI", "kPa"]
DISTANCE_UNITS = ["mi", "km"]

UPDATE_INTERVAL = "update_interval"
UPDATE_INTERVAL_DEFAULT = 900


REGION = "region"

Expand Down
2 changes: 1 addition & 1 deletion custom_components/fordpass/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://github.com/itchannel/fordpass-ha",
"issue_tracker": "https://github.com/itchannel/fordpass-ha/issues",
"version": "0.1.37",
"version": "0.1.38",
"requirements": [],
"ssdp": [],
"zeroconf": [],
Expand Down
3 changes: 2 additions & 1 deletion custom_components/fordpass/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"init": {
"data": {
"pressure_unit": "Unit of Pressure",
"distance_unit": "Unit of Distance"
"distance_unit": "Unit of Distance",
"update_interval": "Interval to poll Fordpass API (Seconds)"
},
"description": "Configure fordpass options"
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/fordpass/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"init": {
"data": {
"pressure_unit": "Unit of Pressure",
"distance_unit": "Unit of Distance"
"distance_unit": "Unit of Distance",
"update_interval": "Interval to poll Fordpass API (Seconds)"
},
"description": "Configure fordpass options"
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/fordpass/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"init": {
"data": {
"pressure_unit": "Unité de pression",
"distance_unit": "Unité de distance"
"distance_unit": "Unité de distance",
"update_interval": "Intervalle pour interroger l'API Fordpass (secondes)"
},
"description": "Configuration de Fordpass"
}
Expand Down
3 changes: 2 additions & 1 deletion custom_components/fordpass/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"init": {
"data": {
"pressure_unit": "Eenheid voor luchtdruk",
"distance_unit": "Eenheid voor afstand"
"distance_unit": "Eenheid voor afstand",
"update_interval": "Interval om Fordpass API te peilen (seconden)"
},
"description": "Instellingen FordPass"
}
Expand Down
3 changes: 3 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

## **Changelog**
### Version 1.38
- Changed the default update interval from 5 minutes to 15 minutes (Reduce Ford API Requests)
- Add ability to change this interval in integration options (WARNING! setting this too low will result in your Fordpass account being locked!!!!)
### Version 1.37
- Update messages icon to new format
### Version 1.36
Expand Down

0 comments on commit f4f8dd6

Please sign in to comment.