This commit is contained in:
Martin Bauer
2020-05-03 14:41:27 +00:00
parent feb05f63df
commit d3c7e18d38
11 changed files with 1093 additions and 54 deletions

View File

@@ -57,7 +57,7 @@ class SispmctlHost:
async def update_state(self):
url = f"http://{self.hostname}:{self.port}"
async with self._session.get(url, timeout=20) as resp:
async with self._session.get(url, timeout=3) as resp:
if resp.status == 200:
result = await resp.json()
await self.notify_switches(result)

View File

@@ -12,4 +12,4 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
sensor = IsConnectedSensor(connection.get_name() + "_connected")
connection.connected_sensor = sensor
sensors.append(sensor)
async_add_entities(sensors)
async_add_entities(sensors)

View File

@@ -57,7 +57,13 @@ def find_local_radio_url_by_name(search_name):
if search_name.startswith('http'):
return search_name
for radioId, radio in find_local_radio_url_by_name.stations.items():
# first try: find a station that starts with the search expression
for radio_id, radio in find_local_radio_url_by_name.stations.items():
if radio['name'].lower().startswith(search_name):
return radio['url']
# second try: containment is enough
for radio_id, radio in find_local_radio_url_by_name.stations.items():
if search_name in radio['name'].lower():
return radio['url']