コード例 #1
0
    def fs_device(self):
        """
        Create a fresh fsapi session.

        A new session is created for each request in case someone else
        connected to the device in between the updates and invalidated the
        existing session (i.e UNDOK).
        """
        from fsapi import FSAPI

        return FSAPI(self._device_url, self._password)
コード例 #2
0
ファイル: fsapi2mqttd.py プロジェクト: ecoenjaerts/fsapi2mqtt
    client.will_set(mqtt_pubTopic + 'LWT', 'ON', 0, False)
    log("MQTT LWT published!")

    # Blocking call that processes network traffic, dispatches callbacks and
    # handles reconnecting.
    # Other loop*() functions are available that give a threaded interface and a
    # manual interface.
    client.loop_forever()


if __name__ == '__main__':

    try:
        #	fs = FSAPI('http://192.168.2.51:80/device', 1234)
        fs = FSAPI(URL, PIN)
        if not fs == None:
            log('Name: %s' % fs.friendly_name)
            log('Version: %s' % fs.version)
            log('Mute: %s' % fs.mute)
            log('Mode: %s' % fs.mode)
            log('Power: %s' % fs.power)
            log('Volume: %s' % fs.volume)
            log('Play status: %s' % fs.play_status)
            log('Track name: %s' % fs.play_info_name)
            log('Track text: %s' % fs.play_info_text)
    except Exception as e:
        log(e)
        sys.exit(e)

    # https://pypi.org/project/paho-mqtt/
コード例 #3
0
ファイル: test_fsapi.py プロジェクト: JRInge/python-fsapi
 def test_maybe_accepts_lambda(self):
     assert FSAPI.maybe(1, lambda x: str(x)) == "1"
コード例 #4
0
ファイル: tests.py プロジェクト: sd-personal/python-fsapi
from fsapi import FSAPI

URL = 'http://192.168.1.39:80/device'
PIN = 1234
TIMEOUT = 1  # in seconds

fs = FSAPI(URL, PIN, TIMEOUT)
print('Name: %s' % fs.friendly_name)
print('Mute: %s' % fs.mute)
print('Mode: %s' % fs.mode)
print('Modes: %s' % fs.modes)
print('Power: %s' % fs.power)
print('Volume steps: %s' % fs.volume_steps)
print('Volume: %s' % fs.volume)
print('Play status: %s' % fs.play_status)
print('Track name: %s' % fs.play_info_name)
print('Track text: %s' % fs.play_info_text)
print('Artist: %s' % fs.play_info_artist)
print('Album: %s' % fs.play_info_album)
print('Graphics: %s' % fs.play_info_graphics)
コード例 #5
0
ファイル: test_fsapi.py プロジェクト: JRInge/python-fsapi
 def test_maybe_handles_str2int(self):
     assert FSAPI.maybe("1", int) == 1
コード例 #6
0
ファイル: test_fsapi.py プロジェクト: JRInge/python-fsapi
 def test_maybe_handles_None(self):
     assert FSAPI.maybe(None, int) is None
コード例 #7
0
ファイル: test_fsapi.py プロジェクト: JRInge/python-fsapi
 def test_unpack_xml_handles_None(self, xml_test_data):
     assert FSAPI.unpack_xml(None, 'status') is None
コード例 #8
0
ファイル: test_fsapi.py プロジェクト: JRInge/python-fsapi
 def test_unpack_xml_handles_l2_value(self, xml_test_data):
     assert FSAPI.unpack_xml(xml_test_data, 'value/c8_array') == 'My Radio'
コード例 #9
0
ファイル: test_fsapi.py プロジェクト: JRInge/python-fsapi
 def test_unpack_xml_handles_l1_value(self, xml_test_data):
     assert FSAPI.unpack_xml(xml_test_data, 'status') == 'FS_OK'