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)
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/
def test_maybe_accepts_lambda(self): assert FSAPI.maybe(1, lambda x: str(x)) == "1"
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)
def test_maybe_handles_str2int(self): assert FSAPI.maybe("1", int) == 1
def test_maybe_handles_None(self): assert FSAPI.maybe(None, int) is None
def test_unpack_xml_handles_None(self, xml_test_data): assert FSAPI.unpack_xml(None, 'status') is None
def test_unpack_xml_handles_l2_value(self, xml_test_data): assert FSAPI.unpack_xml(xml_test_data, 'value/c8_array') == 'My Radio'
def test_unpack_xml_handles_l1_value(self, xml_test_data): assert FSAPI.unpack_xml(xml_test_data, 'status') == 'FS_OK'