コード例 #1
0
    """Cleanup tasks tied to the service's shutdown."""
    if signal:
        print(f"Received exit signal {signal.name}...")
    tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]
    [task.cancel() for task in tasks]
    await asyncio.gather(*tasks, return_exceptions=True)
    loop.stop()


def main():
    loop = asyncio.get_event_loop()
    # May want to catch other signals too


if __name__ == '__main__':
    pyvisonic.setupLocalLogger(
        "DEBUG", True)  # one of "WARNING"  "INFO"  "ERROR"   "DEBUG"
    print("Starting")

    testloop = asyncio.get_event_loop()
    testloop.set_exception_handler(handle_exception)

    client = VisonicClient(loop=testloop, config=myconfig)
    if client is not None:
        success = True  #client.connect(wait_sleep=False, wait_loop=True)
        if success:
            try:
                console = MyAsyncConsole()
                #console.__init_ui = MethodType(my_init_ui, console)
                console.title('Visonic Alarm Panel Test')
                testloop.create_task(console.mainloop())
                testloop.create_task(controller(client, console))
コード例 #2
0
ファイル: test.py プロジェクト: olijouve/visonic
        return
    if type(visonic_devices) == defaultdict:
        log.warning("Visonic got new sensors {0}".format( visonic_devices ))
    elif type(visonic_devices) == pyvisonic.SensorDevice:
        # This is an update of an existing device
        log.warning("Visonic got a sensor update {0}".format( visonic_devices ))
        
    #elif type(visonic_devices) == visonicApi.SwitchDevice:   # doesnt exist yet
    
    else:
        log.warning("Visonic attempt to add device with type {0}  device is {1}".format(type(visonic_devices), visonic_devices ))

logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)

pyvisonic.setupLocalLogger()

pyvisonic.setConfig("OverrideCode", -1)
# pyvisonic.setConfig("PluginDebug", True)
pyvisonic.setConfig("ForceStandard", False)

conn = None

parser = argparse.ArgumentParser(description="Connect to Visonic Alarm Panel")
parser.add_argument("-usb", help="visonic alarm usb device", default = '')
parser.add_argument("-address", help="visonic alarm ip address", default = '')
parser.add_argument("-port", help="visonic alarm ip port", type=int)
args = parser.parse_args()

testloop = asyncio.get_event_loop()
コード例 #3
0
            new_sensor_callback=new_sensor_callback,
            new_switch_callback=new_switch_callback)

        while True:
            print("You can do stuff here with visonicProtocol, Mode=",
                  visonicProtocol.getPanelMode())
            await asyncio.sleep(5.0)
    else:
        print("Please check you command line parameters")


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    _LOGGER = logging.getLogger(__name__)

    pyvisonic.setupLocalLogger("DEBUG")

    parser = argparse.ArgumentParser(
        description="Connect to Visonic Alarm Panel")
    parser.add_argument("-usb", help="visonic alarm usb device", default="")
    parser.add_argument("-address",
                        help="visonic alarm ip address",
                        default="")
    parser.add_argument("-port", help="visonic alarm ip port", type=int)
    args = parser.parse_args()

    testloop = asyncio.get_event_loop()

    task = testloop.create_task(startitall(testloop))
    try:
        print("Calling run_forever")