formatting
This commit is contained in:
17
apps/tv.py
17
apps/tv.py
@@ -1,5 +1,4 @@
|
|||||||
from dataclasses import dataclass, field, fields
|
from dataclasses import dataclass, fields
|
||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
from appdaemon.entity import Entity
|
from appdaemon.entity import Entity
|
||||||
from appdaemon.plugins.hass.hassapi import Hass
|
from appdaemon.plugins.hass.hassapi import Hass
|
||||||
@@ -8,10 +7,11 @@ from appdaemon.plugins.hass.hassapi import Hass
|
|||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class SoundBar(Hass):
|
class SoundBar(Hass):
|
||||||
"""Turns on the soundbar by sending a command with the Broadlink remote.
|
"""Turns on the soundbar by sending a command with the Broadlink remote.
|
||||||
- Turns on when the playing_entity goes to playing
|
- Turns on when the playing_entity goes to playing
|
||||||
- Turns off when the off_entity turns off
|
- Turns off when the off_entity turns off
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
device: str
|
device: str
|
||||||
remote_entity: Entity
|
remote_entity: Entity
|
||||||
playing_entity: Entity
|
playing_entity: Entity
|
||||||
@@ -32,13 +32,13 @@ class SoundBar(Hass):
|
|||||||
arg = self.args[f.name]
|
arg = self.args[f.name]
|
||||||
if f.type == Entity:
|
if f.type == Entity:
|
||||||
if not self.entity_exists(arg):
|
if not self.entity_exists(arg):
|
||||||
self.log(f'{arg} does not exist', level="WARNING")
|
self.log(f'{arg} does not exist', level='WARNING')
|
||||||
else:
|
else:
|
||||||
setattr(self, f.name, self.get_entity(arg))
|
setattr(self, f.name, self.get_entity(arg))
|
||||||
else:
|
else:
|
||||||
setattr(self, f.name, arg)
|
setattr(self, f.name, arg)
|
||||||
else:
|
else:
|
||||||
self.log(f'{f.name} field is unset', level="WARNING")
|
self.log(f'{f.name} field is unset', level='WARNING')
|
||||||
self.log(repr(self))
|
self.log(repr(self))
|
||||||
|
|
||||||
def send_remote_command(self, command: str):
|
def send_remote_command(self, command: str):
|
||||||
@@ -48,10 +48,7 @@ class SoundBar(Hass):
|
|||||||
|
|
||||||
self.log(f'Sending remote command: {command}')
|
self.log(f'Sending remote command: {command}')
|
||||||
self.call_service(
|
self.call_service(
|
||||||
service='remote/send_command',
|
service='remote/send_command', entity_id=self.remote_entity.entity_id, device='BoseTV', command=command
|
||||||
entity_id=self.remote_entity.entity_id,
|
|
||||||
device='BoseTV',
|
|
||||||
command=command
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def turn_on_soundbar(self, entity=None, attribute=None, old=None, new=None, kwargs=None):
|
def turn_on_soundbar(self, entity=None, attribute=None, old=None, new=None, kwargs=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user