This commit is contained in:
Paulus Schoutsen 2019-07-31 12:46:17 -07:00
parent 4de97abc3a
commit 0ccffc3e55
11 changed files with 54 additions and 42 deletions

View File

@ -144,8 +144,8 @@ class Data:
# pylint: disable=no-self-use
def hash_password(self, password: str, for_storage: bool = False) -> bytes:
"""Encode a password."""
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))
# type: bytes
hashed: bytes = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12))
if for_storage:
hashed = base64.b64encode(hashed)
return hashed

View File

@ -539,8 +539,7 @@ class CastDevice(MediaPlayerDevice):
self.media_status = None
self.media_status_received = None
self._dynamic_group_cast_info = None # type: ChromecastInfo
self._dynamic_group_cast = None
# type: Optional[pychromecast.Chromecast]
self._dynamic_group_cast = None # type: Optional[pychromecast.Chromecast]
self.dynamic_group_media_status = None
self.dynamic_group_media_status_received = None
self.mz_media_status = {}
@ -549,8 +548,9 @@ class CastDevice(MediaPlayerDevice):
self._available = False # type: bool
self._dynamic_group_available = False # type: bool
self._status_listener = None # type: Optional[CastStatusListener]
self._dynamic_group_status_listener = None
# type: Optional[DynamicGroupCastStatusListener]
self._dynamic_group_status_listener = (
None
) # type: Optional[DynamicGroupCastStatusListener]
self._add_remove_handler = None
self._del_remove_handler = None

View File

@ -61,11 +61,11 @@ SCHEMA_WS_HOOK_DELETE = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend(
_CLOUD_ERRORS = {
InvalidTrustedNetworks: (
500,
"Remote UI not compatible with 127.0.0.1/::1" " as a trusted network.",
"Remote UI not compatible with 127.0.0.1/::1 as a trusted network.",
),
InvalidTrustedProxies: (
500,
"Remote UI not compatible with 127.0.0.1/::1" " as trusted proxies.",
"Remote UI not compatible with 127.0.0.1/::1 as trusted proxies.",
),
}

View File

@ -678,7 +678,8 @@ class DarkSkySensor(Entity):
"temperature_high",
"apparent_temperature_high",
"temperature_max",
"apparent_temperature_max" "precip_accumulation",
"apparent_temperature_max",
"precip_accumulation",
"pressure",
"ozone",
"uvIndex",

View File

@ -200,8 +200,10 @@ class EvoBroker:
return False
self.tcs = (
client.locations[loc_idx]._gateways[0]._control_systems[0]
) # noqa: E501; pylint: disable=protected-access
client.locations[loc_idx] # noqa: E501; pylint: disable=protected-access
._gateways[0]
._control_systems[0]
)
_LOGGER.debug("Config = %s", self.config)
if _LOGGER.isEnabledFor(logging.DEBUG):

View File

@ -175,9 +175,8 @@ class EvoClimateDevice(EvoDevice, ClimateDevice):
def _set_tcs_mode(self, op_mode: str) -> None:
"""Set the Controller to any of its native EVO_* operating modes."""
try:
self._evo_tcs._set_status(
op_mode
) # noqa: E501; pylint: disable=protected-access
# noqa: E501; pylint: disable=protected-access
self._evo_tcs._set_status(op_mode)
except (
requests.exceptions.RequestException,
evohomeclient2.AuthenticationError,

View File

@ -49,11 +49,15 @@ async def async_setup(hass, hass_config):
return False
_LOGGER.debug(
"zones_raw = %s", data._client.hub._zones_raw
) # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
"zones_raw = %s",
data._client.hub._zones_raw,
)
_LOGGER.debug(
"devices_raw = %s", data._client.hub._devices_raw
) # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
"devices_raw = %s",
data._client.hub._devices_raw,
)
async_track_time_interval(hass, data.async_update, SCAN_INTERVAL)
@ -90,10 +94,14 @@ class GeniusData:
return
_LOGGER.debug(
"zones_raw = %s", self._client.hub._zones_raw
) # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
"zones_raw = %s",
self._client.hub._zones_raw,
)
_LOGGER.debug(
"devices_raw = %s", self._client.hub._devices_raw
) # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
"devices_raw = %s",
self._client.hub._devices_raw,
)
async_dispatcher_send(self._hass, DOMAIN)

View File

@ -67,9 +67,8 @@ class GeniusBinarySensor(BinarySensorDevice):
attrs = {}
attrs["assigned_zone"] = self._device.assignedZones[0]["name"]
last_comms = self._device._raw_json["childValues"]["lastComms"][
"val"
] # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
last_comms = self._device._raw_json["childValues"]["lastComms"]["val"]
if last_comms != 0:
attrs["last_comms"] = utc_from_timestamp(last_comms).isoformat()

View File

@ -62,9 +62,8 @@ class GeniusDevice(Entity):
@property
def icon(self):
"""Return the icon of the sensor."""
values = self._device._raw_json[
"childValues"
] # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
values = self._device._raw_json["childValues"]
last_comms = utc_from_timestamp(values["lastComms"]["val"])
if "WakeUp_Interval" in values:
@ -114,9 +113,8 @@ class GeniusDevice(Entity):
attrs = {}
attrs["assigned_zone"] = self._device.assignedZones[0]["name"]
last_comms = self._device._raw_json["childValues"]["lastComms"][
"val"
] # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
last_comms = self._device._raw_json["childValues"]["lastComms"]["val"]
attrs["last_comms"] = utc_from_timestamp(last_comms).isoformat()
return {**attrs}

View File

@ -161,8 +161,10 @@ class HoneywellUSThermostat(ClimateDevice):
self._password = password
_LOGGER.debug(
"latestData = %s ", device._data
) # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
"latestData = %s ",
device._data,
)
# not all honeywell HVACs support all modes
mappings = [v for k, v in HVAC_MODE_TO_HW_MODE.items() if device.raw_ui_data[k]]
@ -174,9 +176,8 @@ class HoneywellUSThermostat(ClimateDevice):
| SUPPORT_TARGET_TEMPERATURE_RANGE
)
if device._data[
"canControlHumidification"
]: # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
if device._data["canControlHumidification"]:
self._supported_features |= SUPPORT_TARGET_HUMIDITY
if device.raw_ui_data["SwitchEmergencyHeatAllowed"]:
@ -464,5 +465,7 @@ class HoneywellUSThermostat(ClimateDevice):
_LOGGER.error("SomeComfort update failed, Retrying - Error: %s", exp)
_LOGGER.debug(
"latestData = %s ", self._device._data
) # noqa; pylint: disable=protected-access
# noqa; pylint: disable=protected-access
"latestData = %s ",
self._device._data,
)

View File

@ -51,8 +51,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
token = auth.get_token(email, password)
except requests.exceptions.HTTPError as http_error:
if (
http_error.response.status_code == requests.codes.unauthorized
): # pylint: disable=no-member
http_error.response.status_code
== requests.codes.unauthorized # pylint: disable=no-member
):
_LOGGER.error("Invalid credentials")
return
@ -115,8 +116,9 @@ class TankUtilitySensor(Entity):
data = device.get_device_data(self._token, self.device)
except requests.exceptions.HTTPError as http_error:
if (
http_error.response.status_code == requests.codes.unauthorized
): # pylint: disable=no-member
http_error.response.status_code
== requests.codes.unauthorized # pylint: disable=no-member
):
_LOGGER.info("Getting new token")
self._token = auth.get_token(self._email, self._password, force=True)
data = device.get_device_data(self._token, self.device)