Skip to content

Commit

Permalink
Fix sensor to use native unit of measurement and improve reauth flow
Browse files Browse the repository at this point in the history
  • Loading branch information
natekspencer committed May 17, 2022
1 parent b1ca362 commit 35a7984
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion custom_components/vivint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except (VivintSkyApiMfaRequiredError, VivintSkyApiAuthenticationError) as ex:
raise ConfigEntryAuthFailed(ex) from ex
except (VivintSkyApiError, ClientResponseError, ClientConnectorError) as ex:
raise ConfigEntryNotReady from ex
raise ConfigEntryNotReady(ex) from ex

dev_reg = await device_registry.async_get_registry(hass)

Expand Down
4 changes: 2 additions & 2 deletions custom_components/vivint/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ async def _async_create_entry(self) -> FlowResult:
CONF_PASSWORD: self._hub._data[CONF_PASSWORD],
}

await self._hub.disconnect()
if existing_entry:
self.hass.config_entries.async_update_entry(
existing_entry, data=config_data
)
await self.hass.config_entries.async_reload(existing_entry.entry_id)
return self.async_abort(reason="reauth_successful")

await self._hub.disconnect()
return self.async_create_entry(
title=config_data[CONF_USERNAME], data=config_data
)
Expand Down Expand Up @@ -143,7 +143,7 @@ async def async_step_reauth(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Perform reauth upon an API authentication error."""
return await self.async_step_reauth_confirm()
return await self.async_step_reauth_confirm(user_input)

async def async_step_reauth_confirm(
self, user_input: dict[str, Any] | None = None
Expand Down
16 changes: 5 additions & 11 deletions custom_components/vivint/manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
"domain": "vivint",
"name": "Vivint",
"version": "2022.4.0",
"version": "2022.5.0",
"config_flow": true,
"documentation": "https://github.com/natekspencer/hacs-vivint",
"issue_tracker": "https://github.com/natekspencer/hacs-vivint/issues",
"requirements": [
"vivintpy==2022.1.0"
],
"dependencies": [
"ffmpeg"
],
"codeowners": [
"@natekspencer"
]
}
"requirements": ["vivintpy==2022.1.0"],
"dependencies": ["ffmpeg"],
"codeowners": ["@natekspencer"]
}
2 changes: 1 addition & 1 deletion custom_components/vivint/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class VivintBatterySensorEntity(VivintEntity, SensorEntity):

_attr_device_class = SensorDeviceClass.BATTERY
_attr_entity_category = EntityCategory.DIAGNOSTIC
_attr_unit_of_measurement = PERCENTAGE
_attr_native_unit_of_measurement = PERCENTAGE

@property
def name(self) -> str:
Expand Down

0 comments on commit 35a7984

Please sign in to comment.