Upgrade PyISY to v2.1.0, add support for variable precision (#42043)

This commit is contained in:
shbatm 2020-10-18 11:45:15 -05:00 committed by GitHub
parent d96a1744f0
commit 941453dca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 10 deletions

View File

@ -156,7 +156,6 @@ async def async_setup_entry(
password=password, password=password,
use_https=https, use_https=https,
tls_ver=tls_version, tls_ver=tls_version,
log=_LOGGER,
webroot=host.path, webroot=host.path,
) )
) )

View File

@ -94,13 +94,12 @@ def _fetch_isy_configuration(
password, password,
use_https, use_https,
tls_ver, tls_ver,
log=_LOGGER,
webroot=webroot, webroot=webroot,
) )
except ValueError as err: except ValueError as err:
raise InvalidAuth(err.args[0]) from err raise InvalidAuth(err.args[0]) from err
return Configuration(log=_LOGGER, xml=isy_conn.get_config()) return Configuration(xml=isy_conn.get_config())
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):

View File

@ -402,7 +402,7 @@ async def migrate_old_unique_ids(
def convert_isy_value_to_hass( def convert_isy_value_to_hass(
value: Union[int, float, None], value: Union[int, float, None],
uom: str, uom: str,
precision: str, precision: Union[int, str],
fallback_precision: Optional[int] = None, fallback_precision: Optional[int] = None,
) -> Union[float, int]: ) -> Union[float, int]:
"""Fix ISY Reported Values. """Fix ISY Reported Values.
@ -418,7 +418,7 @@ def convert_isy_value_to_hass(
return None return None
if uom in [UOM_DOUBLE_TEMP, UOM_ISYV4_DEGREES]: if uom in [UOM_DOUBLE_TEMP, UOM_ISYV4_DEGREES]:
return round(float(value) / 2.0, 1) return round(float(value) / 2.0, 1)
if precision != "0": if precision not in ("0", 0):
return round(float(value) / 10 ** int(precision), int(precision)) return round(float(value) / 10 ** int(precision), int(precision))
if fallback_precision: if fallback_precision:
return round(float(value), fallback_precision) return round(float(value), fallback_precision)

View File

@ -2,7 +2,7 @@
"domain": "isy994", "domain": "isy994",
"name": "Universal Devices ISY994", "name": "Universal Devices ISY994",
"documentation": "https://www.home-assistant.io/integrations/isy994", "documentation": "https://www.home-assistant.io/integrations/isy994",
"requirements": ["pyisy==2.0.2"], "requirements": ["pyisy==2.1.0"],
"codeowners": ["@bdraco", "@shbatm"], "codeowners": ["@bdraco", "@shbatm"],
"config_flow": true, "config_flow": true,
"ssdp": [ "ssdp": [

View File

@ -106,12 +106,16 @@ class ISYSensorVariableEntity(ISYEntity):
@property @property
def state(self): def state(self):
"""Return the state of the variable.""" """Return the state of the variable."""
return self._node.status return convert_isy_value_to_hass(self._node.status, "", self._node.prec)
@property @property
def device_state_attributes(self) -> Dict: def device_state_attributes(self) -> Dict:
"""Get the state attributes for the device.""" """Get the state attributes for the device."""
return {"init_value": int(self._node.init)} return {
"init_value": convert_isy_value_to_hass(
self._node.init, "", self._node.prec
)
}
@property @property
def icon(self): def icon(self):

View File

@ -1451,7 +1451,7 @@ pyirishrail==0.0.2
pyiss==1.0.1 pyiss==1.0.1
# homeassistant.components.isy994 # homeassistant.components.isy994
pyisy==2.0.2 pyisy==2.1.0
# homeassistant.components.itach # homeassistant.components.itach
pyitachip2ir==0.0.7 pyitachip2ir==0.0.7

View File

@ -709,7 +709,7 @@ pyipp==0.11.0
pyiqvia==0.2.1 pyiqvia==0.2.1
# homeassistant.components.isy994 # homeassistant.components.isy994
pyisy==2.0.2 pyisy==2.1.0
# homeassistant.components.kira # homeassistant.components.kira
pykira==0.1.1 pykira==0.1.1