v0.8.933 (homeassistant component)

This commit is contained in:
e2002
2023-02-12 18:18:53 +03:00
parent 8ae86ec8d3
commit 19c9f7433f
2 changed files with 14 additions and 9 deletions

View File

@@ -8,7 +8,7 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
VERSION = '0.5.010' VERSION = '0.8.933'
DOMAIN = "yoradio" DOMAIN = "yoradio"
@@ -43,7 +43,6 @@ SUPPORT_YORADIO = SUPPORT_PAUSE | SUPPORT_PLAY | SUPPORT_STOP |\
DEFAULT_NAME = 'yoRadio' DEFAULT_NAME = 'yoRadio'
CONF_MAX_VOLUME = 'max_volume' CONF_MAX_VOLUME = 'max_volume'
CONF_ROOT_TOPIC = 'root_topic' CONF_ROOT_TOPIC = 'root_topic'
YORADIO_SOURCE_TYPE = []
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ROOT_TOPIC, default="yoradio"): cv.string, vol.Required(CONF_ROOT_TOPIC, default="yoradio"): cv.string,
@@ -56,15 +55,17 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
name = config.get(CONF_NAME) name = config.get(CONF_NAME)
max_volume = int(config.get(CONF_MAX_VOLUME)) max_volume = int(config.get(CONF_MAX_VOLUME))
session = async_get_clientsession(hass) session = async_get_clientsession(hass)
api = yoradioApi(root_topic, session, hass) playlist = []
api = yoradioApi(root_topic, session, hass, playlist)
add_devices([yoradioDevice(name, max_volume, api)], True) add_devices([yoradioDevice(name, max_volume, api)], True)
class yoradioApi(): class yoradioApi():
def __init__(self, root_topic, session, hass): def __init__(self, root_topic, session, hass, playlist):
self.session = session self.session = session
self.hass = hass self.hass = hass
self.mqtt = hass.components.mqtt self.mqtt = hass.components.mqtt
self.root_topic = root_topic self.root_topic = root_topic
self.playlist = playlist
async def set_command(self, command): async def set_command(self, command):
try: try:
@@ -97,12 +98,13 @@ class yoradioApi():
else: else:
file = file.split('\n') file = file.split('\n')
counter = 1 counter = 1
YORADIO_SOURCE_TYPE.clear() self.playlist.clear()
for line in file: for line in file:
res = line.split('\t') res = line.split('\t')
station = str(counter) + '. ' + res[0] if res[0] != "":
YORADIO_SOURCE_TYPE.append(station) station = str(counter) + '. ' + res[0]
counter=counter+1 self.playlist.append(station)
counter=counter+1
class yoradioDevice(MediaPlayerEntity): class yoradioDevice(MediaPlayerEntity):
def __init__(self, name, max_volume, api): def __init__(self, name, max_volume, api):
@@ -182,7 +184,7 @@ class yoradioDevice(MediaPlayerEntity):
@property @property
def source_list(self): def source_list(self):
return YORADIO_SOURCE_TYPE return self.api.playlist
async def async_select_source(self, source): async def async_select_source(self, source):
await self.api.set_source(source) await self.api.set_source(source)

View File

@@ -223,6 +223,9 @@ Work is in progress...
--- ---
## Version history ## Version history
#### v0.8.933 (homeassistant component)
- HA component >> fixed bugs of getting and generating a playlist
#### v0.8.933 #### v0.8.933
- added support for ILI9488 display - added support for ILI9488 display
- added support for ILI9486 display in testing mode - added support for ILI9486 display in testing mode