"""Define an app for working the Living Room TV.""" # pylint: disable=attribute-defined-outside-init,too-few-public-methods import appdaemon.plugins.hass.hassapi as hass class HarmonyRemote(hass.Hass): """Define a class to represent the Living Room TV.""" def initialize(self): """Initialize.""" self.activities = self.args['activities'] self.entity = self.args['entity'] @property def current_activity_id(self): """Get the current activity ID (Harmony).""" activity = self.get_state(self.entity, attribute='current_activity') try: return self.activities[activity.replace(' ', '_').lower()] except KeyError: return None def send_command(self, command): """Send a command to the Harmony.""" if self.current_activity_id: self.call_service( 'remote/send_command', entity_id=self.entity, device=self.current_activity_id, command=command) def pause(self): """Pause the entire thing by pausing the Harmony.""" self.send_command('Pause') def play(self): """Play the entire thing by playing the Harmony.""" self.send_command('Play')