mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 13:45:12 +02:00
handle PlatformNotReady
This commit is contained in:
@@ -29,6 +29,7 @@ from homeassistant.const import (
|
|||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.script import Script
|
from homeassistant.helpers.script import Script
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
@@ -97,6 +98,7 @@ class SamsungTVDevice(MediaPlayerEntity):
|
|||||||
# Assume that the TV is in Play mode
|
# Assume that the TV is in Play mode
|
||||||
self._playing = True
|
self._playing = True
|
||||||
self._state = None
|
self._state = None
|
||||||
|
self._was_on = False
|
||||||
# Mark the end of a shutdown command (need to wait 15 seconds before
|
# Mark the end of a shutdown command (need to wait 15 seconds before
|
||||||
# sending the next command to avoid turning the TV back ON).
|
# sending the next command to avoid turning the TV back ON).
|
||||||
self._end_of_power_off = None
|
self._end_of_power_off = None
|
||||||
@@ -117,7 +119,13 @@ class SamsungTVDevice(MediaPlayerEntity):
|
|||||||
if self._power_off_in_progress():
|
if self._power_off_in_progress():
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
else:
|
else:
|
||||||
self._state = STATE_ON if self._bridge.is_on() else STATE_OFF
|
if self._bridge.is_on():
|
||||||
|
self._state = STATE_ON
|
||||||
|
self._was_on = True
|
||||||
|
else:
|
||||||
|
self._state = STATE_OFF
|
||||||
|
if !self._was_on:
|
||||||
|
raise PlatformNotReady
|
||||||
|
|
||||||
def send_key(self, key):
|
def send_key(self, key):
|
||||||
"""Send a key to the tv and handles exceptions."""
|
"""Send a key to the tv and handles exceptions."""
|
||||||
|
Reference in New Issue
Block a user