Example #1
0
def test_creation():

    uid = 'zwave:device:controller:node15:sensor_luminance'
    name = 'ZWaveItem1'

    o = ItemChannelLinkDefinition(item_name=name, channel_uid=uid)
    assert o.channel_uid == uid
    assert o.item_name == name
    assert o.configuration == {}

    assert o.dict(by_alias=True) == {
        "channelUID": "zwave:device:controller:node15:sensor_luminance",
        "itemName": "ZWaveItem1",
        "configuration": {}
    }
Example #2
0
async def async_get_channel_link(channel_uid: str, item_name: str) -> ItemChannelLinkDefinition:
    ret = await get(__get_link_url(channel_uid, item_name), log_404=False)
    if ret.status == 404:
        raise LinkNotFoundError(f'Link {item_name} -> {channel_uid} not found!')
    if ret.status >= 300:
        return None
    else:
        return ItemChannelLinkDefinition(**await ret.json(encoding='utf-8'))
Example #3
0
def test_simple():
    _in = {
        "channelUID": "zwave:device:controller:node15:sensor_luminance",
        "configuration": {},
        "itemName": "ZWaveItem1"
    }
    o = ItemChannelLinkDefinition(**_in)
    assert o.channel_uid == 'zwave:device:controller:node15:sensor_luminance'
    assert o.item_name == 'ZWaveItem1'
Example #4
0
def test_configuration():
    _in = {
        "channelUID": "zwave:device:controller:node15:sensor_luminance",
        "configuration": {
            'profile': 'follow',
            'offset': 1,
        },
        "itemName": "ZWaveItem1"
    }
    o = ItemChannelLinkDefinition(**_in)
    assert o.channel_uid == 'zwave:device:controller:node15:sensor_luminance'
    assert o.item_name == 'ZWaveItem1'
    assert o.configuration == {'profile': 'follow', 'offset': 1}