Improve entity type hints [g] (#77145)

This commit is contained in:
epenet 2022-08-26 11:37:12 +02:00 committed by GitHub
parent 452ee0284a
commit b043053aad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 66 additions and 51 deletions

View File

@ -59,7 +59,7 @@ class GC100BinarySensor(BinarySensorEntity):
"""Return the state of the entity.""" """Return the state of the entity."""
return self._state return self._state
def update(self): def update(self) -> None:
"""Update the sensor state.""" """Update the sensor state."""
self._gc100.read_sensor(self._port_addr, self.set_state) self._gc100.read_sensor(self._port_addr, self.set_state)

View File

@ -1,6 +1,8 @@
"""Support for switches using GC100.""" """Support for switches using GC100."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import voluptuous as vol import voluptuous as vol
from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity from homeassistant.components.switch import PLATFORM_SCHEMA, SwitchEntity
@ -54,15 +56,15 @@ class GC100Switch(SwitchEntity):
"""Return the state of the entity.""" """Return the state of the entity."""
return self._state return self._state
def turn_on(self, **kwargs): def turn_on(self, **kwargs: Any) -> None:
"""Turn the device on.""" """Turn the device on."""
self._gc100.write_switch(self._port_addr, 1, self.set_state) self._gc100.write_switch(self._port_addr, 1, self.set_state)
def turn_off(self, **kwargs): def turn_off(self, **kwargs: Any) -> None:
"""Turn the device off.""" """Turn the device off."""
self._gc100.write_switch(self._port_addr, 0, self.set_state) self._gc100.write_switch(self._port_addr, 0, self.set_state)
def update(self): def update(self) -> None:
"""Update the sensor state.""" """Update the sensor state."""
self._gc100.read_sensor(self._port_addr, self.set_state) self._gc100.read_sensor(self._port_addr, self.set_state)

View File

@ -59,7 +59,7 @@ class GdacsSensor(SensorEntity):
self._removed = None self._removed = None
self._remove_signal_status = None self._remove_signal_status = None
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass.""" """Call when entity is added to hass."""
self._remove_signal_status = async_dispatcher_connect( self._remove_signal_status = async_dispatcher_connect(
self.hass, self.hass,
@ -81,7 +81,7 @@ class GdacsSensor(SensorEntity):
_LOGGER.debug("Received status update for %s", self._config_entry_id) _LOGGER.debug("Received status update for %s", self._config_entry_id)
self.async_schedule_update_ha_state(True) self.async_schedule_update_ha_state(True)
async def async_update(self): async def async_update(self) -> None:
"""Update this entity from the data held in the feed manager.""" """Update this entity from the data held in the feed manager."""
_LOGGER.debug("Updating %s", self._config_entry_id) _LOGGER.debug("Updating %s", self._config_entry_id)
if self._manager: if self._manager:

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
import logging import logging
import math import math
from typing import Any
import voluptuous as vol import voluptuous as vol
@ -366,7 +367,7 @@ class GenericThermostat(ClimateEntity, RestoreEntity):
"""List of available operation modes.""" """List of available operation modes."""
return self._hvac_list return self._hvac_list
async def async_set_hvac_mode(self, hvac_mode): async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set hvac mode.""" """Set hvac mode."""
if hvac_mode == HVACMode.HEAT: if hvac_mode == HVACMode.HEAT:
self._hvac_mode = HVACMode.HEAT self._hvac_mode = HVACMode.HEAT
@ -384,7 +385,7 @@ class GenericThermostat(ClimateEntity, RestoreEntity):
# Ensure we update the current operation after changing the mode # Ensure we update the current operation after changing the mode
self.async_write_ha_state() self.async_write_ha_state()
async def async_set_temperature(self, **kwargs): async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature.""" """Set new target temperature."""
if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None:
return return
@ -537,7 +538,7 @@ class GenericThermostat(ClimateEntity, RestoreEntity):
HA_DOMAIN, SERVICE_TURN_OFF, data, context=self._context HA_DOMAIN, SERVICE_TURN_OFF, data, context=self._context
) )
async def async_set_preset_mode(self, preset_mode: str): async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode.""" """Set new preset mode."""
if preset_mode not in (self._attr_preset_modes or []): if preset_mode not in (self._attr_preset_modes or []):
raise ValueError( raise ValueError(

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
from datetime import timedelta from datetime import timedelta
from typing import Any
import voluptuous as vol import voluptuous as vol
@ -71,13 +72,13 @@ class GeniusSwitch(GeniusZone, SwitchEntity):
""" """
return self._zone.data["mode"] == "override" and self._zone.data["setpoint"] return self._zone.data["mode"] == "override" and self._zone.data["setpoint"]
async def async_turn_off(self, **kwargs) -> None: async def async_turn_off(self, **kwargs: Any) -> None:
"""Send the zone to Timer mode. """Send the zone to Timer mode.
The zone is deemed 'off' in this mode, although the plugs may actually be on. The zone is deemed 'off' in this mode, although the plugs may actually be on.
""" """
await self._zone.set_mode("timer") await self._zone.set_mode("timer")
async def async_turn_on(self, **kwargs) -> None: async def async_turn_on(self, **kwargs: Any) -> None:
"""Set the zone to override/on ({'setpoint': true}) for x seconds.""" """Set the zone to override/on ({'setpoint': true}) for x seconds."""
await self._zone.set_override(1, kwargs.get(ATTR_DURATION, 3600)) await self._zone.set_override(1, kwargs.get(ATTR_DURATION, 3600))

View File

@ -78,6 +78,6 @@ class GeniusWaterHeater(GeniusHeatingZone, WaterHeaterEntity):
"""Return the current operation mode.""" """Return the current operation mode."""
return GH_STATE_TO_HA[self._zone.data["mode"]] # type: ignore[return-value] return GH_STATE_TO_HA[self._zone.data["mode"]] # type: ignore[return-value]
async def async_set_operation_mode(self, operation_mode) -> None: async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set a new operation mode for this boiler.""" """Set a new operation mode for this boiler."""
await self._zone.set_mode(HA_OPMODE_TO_GH[operation_mode]) await self._zone.set_mode(HA_OPMODE_TO_GH[operation_mode])

View File

@ -150,7 +150,7 @@ class GeoRssServiceSensor(SensorEntity):
"""Return the state attributes.""" """Return the state attributes."""
return self._state_attributes return self._state_attributes
def update(self): def update(self) -> None:
"""Update this sensor from the GeoRSS service.""" """Update this sensor from the GeoRSS service."""
status, feed_entries = self._feed.update() status, feed_entries = self._feed.update()

View File

@ -100,7 +100,7 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
"""Return the source type, eg gps or router, of the device.""" """Return the source type, eg gps or router, of the device."""
return SourceType.GPS return SourceType.GPS
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Register state update callback.""" """Register state update callback."""
await super().async_added_to_hass() await super().async_added_to_hass()
self._unsub_dispatcher = async_dispatcher_connect( self._unsub_dispatcher = async_dispatcher_connect(
@ -117,7 +117,7 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
attr = state.attributes attr = state.attributes
self._gps = (attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE)) self._gps = (attr.get(ATTR_LATITUDE), attr.get(ATTR_LONGITUDE))
async def async_will_remove_from_hass(self): async def async_will_remove_from_hass(self) -> None:
"""Clean up after entity before removal.""" """Clean up after entity before removal."""
await super().async_will_remove_from_hass() await super().async_will_remove_from_hass()
self._unsub_dispatcher() self._unsub_dispatcher()

View File

@ -60,7 +60,7 @@ class GeonetnzQuakesSensor(SensorEntity):
self._removed = None self._removed = None
self._remove_signal_status = None self._remove_signal_status = None
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass.""" """Call when entity is added to hass."""
self._remove_signal_status = async_dispatcher_connect( self._remove_signal_status = async_dispatcher_connect(
self.hass, self.hass,
@ -82,7 +82,7 @@ class GeonetnzQuakesSensor(SensorEntity):
_LOGGER.debug("Received status update for %s", self._config_entry_id) _LOGGER.debug("Received status update for %s", self._config_entry_id)
self.async_schedule_update_ha_state(True) self.async_schedule_update_ha_state(True)
async def async_update(self): async def async_update(self) -> None:
"""Update this entity from the data held in the feed manager.""" """Update this entity from the data held in the feed manager."""
_LOGGER.debug("Updating %s", self._config_entry_id) _LOGGER.debug("Updating %s", self._config_entry_id)
if self._manager: if self._manager:

View File

@ -81,7 +81,7 @@ class GeonetnzVolcanoSensor(SensorEntity):
self._feed_last_update_successful = None self._feed_last_update_successful = None
self._remove_signal_update = None self._remove_signal_update = None
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass.""" """Call when entity is added to hass."""
self._remove_signal_update = async_dispatcher_connect( self._remove_signal_update = async_dispatcher_connect(
self.hass, self.hass,
@ -99,7 +99,7 @@ class GeonetnzVolcanoSensor(SensorEntity):
"""Call update method.""" """Call update method."""
self.async_schedule_update_ha_state(True) self.async_schedule_update_ha_state(True)
async def async_update(self): async def async_update(self) -> None:
"""Update this entity from the data held in the feed manager.""" """Update this entity from the data held in the feed manager."""
_LOGGER.debug("Updating %s", self._external_id) _LOGGER.debug("Updating %s", self._external_id)
feed_entry = self._feed_manager.get_entry(self._external_id) feed_entry = self._feed_manager.get_entry(self._external_id)

View File

@ -126,7 +126,7 @@ class GitLabSensor(SensorEntity):
return ICON_SAD return ICON_SAD
return ICON_OTHER return ICON_OTHER
def update(self): def update(self) -> None:
"""Collect updated data from GitLab API.""" """Collect updated data from GitLab API."""
self._gitlab_data.update() self._gitlab_data.update()

View File

@ -98,7 +98,7 @@ class GitterSensor(SensorEntity):
"""Return the icon to use in the frontend, if any.""" """Return the icon to use in the frontend, if any."""
return ICON return ICON
def update(self): def update(self) -> None:
"""Get the latest data and updates the state.""" """Get the latest data and updates the state."""
try: try:

View File

@ -20,7 +20,7 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
Platform, Platform,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
@ -330,7 +330,7 @@ class GlancesSensor(SensorEntity):
self.glances_data = glances_data self.glances_data = glances_data
self._sensor_name_prefix = sensor_name_prefix self._sensor_name_prefix = sensor_name_prefix
self._state = None self._state = None
self.unsub_update = None self.unsub_update: CALLBACK_TYPE | None = None
self.entity_description = description self.entity_description = description
self._attr_name = f"{sensor_name_prefix} {description.name_suffix}" self._attr_name = f"{sensor_name_prefix} {description.name_suffix}"
@ -342,7 +342,7 @@ class GlancesSensor(SensorEntity):
self._attr_unique_id = f"{self.glances_data.config_entry.entry_id}-{sensor_name_prefix}-{description.key}" self._attr_unique_id = f"{self.glances_data.config_entry.entry_id}-{sensor_name_prefix}-{description.key}"
@property @property
def available(self): def available(self) -> bool:
"""Could the device be accessed during the last update call.""" """Could the device be accessed during the last update call."""
return self.glances_data.available return self.glances_data.available
@ -351,7 +351,7 @@ class GlancesSensor(SensorEntity):
"""Return the state of the resources.""" """Return the state of the resources."""
return self._state return self._state
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Handle entity which will be added.""" """Handle entity which will be added."""
self.unsub_update = async_dispatcher_connect( self.unsub_update = async_dispatcher_connect(
self.hass, DATA_UPDATED, self._schedule_immediate_update self.hass, DATA_UPDATED, self._schedule_immediate_update

View File

@ -186,7 +186,7 @@ class GoogleTravelTimeSensor(SensorEntity):
await self.hass.async_add_executor_job(self.update) await self.hass.async_add_executor_job(self.update)
self.async_write_ha_state() self.async_write_ha_state()
def update(self): def update(self) -> None:
"""Get the latest data from Google.""" """Get the latest data from Google."""
options_copy = self._config_entry.options.copy() options_copy = self._config_entry.options.copy()
dtime = options_copy.get(CONF_DEPARTURE_TIME) dtime = options_copy.get(CONF_DEPARTURE_TIME)

View File

@ -136,18 +136,23 @@ class GoogleWifiSensor(SensorEntity):
entity_description: GoogleWifiSensorEntityDescription entity_description: GoogleWifiSensorEntityDescription
def __init__(self, api, name, description: GoogleWifiSensorEntityDescription): def __init__(
self,
api: GoogleWifiAPI,
name: str,
description: GoogleWifiSensorEntityDescription,
) -> None:
"""Initialize a Google Wifi sensor.""" """Initialize a Google Wifi sensor."""
self.entity_description = description self.entity_description = description
self._api = api self._api = api
self._attr_name = f"{name}_{description.key}" self._attr_name = f"{name}_{description.key}"
@property @property
def available(self): def available(self) -> bool:
"""Return availability of Google Wifi API.""" """Return availability of Google Wifi API."""
return self._api.available return self._api.available
def update(self): def update(self) -> None:
"""Get the latest data from the Google Wifi API.""" """Get the latest data from the Google Wifi API."""
self._api.update() self._api.update()
if self.available: if self.available:

View File

@ -122,7 +122,7 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
"""Return the source type, eg gps or router, of the device.""" """Return the source type, eg gps or router, of the device."""
return SourceType.GPS return SourceType.GPS
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Register state update callback.""" """Register state update callback."""
await super().async_added_to_hass() await super().async_added_to_hass()
self._unsub_dispatcher = async_dispatcher_connect( self._unsub_dispatcher = async_dispatcher_connect(
@ -158,7 +158,7 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
} }
self._battery = attr.get(ATTR_BATTERY_LEVEL) self._battery = attr.get(ATTR_BATTERY_LEVEL)
async def async_will_remove_from_hass(self): async def async_will_remove_from_hass(self) -> None:
"""Clean up after entity before removal.""" """Clean up after entity before removal."""
await super().async_will_remove_from_hass() await super().async_will_remove_from_hass()
self._unsub_dispatcher() self._unsub_dispatcher()

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from greeclimate.device import ( from greeclimate.device import (
TEMP_MAX, TEMP_MAX,
@ -166,7 +167,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
"""Return the target temperature for the device.""" """Return the target temperature for the device."""
return self.coordinator.device.target_temperature return self.coordinator.device.target_temperature
async def async_set_temperature(self, **kwargs): async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature.""" """Set new target temperature."""
if ATTR_TEMPERATURE not in kwargs: if ATTR_TEMPERATURE not in kwargs:
raise ValueError(f"Missing parameter {ATTR_TEMPERATURE}") raise ValueError(f"Missing parameter {ATTR_TEMPERATURE}")
@ -265,7 +266,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
return PRESET_BOOST return PRESET_BOOST
return PRESET_NONE return PRESET_NONE
async def async_set_preset_mode(self, preset_mode): async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode.""" """Set new preset mode."""
if preset_mode not in PRESET_MODES: if preset_mode not in PRESET_MODES:
raise ValueError(f"Invalid preset mode: {preset_mode}") raise ValueError(f"Invalid preset mode: {preset_mode}")
@ -304,7 +305,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
speed = self.coordinator.device.fan_speed speed = self.coordinator.device.fan_speed
return FAN_MODES.get(speed) return FAN_MODES.get(speed)
async def async_set_fan_mode(self, fan_mode): async def async_set_fan_mode(self, fan_mode: str) -> None:
"""Set new target fan mode.""" """Set new target fan mode."""
if fan_mode not in FAN_MODES_REVERSE: if fan_mode not in FAN_MODES_REVERSE:
raise ValueError(f"Invalid fan mode: {fan_mode}") raise ValueError(f"Invalid fan mode: {fan_mode}")
@ -332,7 +333,7 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
return SWING_VERTICAL return SWING_VERTICAL
return SWING_OFF return SWING_OFF
async def async_set_swing_mode(self, swing_mode): async def async_set_swing_mode(self, swing_mode: str) -> None:
"""Set new target swing operation.""" """Set new target swing operation."""
if swing_mode not in SWING_MODES: if swing_mode not in SWING_MODES:
raise ValueError(f"Invalid swing mode: {swing_mode}") raise ValueError(f"Invalid swing mode: {swing_mode}")

View File

@ -1,6 +1,8 @@
"""Support for interface with a Gree climate systems.""" """Support for interface with a Gree climate systems."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -60,13 +62,13 @@ class GreePanelLightSwitchEntity(GreeEntity, SwitchEntity):
"""Return if the light is turned on.""" """Return if the light is turned on."""
return self.coordinator.device.light return self.coordinator.device.light
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on.""" """Turn the entity on."""
self.coordinator.device.light = True self.coordinator.device.light = True
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off.""" """Turn the entity off."""
self.coordinator.device.light = False self.coordinator.device.light = False
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
@ -90,13 +92,13 @@ class GreeQuietModeSwitchEntity(GreeEntity, SwitchEntity):
"""Return if the state is turned on.""" """Return if the state is turned on."""
return self.coordinator.device.quiet return self.coordinator.device.quiet
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on.""" """Turn the entity on."""
self.coordinator.device.quiet = True self.coordinator.device.quiet = True
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off.""" """Turn the entity off."""
self.coordinator.device.quiet = False self.coordinator.device.quiet = False
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
@ -120,13 +122,13 @@ class GreeFreshAirSwitchEntity(GreeEntity, SwitchEntity):
"""Return if the state is turned on.""" """Return if the state is turned on."""
return self.coordinator.device.fresh_air return self.coordinator.device.fresh_air
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on.""" """Turn the entity on."""
self.coordinator.device.fresh_air = True self.coordinator.device.fresh_air = True
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off.""" """Turn the entity off."""
self.coordinator.device.fresh_air = False self.coordinator.device.fresh_air = False
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
@ -150,13 +152,13 @@ class GreeXFanSwitchEntity(GreeEntity, SwitchEntity):
"""Return if the state is turned on.""" """Return if the state is turned on."""
return self.coordinator.device.xfan return self.coordinator.device.xfan
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on.""" """Turn the entity on."""
self.coordinator.device.xfan = True self.coordinator.device.xfan = True
await self.coordinator.push_state_update() await self.coordinator.push_state_update()
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the entity off.""" """Turn the entity off."""
self.coordinator.device.xfan = False self.coordinator.device.xfan = False
await self.coordinator.push_state_update() await self.coordinator.push_state_update()

View File

@ -171,7 +171,7 @@ class GrowattInverter(SensorEntity):
return self.probe.get_data("currency") return self.probe.get_data("currency")
return super().native_unit_of_measurement return super().native_unit_of_measurement
def update(self): def update(self) -> None:
"""Get the latest data from the Growat API and updates the state.""" """Get the latest data from the Growat API and updates the state."""
self.probe.update() self.probe.update()

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from gsp import GstreamerPlayer from gsp import GstreamerPlayer
import voluptuous as vol import voluptuous as vol
@ -78,7 +79,7 @@ class GstreamerDevice(MediaPlayerEntity):
self._artist = None self._artist = None
self._album = None self._album = None
def update(self): def update(self) -> None:
"""Update properties.""" """Update properties."""
self._state = self._player.state self._state = self._player.state
self._volume = self._player.volume self._volume = self._player.volume
@ -88,11 +89,13 @@ class GstreamerDevice(MediaPlayerEntity):
self._album = self._player.album self._album = self._player.album
self._artist = self._player.artist self._artist = self._player.artist
def set_volume_level(self, volume): def set_volume_level(self, volume: float) -> None:
"""Set the volume level.""" """Set the volume level."""
self._player.volume = volume self._player.volume = volume
async def async_play_media(self, media_type, media_id, **kwargs): async def async_play_media(
self, media_type: str, media_id: str, **kwargs: Any
) -> None:
"""Play media.""" """Play media."""
# Handle media_source # Handle media_source
if media_source.is_media_source_id(media_id): if media_source.is_media_source_id(media_id):
@ -109,15 +112,15 @@ class GstreamerDevice(MediaPlayerEntity):
await self.hass.async_add_executor_job(self._player.queue, media_id) await self.hass.async_add_executor_job(self._player.queue, media_id)
def media_play(self): def media_play(self) -> None:
"""Play.""" """Play."""
self._player.play() self._player.play()
def media_pause(self): def media_pause(self) -> None:
"""Pause.""" """Pause."""
self._player.pause() self._player.pause()
def media_next_track(self): def media_next_track(self) -> None:
"""Next track.""" """Next track."""
self._player.next() self._player.next()
@ -167,7 +170,7 @@ class GstreamerDevice(MediaPlayerEntity):
return self._album return self._album
async def async_browse_media( async def async_browse_media(
self, media_content_type=None, media_content_id=None self, media_content_type: str | None = None, media_content_id: str | None = None
) -> BrowseMedia: ) -> BrowseMedia:
"""Implement the websocket media browsing helper.""" """Implement the websocket media browsing helper."""
return await media_source.async_browse_media( return await media_source.async_browse_media(