Skip to content

Commit b0b4bc8

Browse files
Fix self.async_update_ha_state() #1071
1 parent fad9e79 commit b0b4bc8

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

custom_components/smartir/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
_LOGGER = logging.getLogger(__name__)
2020

2121
DOMAIN = 'smartir'
22-
VERSION = '1.17.7'
22+
VERSION = '1.17.8'
2323
MANIFEST_URL = (
2424
"https://raw.githubusercontent.com/"
2525
"smartHomeHub/SmartIR/{}/"

custom_components/smartir/climate.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ async def async_set_temperature(self, **kwargs):
319319
if not self._hvac_mode.lower() == HVAC_MODE_OFF:
320320
await self.send_command()
321321

322-
await self.async_update_ha_state()
322+
self.async_write_ha_state()
323323

324324
async def async_set_hvac_mode(self, hvac_mode):
325325
"""Set operation mode."""
@@ -329,23 +329,23 @@ async def async_set_hvac_mode(self, hvac_mode):
329329
self._last_on_operation = hvac_mode
330330

331331
await self.send_command()
332-
await self.async_update_ha_state()
332+
self.async_write_ha_state()
333333

334334
async def async_set_fan_mode(self, fan_mode):
335335
"""Set fan mode."""
336336
self._current_fan_mode = fan_mode
337337

338338
if not self._hvac_mode.lower() == HVAC_MODE_OFF:
339339
await self.send_command()
340-
await self.async_update_ha_state()
340+
self.async_write_ha_state()
341341

342342
async def async_set_swing_mode(self, swing_mode):
343343
"""Set swing mode."""
344344
self._current_swing_mode = swing_mode
345345

346346
if not self._hvac_mode.lower() == HVAC_MODE_OFF:
347347
await self.send_command()
348-
await self.async_update_ha_state()
348+
self.async_write_ha_state()
349349

350350
async def async_turn_off(self):
351351
"""Turn off."""
@@ -391,15 +391,15 @@ async def _async_temp_sensor_changed(self, entity_id, old_state, new_state):
391391
return
392392

393393
self._async_update_temp(new_state)
394-
await self.async_update_ha_state()
394+
self.async_write_ha_state()
395395

396396
async def _async_humidity_sensor_changed(self, entity_id, old_state, new_state):
397397
"""Handle humidity sensor changes."""
398398
if new_state is None:
399399
return
400400

401401
self._async_update_humidity(new_state)
402-
await self.async_update_ha_state()
402+
self.async_write_ha_state()
403403

404404
async def _async_power_sensor_changed(self, entity_id, old_state, new_state):
405405
"""Handle power sensor changes."""
@@ -416,13 +416,13 @@ async def _async_power_sensor_changed(self, entity_id, old_state, new_state):
416416
else:
417417
self._hvac_mode = STATE_ON
418418

419-
await self.async_update_ha_state()
419+
self.async_write_ha_state()
420420

421421
if new_state.state == STATE_OFF:
422422
self._on_by_remote = False
423423
if self._hvac_mode != HVAC_MODE_OFF:
424424
self._hvac_mode = HVAC_MODE_OFF
425-
await self.async_update_ha_state()
425+
self.async_write_ha_state()
426426

427427
@callback
428428
def _async_update_temp(self, state):

custom_components/smartir/fan.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
FanEntity, PLATFORM_SCHEMA,
1010
DIRECTION_REVERSE, DIRECTION_FORWARD,
1111
SUPPORT_SET_SPEED, SUPPORT_DIRECTION, SUPPORT_OSCILLATE,
12-
ATTR_OSCILLATING )
12+
ATTR_OSCILLATING)
1313
from homeassistant.const import (
1414
CONF_NAME, STATE_OFF, STATE_ON, STATE_UNKNOWN)
1515
from homeassistant.core import callback
@@ -228,14 +228,14 @@ async def async_set_percentage(self, percentage: int):
228228
self._last_on_speed = self._speed
229229

230230
await self.send_command()
231-
await self.async_update_ha_state()
231+
self.async_write_ha_state()
232232

233233
async def async_oscillate(self, oscillating: bool) -> None:
234234
"""Set oscillation of the fan."""
235235
self._oscillating = oscillating
236236

237237
await self.send_command()
238-
await self.async_update_ha_state()
238+
self.async_write_ha_state()
239239

240240
async def async_set_direction(self, direction: str):
241241
"""Set the direction of the fan"""
@@ -244,7 +244,7 @@ async def async_set_direction(self, direction: str):
244244
if not self._speed.lower() == SPEED_OFF:
245245
await self.send_command()
246246

247-
await self.async_update_ha_state()
247+
self.async_write_ha_state()
248248

249249
async def async_turn_on(self, percentage: int = None, **kwargs):
250250
"""Turn on the fan."""
@@ -288,10 +288,10 @@ async def _async_power_sensor_changed(self, entity_id, old_state, new_state):
288288
if new_state.state == STATE_ON and self._speed == SPEED_OFF:
289289
self._on_by_remote = True
290290
self._speed = None
291-
await self.async_update_ha_state()
291+
self.async_write_ha_state()
292292

293293
if new_state.state == STATE_OFF:
294294
self._on_by_remote = False
295295
if self._speed != SPEED_OFF:
296296
self._speed = SPEED_OFF
297-
await self.async_update_ha_state()
297+
self.async_write_ha_state()

custom_components/smartir/manifest.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"dependencies": [],
66
"codeowners": ["@smartHomeHub"],
77
"requirements": ["aiofiles>=0.6.0"],
8-
"homeassistant": "2022.4.0",
9-
"version": "1.17.7",
8+
"homeassistant": "2023.6.0",
9+
"version": "1.17.8",
1010
"updater": {
11-
"version": "1.17.7",
12-
"releaseNotes": "-- Fixes #1025",
11+
"version": "1.17.8",
12+
"releaseNotes": "-- Fix self.async_update_ha_state() #1071",
1313
"files": [
1414
"__init__.py",
1515
"climate.py",

custom_components/smartir/media_player.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -225,46 +225,46 @@ async def async_turn_off(self):
225225
if self._power_sensor is None:
226226
self._state = STATE_OFF
227227
self._source = None
228-
await self.async_update_ha_state()
228+
self.async_write_ha_state()
229229

230230
async def async_turn_on(self):
231231
"""Turn the media player off."""
232232
await self.send_command(self._commands['on'])
233233

234234
if self._power_sensor is None:
235235
self._state = STATE_ON
236-
await self.async_update_ha_state()
236+
self.async_write_ha_state()
237237

238238
async def async_media_previous_track(self):
239239
"""Send previous track command."""
240240
await self.send_command(self._commands['previousChannel'])
241-
await self.async_update_ha_state()
241+
self.async_write_ha_state()
242242

243243
async def async_media_next_track(self):
244244
"""Send next track command."""
245245
await self.send_command(self._commands['nextChannel'])
246-
await self.async_update_ha_state()
246+
self.async_write_ha_state()
247247

248248
async def async_volume_down(self):
249249
"""Turn volume down for media player."""
250250
await self.send_command(self._commands['volumeDown'])
251-
await self.async_update_ha_state()
251+
self.async_write_ha_state()
252252

253253
async def async_volume_up(self):
254254
"""Turn volume up for media player."""
255255
await self.send_command(self._commands['volumeUp'])
256-
await self.async_update_ha_state()
256+
self.async_write_ha_state()
257257

258258
async def async_mute_volume(self, mute):
259259
"""Mute the volume."""
260260
await self.send_command(self._commands['mute'])
261-
await self.async_update_ha_state()
261+
self.async_write_ha_state()
262262

263263
async def async_select_source(self, source):
264264
"""Select channel from source."""
265265
self._source = source
266266
await self.send_command(self._commands['sources'][source])
267-
await self.async_update_ha_state()
267+
self.async_write_ha_state()
268268

269269
async def async_play_media(self, media_type, media_id, **kwargs):
270270
"""Support channel change through play_media service."""
@@ -281,7 +281,7 @@ async def async_play_media(self, media_type, media_id, **kwargs):
281281
self._source = "Channel {}".format(media_id)
282282
for digit in media_id:
283283
await self.send_command(self._commands['sources']["Channel {}".format(digit)])
284-
await self.async_update_ha_state()
284+
self.async_write_ha_state()
285285

286286
async def send_command(self, command):
287287
async with self._temp_lock:

hacs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "SmartIR",
3-
"homeassistant": "0.115.0",
3+
"homeassistant": "2023.6.0",
44
"persistent_directory": "codes"
55
}

0 commit comments

Comments
 (0)