1 """Support for the Roku remote."""
3 from __future__
import annotations
5 from collections.abc
import Iterable
13 from .const
import DOMAIN
14 from .coordinator
import RokuDataUpdateCoordinator
15 from .entity
import RokuEntity
16 from .helpers
import roku_exception_handler
22 async_add_entities: AddEntitiesCallback,
24 """Load Roku remote based on a config entry."""
25 coordinator: RokuDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
30 coordinator=coordinator,
38 """Device that sends commands to an Roku."""
44 """Return true if device is on."""
45 return not self.coordinator.data.state.standby
47 @roku_exception_handler()
49 """Turn the device on."""
50 await self.coordinator.roku.remote(
"poweron")
51 await self.coordinator.async_request_refresh()
53 @roku_exception_handler(ignore_timeout=True)
55 """Turn the device off."""
56 await self.coordinator.roku.remote(
"poweroff")
57 await self.coordinator.async_request_refresh()
59 @roku_exception_handler()
61 """Send a command to one device."""
62 num_repeats = kwargs[ATTR_NUM_REPEATS]
64 for _
in range(num_repeats):
65 for single_command
in command:
66 await self.coordinator.roku.remote(single_command)
68 await self.coordinator.async_request_refresh()
None async_turn_on(self, **Any kwargs)
None async_send_command(self, Iterable[str] command, **Any kwargs)
None async_turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)