Skip to content

Commit

Permalink
fix: add relevant icons to switches
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Sep 21, 2019
1 parent fd44b7c commit a66364d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions custom_components/alexa_media/switch.py
Expand Up @@ -246,6 +246,15 @@ def device_info(self):
'via_device': (ALEXA_DOMAIN, self._client.unique_id),
}

@property
def icon(self):
"""Return the icon of the switch."""
return self._icon()

def _icon(self, on=None, off=None):
return on if self.is_on else off


class DNDSwitch(AlexaMediaSwitch):
"""Representation of a Alexa Media Do Not Disturb switch."""

Expand All @@ -259,6 +268,10 @@ def __init__(self, client, account):
account,
"do not disturb")

@property
def icon(self):
"""Return the icon of the switch."""
return super()._icon("mdi:do-not-disturb", "mdi:do-not-disturb-off")

class ShuffleSwitch(AlexaMediaSwitch):
"""Representation of a Alexa Media Shuffle switch."""
Expand All @@ -273,6 +286,10 @@ def __init__(self, client, account):
account,
"shuffle")

@property
def icon(self):
"""Return the icon of the switch."""
return super()._icon("mdi:shuffle", "mdi:shuffle-disabled")

class RepeatSwitch(AlexaMediaSwitch):
"""Representation of a Alexa Media Repeat switch."""
Expand All @@ -286,3 +303,8 @@ def __init__(self, client, account):
client.alexa_api.repeat,
account,
"repeat")

@property
def icon(self):
"""Return the icon of the switch."""
return super()._icon("mdi:repeat", "mdi:repeat-off")

0 comments on commit a66364d

Please sign in to comment.