mirror of
https://github.com/USA-RedDragon/badnest.git
synced 2025-09-08 18:01:52 +01:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
977c553a8d | ||
|
f1abecefce | ||
|
c7c011720c | ||
|
b4debfcf9c |
@@ -92,7 +92,6 @@ class NestThermostatAPI(NestAPI):
|
|||||||
self.can_cool = None
|
self.can_cool = None
|
||||||
self.has_fan = None
|
self.has_fan = None
|
||||||
self.fan = None
|
self.fan = None
|
||||||
self.away = None
|
|
||||||
self.current_temperature = None
|
self.current_temperature = None
|
||||||
self.target_temperature = None
|
self.target_temperature = None
|
||||||
self.target_temperature_high = None
|
self.target_temperature_high = None
|
||||||
@@ -137,6 +136,7 @@ class NestThermostatAPI(NestAPI):
|
|||||||
|
|
||||||
self._czfe_url = r.json()["service_urls"]["urls"]["czfe_url"]
|
self._czfe_url = r.json()["service_urls"]["urls"]["czfe_url"]
|
||||||
|
|
||||||
|
temp_mode = None
|
||||||
for bucket in r.json()["updated_buckets"]:
|
for bucket in r.json()["updated_buckets"]:
|
||||||
if bucket["object_key"].startswith(f"shared.{self._device_id}"):
|
if bucket["object_key"].startswith(f"shared.{self._device_id}"):
|
||||||
thermostat_data = bucket["value"]
|
thermostat_data = bucket["value"]
|
||||||
@@ -151,7 +151,7 @@ class NestThermostatAPI(NestAPI):
|
|||||||
]
|
]
|
||||||
self._hvac_ac_state = thermostat_data["hvac_ac_state"]
|
self._hvac_ac_state = thermostat_data["hvac_ac_state"]
|
||||||
self._hvac_heater_state = thermostat_data["hvac_heater_state"]
|
self._hvac_heater_state = thermostat_data["hvac_heater_state"]
|
||||||
self.mode = thermostat_data["target_temperature_type"]
|
temp_mode = thermostat_data["target_temperature_type"]
|
||||||
self.target_temperature_high = thermostat_data[
|
self.target_temperature_high = thermostat_data[
|
||||||
"target_temperature_high"
|
"target_temperature_high"
|
||||||
]
|
]
|
||||||
@@ -166,7 +166,9 @@ class NestThermostatAPI(NestAPI):
|
|||||||
self.has_fan = thermostat_data["has_fan"]
|
self.has_fan = thermostat_data["has_fan"]
|
||||||
self.fan = thermostat_data["fan_timer_timeout"] > 0
|
self.fan = thermostat_data["fan_timer_timeout"] > 0
|
||||||
self.current_humidity = thermostat_data["current_humidity"]
|
self.current_humidity = thermostat_data["current_humidity"]
|
||||||
self.away = thermostat_data["home_away_input"]
|
if thermostat_data["eco"]["mode"] == 'manual-eco':
|
||||||
|
temp_mode = 'eco'
|
||||||
|
self.mode = temp_mode
|
||||||
|
|
||||||
def set_temp(self, temp, temp_high=None):
|
def set_temp(self, temp, temp_high=None):
|
||||||
if temp_high is None:
|
if temp_high is None:
|
||||||
@@ -231,7 +233,8 @@ class NestThermostatAPI(NestAPI):
|
|||||||
headers={"Authorization": f"Basic {self._access_token}"},
|
headers={"Authorization": f"Basic {self._access_token}"},
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_eco_mode(self):
|
def set_eco_mode(self, state):
|
||||||
|
mode = 'manual-eco' if state else 'schedule'
|
||||||
self._session.post(
|
self._session.post(
|
||||||
f"{self._czfe_url}/v5/put",
|
f"{self._czfe_url}/v5/put",
|
||||||
json={
|
json={
|
||||||
@@ -239,7 +242,7 @@ class NestThermostatAPI(NestAPI):
|
|||||||
{
|
{
|
||||||
"object_key": f'device.{self._device_id}',
|
"object_key": f'device.{self._device_id}',
|
||||||
"op": "MERGE",
|
"op": "MERGE",
|
||||||
"value": {"eco": {"mode": "manual-eco"}},
|
"value": {"eco": {"mode": mode}},
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@@ -13,9 +13,9 @@ from homeassistant.components.climate.const import (
|
|||||||
HVAC_MODE_HEAT,
|
HVAC_MODE_HEAT,
|
||||||
HVAC_MODE_OFF,
|
HVAC_MODE_OFF,
|
||||||
SUPPORT_FAN_MODE,
|
SUPPORT_FAN_MODE,
|
||||||
|
SUPPORT_PRESET_MODE,
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
SUPPORT_TARGET_TEMPERATURE,
|
||||||
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
SUPPORT_TARGET_TEMPERATURE_RANGE,
|
||||||
PRESET_AWAY,
|
|
||||||
PRESET_ECO,
|
PRESET_ECO,
|
||||||
PRESET_NONE,
|
PRESET_NONE,
|
||||||
CURRENT_HVAC_HEAT,
|
CURRENT_HVAC_HEAT,
|
||||||
@@ -53,9 +53,7 @@ ACTION_NEST_TO_HASS = {
|
|||||||
|
|
||||||
MODE_NEST_TO_HASS = {v: k for k, v in MODE_HASS_TO_NEST.items()}
|
MODE_NEST_TO_HASS = {v: k for k, v in MODE_HASS_TO_NEST.items()}
|
||||||
|
|
||||||
PRESET_AWAY_AND_ECO = "Away and Eco"
|
PRESET_MODES = [PRESET_NONE, PRESET_ECO]
|
||||||
|
|
||||||
PRESET_MODES = [PRESET_NONE, PRESET_AWAY, PRESET_ECO, PRESET_AWAY_AND_ECO]
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -100,8 +98,7 @@ class NestClimate(ClimateDevice):
|
|||||||
self.device_id = device_id
|
self.device_id = device_id
|
||||||
|
|
||||||
# Set the default supported features
|
# Set the default supported features
|
||||||
self._support_flags = SUPPORT_TARGET_TEMPERATURE
|
self._support_flags = SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE
|
||||||
# | SUPPORT_PRESET_MODE
|
|
||||||
|
|
||||||
# Not all nest devices support cooling and heating remove unused
|
# Not all nest devices support cooling and heating remove unused
|
||||||
self._operation_list = []
|
self._operation_list = []
|
||||||
@@ -209,16 +206,10 @@ class NestClimate(ClimateDevice):
|
|||||||
@property
|
@property
|
||||||
def preset_mode(self):
|
def preset_mode(self):
|
||||||
"""Return current preset mode."""
|
"""Return current preset mode."""
|
||||||
if self.device.away and self.device.mode == NEST_MODE_ECO:
|
|
||||||
return PRESET_AWAY_AND_ECO
|
|
||||||
|
|
||||||
if self.device.away:
|
|
||||||
return PRESET_AWAY
|
|
||||||
|
|
||||||
if self.device.mode == NEST_MODE_ECO:
|
if self.device.mode == NEST_MODE_ECO:
|
||||||
return PRESET_ECO
|
return PRESET_ECO
|
||||||
|
|
||||||
return None
|
return PRESET_NONE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_modes(self):
|
def preset_modes(self):
|
||||||
@@ -268,20 +259,11 @@ class NestClimate(ClimateDevice):
|
|||||||
|
|
||||||
def set_preset_mode(self, preset_mode):
|
def set_preset_mode(self, preset_mode):
|
||||||
"""Set preset mode."""
|
"""Set preset mode."""
|
||||||
need_away = preset_mode in (PRESET_AWAY, PRESET_AWAY_AND_ECO)
|
need_eco = preset_mode in (PRESET_ECO)
|
||||||
need_eco = preset_mode in (PRESET_ECO, PRESET_AWAY_AND_ECO)
|
|
||||||
is_away = self.device.away
|
|
||||||
is_eco = self.device.mode == NEST_MODE_ECO
|
is_eco = self.device.mode == NEST_MODE_ECO
|
||||||
|
|
||||||
if is_away != need_away:
|
|
||||||
pass
|
|
||||||
# self.device.set_away()
|
|
||||||
|
|
||||||
if is_eco != need_eco:
|
if is_eco != need_eco:
|
||||||
if need_eco:
|
self.device.set_eco_mode(need_eco)
|
||||||
self.device.set_eco_mode()
|
|
||||||
else:
|
|
||||||
self.device.mode = MODE_HASS_TO_NEST[self._operation_list[0]]
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Updates data"""
|
"""Updates data"""
|
||||||
|
Reference in New Issue
Block a user