mirror of
https://github.com/USA-RedDragon/badnest.git
synced 2025-01-18 23:10:42 +00:00
Fixup flake8 violations
This commit is contained in:
parent
14d2e08c3f
commit
8d022bd746
@ -19,6 +19,7 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
"""Set up the asuswrt component."""
|
||||
if config.get(DOMAIN) is not None:
|
||||
|
@ -1,10 +1,8 @@
|
||||
from datetime import time, timedelta, datetime
|
||||
import json
|
||||
|
||||
import requests
|
||||
|
||||
API_URL = 'https://home.nest.com'
|
||||
|
||||
|
||||
class NestAPI():
|
||||
def __init__(self, email, password):
|
||||
self._user_id = None
|
||||
@ -50,7 +48,8 @@ class NestAPI():
|
||||
return 'off'
|
||||
|
||||
def update(self):
|
||||
r = requests.post(f'{API_URL}/api/0.1/user/{self._user_id}/app_launch', json={
|
||||
r = requests.post(f'{API_URL}/api/0.1/user/{self._user_id}/app_launch',
|
||||
json={
|
||||
'known_bucket_types': ['shared', 'device'],
|
||||
'known_bucket_versions': []
|
||||
},
|
||||
@ -64,15 +63,21 @@ class NestAPI():
|
||||
if bucket['object_key'].startswith('shared.'):
|
||||
self._shared_id = bucket['object_key']
|
||||
thermostat_data = bucket['value']
|
||||
self.current_temperature = thermostat_data['current_temperature']
|
||||
self.target_temperature = thermostat_data['target_temperature']
|
||||
self._compressor_lockout_enabled = thermostat_data['compressor_lockout_enabled']
|
||||
self._compressor_lockout_time = thermostat_data['compressor_lockout_timeout']
|
||||
self.current_temperature = \
|
||||
thermostat_data['current_temperature']
|
||||
self.target_temperature = \
|
||||
thermostat_data['target_temperature']
|
||||
self._compressor_lockout_enabled = \
|
||||
thermostat_data['compressor_lockout_enabled']
|
||||
self._compressor_lockout_time = \
|
||||
thermostat_data['compressor_lockout_timeout']
|
||||
self._hvac_ac_state = thermostat_data['hvac_ac_state']
|
||||
self._hvac_heater_state = thermostat_data['hvac_heater_state']
|
||||
self.mode = thermostat_data['target_temperature_type']
|
||||
self.target_temperature_high = thermostat_data['target_temperature_high']
|
||||
self.target_temperature_low = thermostat_data['target_temperature_low']
|
||||
self.target_temperature_high = \
|
||||
thermostat_data['target_temperature_high']
|
||||
self.target_temperature_low = \
|
||||
thermostat_data['target_temperature_low']
|
||||
self.can_heat = thermostat_data['can_heat']
|
||||
self.can_cool = thermostat_data['can_cool']
|
||||
elif bucket['object_key'].startswith('device.'):
|
||||
@ -85,13 +90,14 @@ class NestAPI():
|
||||
self.current_humidity = thermostat_data['current_humidity']
|
||||
self.away = thermostat_data['home_away_input']
|
||||
|
||||
def set_temp(self, temp, temp_high = None):
|
||||
def set_temp(self, temp, temp_high=None):
|
||||
if temp_high is None:
|
||||
requests.post(f'{self._czfe_url}/v5/put', json={
|
||||
requests.post(f'{self._czfe_url}/v5/put',
|
||||
json={
|
||||
'objects': [{
|
||||
'object_key': self._shared_id,
|
||||
'op': 'MERGE',
|
||||
'value':{
|
||||
'value': {
|
||||
'target_temperature': temp
|
||||
}
|
||||
}]
|
||||
@ -100,7 +106,8 @@ class NestAPI():
|
||||
'Authorization': f'Basic {self._access_token}'
|
||||
})
|
||||
else:
|
||||
requests.post(f'{self._czfe_url}/v5/put', json={
|
||||
requests.post(f'{self._czfe_url}/v5/put',
|
||||
json={
|
||||
'objects': [{
|
||||
'object_key': self._shared_id,
|
||||
'op': 'MERGE',
|
||||
@ -114,13 +121,13 @@ class NestAPI():
|
||||
'Authorization': f'Basic {self._access_token}'
|
||||
})
|
||||
|
||||
|
||||
def set_mode(self, mode):
|
||||
requests.post(f'{self._czfe_url}/v5/put', json={
|
||||
requests.post(f'{self._czfe_url}/v5/put',
|
||||
json={
|
||||
'objects': [{
|
||||
'object_key': self._shared_id,
|
||||
'op': 'MERGE',
|
||||
'value':{
|
||||
'value': {
|
||||
'target_temperature_type': mode
|
||||
}
|
||||
}]
|
||||
@ -130,11 +137,12 @@ class NestAPI():
|
||||
})
|
||||
|
||||
def set_fan(self, date):
|
||||
requests.post(f'{self._czfe_url}/v5/put', json={
|
||||
requests.post(f'{self._czfe_url}/v5/put',
|
||||
json={
|
||||
'objects': [{
|
||||
'object_key': self._device_id,
|
||||
'op': 'MERGE',
|
||||
'value':{
|
||||
'value': {
|
||||
'fan_timer_timeout': date
|
||||
}
|
||||
}]
|
||||
@ -144,11 +152,12 @@ class NestAPI():
|
||||
})
|
||||
|
||||
def set_eco_mode(self):
|
||||
requests.post(f'{self._czfe_url}/v5/put', json={
|
||||
requests.post(f'{self._czfe_url}/v5/put',
|
||||
json={
|
||||
'objects': [{
|
||||
'object_key': self._device_id,
|
||||
'op': 'MERGE',
|
||||
'value':{
|
||||
'value': {
|
||||
'eco': {
|
||||
'mode': 'manual-eco'
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ from homeassistant.components.climate.const import (
|
||||
HVAC_MODE_COOL,
|
||||
HVAC_MODE_HEAT,
|
||||
HVAC_MODE_OFF,
|
||||
SUPPORT_PRESET_MODE,
|
||||
SUPPORT_FAN_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||
@ -22,9 +21,8 @@ from homeassistant.components.climate.const import (
|
||||
CURRENT_HVAC_IDLE,
|
||||
CURRENT_HVAC_COOL,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
|
||||
from .api import NestAPI
|
||||
from .const import DOMAIN
|
||||
|
||||
NEST_MODE_HEAT_COOL = "range"
|
||||
@ -52,6 +50,7 @@ PRESET_AWAY_AND_ECO = "Away and Eco"
|
||||
|
||||
PRESET_MODES = [PRESET_NONE, PRESET_AWAY, PRESET_ECO, PRESET_AWAY_AND_ECO]
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the Nest climate device."""
|
||||
add_entities(
|
||||
@ -71,7 +70,8 @@ class ShittyNestClimate(ClimateDevice):
|
||||
self._fan_modes = [FAN_ON, FAN_AUTO]
|
||||
|
||||
# Set the default supported features
|
||||
self._support_flags = SUPPORT_TARGET_TEMPERATURE #| SUPPORT_PRESET_MODE
|
||||
self._support_flags = SUPPORT_TARGET_TEMPERATURE
|
||||
# | SUPPORT_PRESET_MODE
|
||||
|
||||
# Not all nest devices support cooling and heating remove unused
|
||||
self._operation_list = []
|
||||
@ -80,7 +80,7 @@ class ShittyNestClimate(ClimateDevice):
|
||||
|
||||
if self.device.can_heat and self.device.can_cool:
|
||||
self._operation_list.append(HVAC_MODE_AUTO)
|
||||
self._support_flags = self._support_flags | SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
self._support_flags |= SUPPORT_TARGET_TEMPERATURE_RANGE
|
||||
|
||||
# Add supported nest thermostat features
|
||||
if self.device.can_heat:
|
||||
@ -131,7 +131,7 @@ class ShittyNestClimate(ClimateDevice):
|
||||
def target_temperature_high(self):
|
||||
"""Return the highbound target temperature we try to reach."""
|
||||
if self.device.mode == NEST_MODE_ECO:
|
||||
#TODO: Grab properly
|
||||
# TODO: Grab properly
|
||||
return None
|
||||
if self.device.mode == NEST_MODE_HEAT_COOL:
|
||||
return self.device.target_temperature_high
|
||||
@ -141,7 +141,7 @@ class ShittyNestClimate(ClimateDevice):
|
||||
def target_temperature_low(self):
|
||||
"""Return the lowbound target temperature we try to reach."""
|
||||
if self.device.mode == NEST_MODE_ECO:
|
||||
#TODO: Grab properly
|
||||
# TODO: Grab properly
|
||||
return None
|
||||
if self.device.mode == NEST_MODE_HEAT_COOL:
|
||||
return self.device.target_temperature_low
|
||||
@ -235,7 +235,7 @@ class ShittyNestClimate(ClimateDevice):
|
||||
|
||||
if is_away != need_away:
|
||||
pass
|
||||
#self.device.set_away()
|
||||
# self.device.set_away()
|
||||
|
||||
if is_eco != need_eco:
|
||||
if need_eco:
|
||||
@ -246,4 +246,3 @@ class ShittyNestClimate(ClimateDevice):
|
||||
def update(self):
|
||||
"""Updates data"""
|
||||
self.device.update()
|
||||
|
||||
|
@ -1 +1 @@
|
||||
DOMAIN='badnest'
|
||||
DOMAIN = 'badnest'
|
||||
|
Loading…
x
Reference in New Issue
Block a user