Exemplo n.º 1
0
def main():
    """
    Monitor telegrams for a specific actor and toggle it's state using kill -USR1

    Usage:
        python example_actor.py eibd_host[:port] actor_address

    Example:
        python example_actor.py localhost '0/0/20'
    """
    parser = argparse.ArgumentParser()
    parser.add_argument("host", type=str)
    parser.add_argument("actor", type=str)
    args = parser.parse_args()

    host, port = parse_host_and_port(args.host)
    print('Creating connection to {host}:{port}'.format(host=host, port=port))

    conn = connect(host=host, port=port)
    actor = Actor(args.actor, conn.write)
    loop = asyncio.get_event_loop()
    loop.add_signal_handler(signal.SIGUSR1, actor.toggle)
    print('Use "kill -USR1 {pid}" to toggle state'.format(pid=os.getpid()))
    loop.call_soon(lambda: conn.read(actor.address))  # read request for initial state
    try:
        loop.run_until_complete(conn.bus_monitor(actor))
    except KeyboardInterrupt:
        print('Byte')
    finally:
        loop.close()
Exemplo n.º 2
0
 def test_connect_connects_to_socket(self, socket):
     sock = MagicMock()
     socket.return_value = sock
     with knx.connect('localhost'):
         sock.connect.assert_called_once_with(('localhost', 6720))
         sock.send.assert_called_once_with(b'\x00\x05\x00&\x00\x00\x00')
     sock.close.assert_called_with()
Exemplo n.º 3
0
 def test_connect_connects_to_socket(self, socket):
     sock = MagicMock()
     socket.return_value = sock
     with knx.connect('localhost'):
         sock.connect.assert_called_once_with(('localhost', 6720))
         sock.send.assert_called_once_with(b'\x00\x05\x00&\x00\x00\x00')
     sock.close.assert_called_with()
Exemplo n.º 4
0
def main():
    connection = knx.connect(host='192.168.4.214', port=3671)
    return connection
Exemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-


from knx import connect


with connect('nuc') as c:
    c.read('0/0/20')
Exemplo n.º 6
0
#!/usr/bin/env python

from knx import connect

with connect('nuc') as c:
    c.write('0/0/20', 1)