How to use bellows - 10 common examples

To help you get started, we’ve selected a few bellows examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zigpy / bellows / tests / test_application.py View on Github external
def _test_startup(app, nwk_type, ieee, auto_form=False, init=0, ezsp_version=4):
    async def mockezsp(*args, **kwargs):
        return [0, nwk_type]

    async def mockinit(*args, **kwargs):
        return [init]

    app._in_flight_msg = None
    ezsp_mock = mock.MagicMock(spec_set=bellows.ezsp.EZSP)
    type(ezsp_mock.return_value).ezsp_version = mock.PropertyMock(
        return_value=ezsp_version
    )
    ezsp_mock.return_value.connect = CoroutineMock()
    ezsp_mock.return_value.setConcentrator = CoroutineMock()
    ezsp_mock.return_value._command = mockezsp
    ezsp_mock.return_value.addEndpoint = mockezsp
    ezsp_mock.return_value.setConfigurationValue = mockezsp
    ezsp_mock.return_value.networkInit = mockinit
    ezsp_mock.return_value.getNetworkParameters = mockezsp
    ezsp_mock.return_value.setPolicy = mockezsp
    ezsp_mock.return_value.getNodeId = mockezsp
    ezsp_mock.return_value.getEui64.side_effect = CoroutineMock(return_value=[ieee])
    ezsp_mock.return_value.leaveNetwork = mockezsp
    app.form_network = CoroutineMock()
    ezsp_mock.return_value.reset.side_effect = CoroutineMock()
github zigpy / bellows / tests / test_types.py View on Github external
def test_str():
    assert str(t.EzspStatus.deserialize(b"\0")[0]) == "EzspStatus.SUCCESS"
github zigpy / bellows / tests / test_zcl.py View on Github external
def test_unknown_cluster():
    c = zcl.Cluster.from_id(None, 999)
    assert isinstance(c, zcl.Cluster)
    assert c.cluster_id == 999
github zigpy / bellows / tests / test_zcl_clusters.py View on Github external
def test_time_cluster():
    ep = mock.MagicMock()
    ep.device = mock.MagicMock()
    t = zcl.Cluster._registry[0x000a](ep)

    aps_frame = 0
    tsn = 0

    t.handle_cluster_request(aps_frame, tsn, 1, [[0]])
    assert ep.device.reply.call_count == 0

    t.handle_cluster_request(aps_frame, tsn, 0, [[0]])
    assert ep.device.reply.call_count == 1
    assert ep.device.reply.call_args[0][1][3] == 0

    t.handle_cluster_request(aps_frame, tsn, 0, [[1]])
    assert ep.device.reply.call_count == 2
    assert ep.device.reply.call_args[0][1][3] == 1

    t.handle_cluster_request(aps_frame, tsn, 0, [[2]])
github zigpy / bellows / tests / test_endpoint.py View on Github external
def test_get_aps():
    app_mock = mock.MagicMock()
    ieee = t.EmberEUI64(map(t.uint8_t, [0, 1, 2, 3, 4, 5, 6, 7]))
    dev = device.Device(app_mock, ieee, 65535)
    ep = endpoint.Endpoint(dev, 55)
    ep.status = endpoint.Status.ZDO_INIT
    ep.profile_id = 99
    aps = ep.get_aps(255)
    assert aps.profileId == 99
    assert aps.clusterId == 255
    assert aps.sourceEndpoint == 55
    assert aps.destinationEndpoint == 55
github zigpy / bellows / tests / test_application.py View on Github external
def test_frame_handler_zdo_annce(app, aps, ieee):
    aps.destinationEndpoint = 0
    app.handle_join = mock.MagicMock()
    nwk = t.uint16_t(0xAA55)
    data = b"\x18" + nwk.serialize() + ieee.serialize()
    _frame_handler(app, aps, ieee, 0, cluster=0x0013, data=data)
    assert app.handle_message.call_count == 1
    assert app.handle_message.call_args[0][5] is data
    assert app.handle_join.call_count == 1
    assert app.handle_join.call_args[0][0] == nwk
    assert app.handle_join.call_args[0][1] == ieee
github zigpy / bellows / tests / test_application.py View on Github external
def ieee(init=0):
    return t.EmberEUI64(map(t.uint8_t, range(init, init + 8)))
github zigpy / bellows / tests / test_appdb.py View on Github external
def ieee(init=0):
    return t.EmberEUI64(map(t.uint8_t, range(init, init + 8)))
github zigpy / bellows / tests / test_zdo.py View on Github external
def zdo_f():
    app = mock.MagicMock()
    app.ieee = t.EmberEUI64(map(t.uint8_t, [8, 9, 10, 11, 12, 13, 14, 15]))
    app.get_sequence = mock.MagicMock(return_value=123)
    ieee = t.EmberEUI64(map(t.uint8_t, [0, 1, 2, 3, 4, 5, 6, 7]))
    dev = bellows.zigbee.device.Device(app, ieee, 65535)
    return zdo.ZDO(dev)
github zigpy / bellows / tests / test_zdo_types.py View on Github external
def test_multi_address_3():
    ma = types.MultiAddress()
    ma.addrmode = 3
    ma.ieee = t.EmberEUI64(map(t.uint8_t, [0, 1, 2, 3, 4, 5, 6, 7]))
    ma.endpoint = 1
    ser = ma.serialize()

    ma2, data = types.MultiAddress.deserialize(ser)
    assert data == b''
    assert ma2.addrmode == ma.addrmode
    assert ma2.ieee == ma.ieee
    assert ma2.endpoint == ma.endpoint