Improve entity type hints [r] (#77874)

This commit is contained in:
epenet 2022-09-06 09:47:35 +02:00 committed by GitHub
parent 7198273a42
commit 6f564e4f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 97 additions and 83 deletions

View File

@ -119,7 +119,7 @@ class RachioControllerOnlineBinarySensor(RachioControllerBinarySensor):
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
self._state = self._controller.init_data[KEY_STATUS] == STATUS_ONLINE
@ -165,7 +165,7 @@ class RachioRainSensor(RachioControllerBinarySensor):
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
self._state = self._controller.init_data[KEY_RAIN_SENSOR_TRIPPED]

View File

@ -3,6 +3,7 @@ from abc import abstractmethod
from contextlib import suppress
from datetime import timedelta
import logging
from typing import Any
import voluptuous as vol
@ -237,15 +238,15 @@ class RachioStandbySwitch(RachioSwitch):
self.async_write_ha_state()
def turn_on(self, **kwargs) -> None:
def turn_on(self, **kwargs: Any) -> None:
"""Put the controller in standby mode."""
self._controller.rachio.device.turn_off(self._controller.controller_id)
def turn_off(self, **kwargs) -> None:
def turn_off(self, **kwargs: Any) -> None:
"""Resume controller functionality."""
self._controller.rachio.device.turn_on(self._controller.controller_id)
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
if KEY_ON in self._controller.init_data:
self._state = not self._controller.init_data[KEY_ON]
@ -309,17 +310,17 @@ class RachioRainDelay(RachioSwitch):
self._cancel_update = None
self.async_write_ha_state()
def turn_on(self, **kwargs) -> None:
def turn_on(self, **kwargs: Any) -> None:
"""Activate a 24 hour rain delay on the controller."""
self._controller.rachio.device.rain_delay(self._controller.controller_id, 86400)
_LOGGER.debug("Starting rain delay for 24 hours")
def turn_off(self, **kwargs) -> None:
def turn_off(self, **kwargs: Any) -> None:
"""Resume controller functionality."""
self._controller.rachio.device.rain_delay(self._controller.controller_id, 0)
_LOGGER.debug("Canceling rain delay")
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
if KEY_RAIN_DELAY in self._controller.init_data:
self._state = self._controller.init_data[
@ -416,7 +417,7 @@ class RachioZone(RachioSwitch):
props[ATTR_ZONE_SLOPE] = "Steep"
return props
def turn_on(self, **kwargs) -> None:
def turn_on(self, **kwargs: Any) -> None:
"""Start watering this zone."""
# Stop other zones first
self.turn_off()
@ -436,7 +437,7 @@ class RachioZone(RachioSwitch):
str(manual_run_time),
)
def turn_off(self, **kwargs) -> None:
def turn_off(self, **kwargs: Any) -> None:
"""Stop watering all zones."""
self._controller.stop_watering()
@ -464,7 +465,7 @@ class RachioZone(RachioSwitch):
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
self._state = self.zone_id == self._current_schedule.get(KEY_ZONE_ID)
@ -519,7 +520,7 @@ class RachioSchedule(RachioSwitch):
"""Return whether the schedule is allowed to run."""
return self._schedule_enabled
def turn_on(self, **kwargs) -> None:
def turn_on(self, **kwargs: Any) -> None:
"""Start this schedule."""
self._controller.rachio.schedulerule.start(self._schedule_id)
_LOGGER.debug(
@ -528,7 +529,7 @@ class RachioSchedule(RachioSwitch):
self._controller.name,
)
def turn_off(self, **kwargs) -> None:
def turn_off(self, **kwargs: Any) -> None:
"""Stop watering all zones."""
self._controller.stop_watering()
@ -548,7 +549,7 @@ class RachioSchedule(RachioSwitch):
self.async_write_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Subscribe to updates."""
self._state = self._schedule_id == self._current_schedule.get(KEY_SCHEDULE_ID)

View File

@ -58,7 +58,7 @@ class RainCloudBinarySensor(RainCloudEntity, BinarySensorEntity):
"""Return true if the binary sensor is on."""
return self._state
def update(self):
def update(self) -> None:
"""Get the latest data and updates the state."""
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
self._state = getattr(self.data, self._sensor_type)

View File

@ -66,7 +66,7 @@ class RainCloudSensor(RainCloudEntity, SensorEntity):
"""Return the units of measurement."""
return UNIT_OF_MEASUREMENT_MAP.get(self._sensor_type)
def update(self):
def update(self) -> None:
"""Get the latest data and updates the states."""
_LOGGER.debug("Updating RainCloud sensor: %s", self._name)
if self._sensor_type == "battery":

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
import voluptuous as vol
@ -68,7 +69,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchEntity):
"""Return true if device is on."""
return self._state
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
if self._sensor_type == "manual_watering":
self.data.watering_time = self._default_watering_timer
@ -76,7 +77,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchEntity):
self.data.auto_watering = True
self._state = True
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
if self._sensor_type == "manual_watering":
self.data.watering_time = "off"
@ -84,7 +85,7 @@ class RainCloudSwitch(RainCloudEntity, SwitchEntity):
self.data.auto_watering = False
self._state = False
def update(self):
def update(self) -> None:
"""Update device state."""
_LOGGER.debug("Updating RainCloud switch: %s", self._name)
if self._sensor_type == "manual_watering":

View File

@ -63,7 +63,7 @@ class RandomSensor(BinarySensorEntity):
"""Return the sensor class of the sensor."""
return self._device_class
async def async_update(self):
async def async_update(self) -> None:
"""Get new state and update the sensor's state."""
self._state = bool(getrandbits(1))

View File

@ -87,7 +87,7 @@ class RandomSensor(SensorEntity):
"""Return the attributes of the sensor."""
return {ATTR_MAXIMUM: self._maximum, ATTR_MINIMUM: self._minimum}
async def async_update(self):
async def async_update(self) -> None:
"""Get a new number and updates the states."""
self._state = randrange(self._minimum, self._maximum + 1)

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
from pyrecswitch import RSNetwork, RSNetworkError
import voluptuous as vol
@ -76,11 +77,11 @@ class RecSwitchSwitch(SwitchEntity):
"""Return true if switch is on."""
return self.gpio_state
async def async_turn_on(self, **kwargs):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on the switch."""
await self.async_set_gpio_status(True)
async def async_turn_off(self, **kwargs):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn off the switch."""
await self.async_set_gpio_status(False)
@ -93,7 +94,7 @@ class RecSwitchSwitch(SwitchEntity):
except RSNetworkError as error:
_LOGGER.error("Setting status to %s: %r", self.name, error)
async def async_update(self):
async def async_update(self) -> None:
"""Update the current switch status."""
try:

View File

@ -127,7 +127,7 @@ class RedditSensor(SensorEntity):
"""Return the icon to use in the frontend."""
return "mdi:reddit"
def update(self):
def update(self) -> None:
"""Update data from Reddit API."""
self._subreddit_data = []

View File

@ -150,7 +150,7 @@ class RejseplanenTransportSensor(SensorEntity):
"""Icon to use in the frontend, if any."""
return ICON
def update(self):
def update(self) -> None:
"""Get the latest data from rejseplanen.dk and update the states."""
self.data.update()
self._times = self.data.info

View File

@ -75,7 +75,7 @@ class RemoteRPiGPIOBinarySensor(BinarySensorEntity):
self._state = False
self._sensor = sensor
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Run when entity about to be added to hass."""
def read_gpio():
@ -101,7 +101,7 @@ class RemoteRPiGPIOBinarySensor(BinarySensorEntity):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return
def update(self):
def update(self) -> None:
"""Update the GPIO state."""
try:
self._state = remote_rpi_gpio.read_input(self._sensor)

View File

@ -1,6 +1,8 @@
"""Allows to configure a switch using RPi GPIO."""
from __future__ import annotations
from typing import Any
import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
@ -75,13 +77,13 @@ class RemoteRPiGPIOSwitch(SwitchEntity):
"""Return true if device is on."""
return self._state
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
remote_rpi_gpio.write_output(self._switch, 1)
self._state = True
self.schedule_update_ha_state()
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
remote_rpi_gpio.write_output(self._switch, 0)
self._state = False

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio
from http import HTTPStatus
import logging
from typing import Any
import aiohttp
import async_timeout
@ -153,7 +154,7 @@ class RestSwitch(TemplateEntity, SwitchEntity):
"""Return true if device is on."""
return self._state
async def async_turn_on(self, **kwargs):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
body_on_t = self._body_on.async_render(parse_result=False)
@ -169,7 +170,7 @@ class RestSwitch(TemplateEntity, SwitchEntity):
except (asyncio.TimeoutError, aiohttp.ClientError):
_LOGGER.error("Error while switching on %s", self._resource)
async def async_turn_off(self, **kwargs):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
body_off_t = self._body_off.async_render(parse_result=False)
@ -201,7 +202,7 @@ class RestSwitch(TemplateEntity, SwitchEntity):
)
return req
async def async_update(self):
async def async_update(self) -> None:
"""Get the current state, catching errors."""
try:
await self.get_device_state(self.hass)

View File

@ -83,7 +83,7 @@ class RflinkBinarySensor(RflinkDevice, BinarySensorEntity, RestoreEntity):
self._delay_listener = None
super().__init__(device_id, **kwargs)
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Restore RFLink BinarySensor state."""
await super().async_added_to_hass()
if (old_state := await self.async_get_last_state()) is not None:

View File

@ -123,7 +123,7 @@ class RflinkSensor(RflinkDevice, SensorEntity):
"""Domain specific event handler."""
self._state = event["value"]
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register update callback."""
# Remove temporary bogus entity_id if added
tmp_entity = TMP_ENTITY.format(self._device_id)

View File

@ -147,7 +147,7 @@ class RfxtrxBinarySensor(RfxtrxEntity, BinarySensorEntity):
self._cmd_on = cmd_on
self._cmd_off = cmd_off
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Restore device state."""
await super().async_added_to_hass()

View File

@ -284,7 +284,7 @@ class RfxtrxSensor(RfxtrxEntity, SensorEntity):
self.entity_description = entity_description
self._attr_unique_id = "_".join(x for x in (*device_id, entity_description.key))
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Restore device state."""
await super().async_added_to_hass()

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
import RFXtrx as rfxtrxmod
@ -87,7 +88,7 @@ class RfxtrxSwitch(RfxtrxCommandEntity, SwitchEntity):
self._cmd_on = cmd_on
self._cmd_off = cmd_off
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Restore device state."""
await super().async_added_to_hass()
@ -134,7 +135,7 @@ class RfxtrxSwitch(RfxtrxCommandEntity, SwitchEntity):
self.async_write_ha_state()
async def async_turn_on(self, **kwargs):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the device on."""
if self._cmd_on is not None:
await self._async_send(self._device.send_command, self._cmd_on)
@ -143,7 +144,7 @@ class RfxtrxSwitch(RfxtrxCommandEntity, SwitchEntity):
self._attr_is_on = True
self.async_write_ha_state()
async def async_turn_off(self, **kwargs):
async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the device off."""
if self._cmd_off is not None:
await self._async_send(self._device.send_command, self._cmd_off)

View File

@ -88,13 +88,13 @@ class RingBinarySensor(RingEntityMixin, BinarySensorEntity):
self._attr_unique_id = f"{device.id}-{description.key}"
self._update_alert()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callbacks."""
await super().async_added_to_hass()
self.ring_objects["dings_data"].async_add_listener(self._dings_update_callback)
self._dings_update_callback()
async def async_will_remove_from_hass(self):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()
self.ring_objects["dings_data"].async_remove_listener(

View File

@ -60,7 +60,7 @@ class RingCam(RingEntityMixin, Camera):
self._image = None
self._expires_at = dt_util.utcnow() - FORCE_REFRESH_INTERVAL
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callbacks."""
await super().async_added_to_hass()
@ -68,7 +68,7 @@ class RingCam(RingEntityMixin, Camera):
self._device, self._history_update_callback
)
async def async_will_remove_from_hass(self):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()
@ -144,7 +144,7 @@ class RingCam(RingEntityMixin, Camera):
finally:
await stream.close()
async def async_update(self):
async def async_update(self) -> None:
"""Update camera entity and refresh attributes."""
if self._last_event is None:
return

View File

@ -82,7 +82,7 @@ class RingSensor(RingEntityMixin, SensorEntity):
class HealthDataRingSensor(RingSensor):
"""Ring sensor that relies on health data."""
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callbacks."""
await super().async_added_to_hass()
@ -90,7 +90,7 @@ class HealthDataRingSensor(RingSensor):
self._device, self._health_update_callback
)
async def async_will_remove_from_hass(self):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()
@ -125,7 +125,7 @@ class HistoryRingSensor(RingSensor):
_latest_event = None
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callbacks."""
await super().async_added_to_hass()
@ -133,7 +133,7 @@ class HistoryRingSensor(RingSensor):
self._device, self._history_update_callback
)
async def async_will_remove_from_hass(self):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()

View File

@ -1,6 +1,7 @@
"""This component provides HA switch support for Ring Door Bell/Chimes."""
from datetime import timedelta
import logging
from typing import Any
import requests
@ -97,11 +98,11 @@ class SirenSwitch(BaseRingSwitch):
"""If the switch is currently on or off."""
return self._siren_on
def turn_on(self, **kwargs):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the siren on for 30 seconds."""
self._set_switch(1)
def turn_off(self, **kwargs):
def turn_off(self, **kwargs: Any) -> None:
"""Turn the siren off."""
self._set_switch(0)

View File

@ -70,7 +70,7 @@ class RippleSensor(SensorEntity):
"""Return the state attributes of the sensor."""
return {ATTR_ATTRIBUTION: ATTRIBUTION}
def update(self):
def update(self) -> None:
"""Get the latest state of the sensor."""
if (balance := get_balance(self.address)) is not None:
self._state = balance

View File

@ -186,7 +186,7 @@ class RMVDepartureSensor(SensorEntity):
"""Return the unit this state is expressed in."""
return TIME_MINUTES
async def async_update(self):
async def async_update(self) -> None:
"""Get the latest data and update the state."""
await self.data.async_update()

View File

@ -1,5 +1,8 @@
"""MediaPlayer platform for Roon integration."""
from __future__ import annotations
import logging
from typing import Any
from roonapi import split_media_path
import voluptuous as vol
@ -8,6 +11,7 @@ from homeassistant.components.media_player import (
MediaPlayerEntity,
MediaPlayerEntityFeature,
)
from homeassistant.components.media_player.browse_media import BrowseMedia
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_DEFAULT_NAME,
@ -119,7 +123,7 @@ class RoonDevice(MediaPlayerEntity):
self._volume_level = 0
self.update_data(player_data)
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callback."""
self.async_on_remove(
async_dispatcher_connect(
@ -376,38 +380,38 @@ class RoonDevice(MediaPlayerEntity):
"""Boolean if shuffle is enabled."""
return self._shuffle
def media_play(self):
def media_play(self) -> None:
"""Send play command to device."""
self._server.roonapi.playback_control(self.output_id, "play")
def media_pause(self):
def media_pause(self) -> None:
"""Send pause command to device."""
self._server.roonapi.playback_control(self.output_id, "pause")
def media_play_pause(self):
def media_play_pause(self) -> None:
"""Toggle play command to device."""
self._server.roonapi.playback_control(self.output_id, "playpause")
def media_stop(self):
def media_stop(self) -> None:
"""Send stop command to device."""
self._server.roonapi.playback_control(self.output_id, "stop")
def media_next_track(self):
def media_next_track(self) -> None:
"""Send next track command to device."""
self._server.roonapi.playback_control(self.output_id, "next")
def media_previous_track(self):
def media_previous_track(self) -> None:
"""Send previous track command to device."""
self._server.roonapi.playback_control(self.output_id, "previous")
def media_seek(self, position):
def media_seek(self, position: float) -> None:
"""Send seek command to device."""
self._server.roonapi.seek(self.output_id, position)
# Seek doesn't cause an async update - so force one
self._media_position = position
self.schedule_update_ha_state()
def set_volume_level(self, volume):
def set_volume_level(self, volume: float) -> None:
"""Send new volume_level to device."""
volume = int(volume * 100)
self._server.roonapi.change_volume(self.output_id, volume)
@ -416,15 +420,15 @@ class RoonDevice(MediaPlayerEntity):
"""Send mute/unmute to device."""
self._server.roonapi.mute(self.output_id, mute)
def volume_up(self):
def volume_up(self) -> None:
"""Send new volume_level to device."""
self._server.roonapi.change_volume(self.output_id, 3, "relative")
def volume_down(self):
def volume_down(self) -> None:
"""Send new volume_level to device."""
self._server.roonapi.change_volume(self.output_id, -3, "relative")
def turn_on(self):
def turn_on(self) -> None:
"""Turn on device (if supported)."""
if not (self.supports_standby and "source_controls" in self.player_data):
self.media_play()
@ -436,7 +440,7 @@ class RoonDevice(MediaPlayerEntity):
)
return
def turn_off(self):
def turn_off(self) -> None:
"""Turn off device (if supported)."""
if not (self.supports_standby and "source_controls" in self.player_data):
self.media_stop()
@ -447,11 +451,11 @@ class RoonDevice(MediaPlayerEntity):
self._server.roonapi.standby(self.output_id, source["control_key"])
return
def set_shuffle(self, shuffle):
def set_shuffle(self, shuffle: bool) -> None:
"""Set shuffle state."""
self._server.roonapi.shuffle(self.output_id, shuffle)
def play_media(self, media_type, media_id, **kwargs):
def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None:
"""Send the play_media command to the media player."""
_LOGGER.debug("Playback request for %s / %s", media_type, media_id)
@ -469,7 +473,7 @@ class RoonDevice(MediaPlayerEntity):
path_list,
)
def join_players(self, group_members):
def join_players(self, group_members: list[str]) -> None:
"""Join `group_members` as a player group with the current player."""
zone_data = self._server.roonapi.zone_by_output_id(self._output_id)
@ -509,7 +513,7 @@ class RoonDevice(MediaPlayerEntity):
[self._output_id] + [sync_available[name] for name in names]
)
def unjoin_player(self):
def unjoin_player(self) -> None:
"""Remove this player from any group."""
if not self._server.roonapi.is_grouped(self._output_id):
@ -548,7 +552,9 @@ class RoonDevice(MediaPlayerEntity):
self._server.roonapi.transfer_zone, self._zone_id, transfer_id
)
async def async_browse_media(self, media_content_type=None, media_content_id=None):
async def async_browse_media(
self, media_content_type: str | None = None, media_content_id: str | None = None
) -> BrowseMedia:
"""Implement the websocket media browsing helper."""
return await self.hass.async_add_executor_job(
browse_media,

View File

@ -117,7 +117,7 @@ class RovaSensor(SensorEntity):
self._attr_name = f"{platform_name}_{description.name}"
self._attr_device_class = SensorDeviceClass.TIMESTAMP
def update(self):
def update(self) -> None:
"""Get the latest data from the sensor and update the state."""
self.data_service.update()
pickup_date = self.data_service.data.get(self.entity_description.key)

View File

@ -115,7 +115,7 @@ class RussoundZoneDevice(MediaPlayerEntity):
if source_id == current:
self.schedule_update_ha_state()
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callback handlers."""
self._russ.add_zone_callback(self._zone_callback_handler)
self._russ.add_source_callback(self._source_callback_handler)
@ -178,20 +178,20 @@ class RussoundZoneDevice(MediaPlayerEntity):
"""
return float(self._zone_var("volume", 0)) / 50.0
async def async_turn_off(self):
async def async_turn_off(self) -> None:
"""Turn off the zone."""
await self._russ.send_zone_event(self._zone_id, "ZoneOff")
async def async_turn_on(self):
async def async_turn_on(self) -> None:
"""Turn on the zone."""
await self._russ.send_zone_event(self._zone_id, "ZoneOn")
async def async_set_volume_level(self, volume):
async def async_set_volume_level(self, volume: float) -> None:
"""Set the volume level."""
rvol = int(volume * 50.0)
await self._russ.send_zone_event(self._zone_id, "KeyPress", "Volume", rvol)
async def async_select_source(self, source):
async def async_select_source(self, source: str) -> None:
"""Select the source input for this zone."""
for source_id, name in self._sources:
if name.lower() != source.lower():

View File

@ -90,7 +90,7 @@ class RussoundRNETDevice(MediaPlayerEntity):
self._volume = None
self._source = None
def update(self):
def update(self) -> None:
"""Retrieve latest state."""
# Updated this function to make a single call to get_zone_info, so that
# with a single call we can get On/Off, Volume and Source, reducing the
@ -141,7 +141,7 @@ class RussoundRNETDevice(MediaPlayerEntity):
"""
return self._volume
def set_volume_level(self, volume):
def set_volume_level(self, volume: float) -> None:
"""Set volume level. Volume has a range (0..1).
Translate this to a range of (0..100) as expected
@ -149,19 +149,19 @@ class RussoundRNETDevice(MediaPlayerEntity):
"""
self._russ.set_volume("1", self._zone_id, volume * 100)
def turn_on(self):
def turn_on(self) -> None:
"""Turn the media player on."""
self._russ.set_power("1", self._zone_id, "1")
def turn_off(self):
def turn_off(self) -> None:
"""Turn off media player."""
self._russ.set_power("1", self._zone_id, "0")
def mute_volume(self, mute):
def mute_volume(self, mute: bool) -> None:
"""Send mute command."""
self._russ.toggle_mute("1", self._zone_id)
def select_source(self, source):
def select_source(self, source: str) -> None:
"""Set the input source."""
if source in self._sources:
index = self._sources.index(source)