2020-03-23 16:01:48 +00:00
|
|
|
"""Utils for Nexia / Trane XL Thermostats."""
|
|
|
|
|
2021-10-23 18:56:30 +00:00
|
|
|
from http import HTTPStatus
|
2020-09-04 14:54:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
def is_invalid_auth_code(http_status_code):
|
|
|
|
"""HTTP status codes that mean invalid auth."""
|
2021-10-23 18:56:30 +00:00
|
|
|
if http_status_code in (HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN):
|
2020-09-04 14:54:27 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
2020-03-23 16:01:48 +00:00
|
|
|
|
|
|
|
def percent_conv(val):
|
|
|
|
"""Convert an actual percentage (0.0-1.0) to 0-100 scale."""
|
2021-04-10 10:42:42 +00:00
|
|
|
if val is None:
|
|
|
|
return None
|
2020-03-23 16:01:48 +00:00
|
|
|
return round(val * 100.0, 1)
|