Skip to content

Commit b9e8da3

Browse files
authored
Merge pull request #9 from 0xAlon/dev
Update FixedTemperature functionality
2 parents cf73dbd + 5d12bfd commit b9e8da3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

custom_components/dolphin/API/dolphin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ async def isEnergyMeter(self, user: User, deviceName: str):
153153
return 0
154154
return data['isEnergyMeter']
155155

156-
async def turnOnFixedTemperature(self, user: User, deviceName: str):
156+
async def turnOnFixedTemperature(self, user: User, deviceName: str, temperature: str):
157157
data = {
158158
"deviceName": deviceName,
159-
"temperature": "60",
159+
"temperature": temperature,
160160
"email": user.email,
161161
"API_Key": user.api,
162162
}

custom_components/dolphin/climate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ async def async_set_temperature(self, **kwargs: Any) -> None:
138138
if kwargs.get('temperature') >= self._coordinator.data[self._device].temperature:
139139
await self._coordinator.dolphin.turnOnManually(self._coordinator.dolphin._user,
140140
kwargs.get('temperature'), self._device)
141+
if self._coordinator.data[self._device].fixedTemperature:
142+
await self._coordinator.dolphin.turnOnFixedTemperature(self._coordinator.dolphin._user, self._device,
143+
kwargs.get('temperature'))
141144
else:
142145
self._coordinator.data[self._device].targetTemperature = self._coordinator.data[self._device].temperature
143146

@@ -157,6 +160,9 @@ async def async_set_hvac_mode(self, hvac_mode):
157160
elif hvac_mode == HVACMode.OFF and self._coordinator.data[self._device].power:
158161

159162
await self._coordinator.dolphin.turnOffManually(self._coordinator.dolphin._user, self._device)
163+
if self._coordinator.data[self._device].fixedTemperature:
164+
await self._coordinator.dolphin.turnOffFixedTemperature(self._coordinator.dolphin._user, self._device)
165+
self._coordinator.data[self._device].fixedTemperature = False
160166
await self.coordinator.async_request_refresh()
161167
self.async_write_ha_state()
162168

custom_components/dolphin/switch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,14 @@ def is_on(self):
194194
return self._coordinator.data[self._device].fixedTemperature
195195

196196
async def async_turn_on(self):
197-
await self._coordinator.dolphin.turnOnFixedTemperature(self._coordinator.dolphin._user, self._device)
197+
await self._coordinator.dolphin.turnOnFixedTemperature(self._coordinator.dolphin._user, self._device,
198+
self._coordinator.data[self._device].targetTemperature)
198199
self._coordinator.data[self._device].fixedTemperature = True
200+
await self.coordinator.async_request_refresh()
199201
self.async_write_ha_state()
200202

201203
async def async_turn_off(self):
202204
await self._coordinator.dolphin.turnOffFixedTemperature(self._coordinator.dolphin._user, self._device)
203205
self._coordinator.data[self._device].fixedTemperature = False
206+
await self.coordinator.async_request_refresh()
204207
self.async_write_ha_state()

0 commit comments

Comments
 (0)