class BraviaQuery:
    def __init__(self, ip, psk):
        self.ip = ip
        self.psk = psk
        self.mac = 'AA:BB:CC:DD:EE:FF'

        self.bravia = BraviaRC(self.ip, self.psk, self.mac)

    def poll(self):
        power_status = self.bravia.get_power_status()
        led_status = 'off' if (self.bravia.get_led_status()
                               == 'SimpleResponse') else 'on'

        return {'Power': power_status(), 'LED': led_status}

    def setMute(self, isOn):
        mode = "Demo" if str(isOn).lower() == "on" else "SimpleResponse"
        print("setting LED to " + str(str(isOn).lower() == "on").lower() +
              " with mode " + mode)
        self.bravia.set_led_status(mode,
                                   str(str(isOn).lower() == "on").lower())

        print("setting AudioMute OSD with " + str(str(isOn).lower() == "on"))
        self.bravia.set_audio_mute(str(isOn).lower() == "on")

    def setVolume(self, level):
        print("setting volume to " + str(level))
        self.bravia.set_volume_level(level / 100)
Beispiel #2
0
        command_param = options.command_param
    except:
        print('Erreur de parametres')

_braviainstance = BraviaRC(ip, mac)
_braviainstance.connect(psk, 'Jeedom', 'Jeedom')

try:
    if command_type == 'turn_on':
        _braviainstance.turn_on()
    if command_type == 'turn_off':
        _braviainstance.turn_off()
    if command_type == 'select_source':
        _braviainstance.select_source(command_param)
    if command_type == 'set_volume':
        _braviainstance.set_volume_level(command_param)
    if command_type == 'start_app':
        _braviainstance.start_app(command_param)
    if command_type == 'volume_up':
        _braviainstance.volume_up()
    if command_type == 'volume_down':
        _braviainstance.volume_down()
    if command_type == 'mute_volume':
        _braviainstance.mute_volume(command_param)
    if command_type == 'play_content':
        _braviainstance.play_content(command_param)
    if command_type == 'media_play':
        _braviainstance.media_play()
    if command_type == 'media_pause':
        _braviainstance.media_pause()
    if command_type == 'media_previous_track':