Exemple #1
0
async def test_interview(mocknode: Node):
    mocknode.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=Version.COMMAND_CLASS_VERSION,
            commandClassVersion=4,
        ))
    mocknode.queue(
        Version.VersionReport(
            zwaveLibraryType=6,
            zwaveProtocolVersion=1,
            zwaveProtocolSubVersion=2,
            applicationVersion=1,
            applicationSubVersion=0,
        ))
    await mocknode.interview()
    assert mocknode.supported[Version.COMMAND_CLASS_VERSION].version == 4
def associationgrpinfo() -> AssociationGrpInfo.AssociationGrpInfo:
    node = MockNode([AssociationGrpInfo.COMMAND_CLASS_ASSOCIATION_GRP_INFO])
    node.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=Version.COMMAND_CLASS_VERSION,
            commandClassVersion=1,
        ))
    node.reply(
        AssociationGrpInfo.GroupNameGet,
        AssociationGrpInfo.GroupNameReport(groupingIdentifier=1,
                                           name="Lifeline"),
    )
    node.reply(
        AssociationGrpInfo.GroupCommandListGet,
        AssociationGrpInfo.GroupCommandListReport(groupingIdentifier=1,
                                                  commandClass=[[1, 2], [3,
                                                                         4]]),
    )
    # node.queue(Association.GroupingsReport(supportedGroupings=1,))
    # node.queue(
    #     MultiChannelAssociation.MultiChannelReport(
    #         groupingIdentifier=1,
    #         maxNodesSupported=1,
    #         reportsToFollow=0,
    #         nodes=[(1, None), (2, 0)],
    #     )
    # )
    # node.queue(
    #     Association.Report(
    #         groupingIdentifier=1, maxNodesSupported=1, reportsToFollow=0, nodes=[1]
    #     )
    # )
    return node.supported[
        AssociationGrpInfo.COMMAND_CLASS_ASSOCIATION_GRP_INFO]
Exemple #3
0
def version() -> Version.Version:
    node = MockNode([Version.COMMAND_CLASS_VERSION])
    node.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=Version.COMMAND_CLASS_VERSION, commandClassVersion=4,
        )
    )
    node.queue(
        Version.VersionReport(
            zwaveLibraryType=6,
            zwaveProtocolVersion=1,
            zwaveProtocolSubVersion=2,
            applicationVersion=1,
            applicationSubVersion=0,
        )
    )
    node.supported[Version.COMMAND_CLASS_VERSION].__setstate__({"zwaveLibraryType": 6})
    return node.supported[Version.COMMAND_CLASS_VERSION]
Exemple #4
0
def manufacturerSpecific() -> ManufacturerSpecific.ManufacturerSpecific:
    node = MockNode([ManufacturerSpecific.COMMAND_CLASS_MANUFACTURER_SPECIFIC])
    node.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=Version.COMMAND_CLASS_VERSION, commandClassVersion=1,
        )
    )
    node.queue(
        ManufacturerSpecific.Report(manufacturerID=1, productTypeID=2, productID=3,)
    )
    return node.supported[ManufacturerSpecific.COMMAND_CLASS_MANUFACTURER_SPECIFIC]
def multilevelSensor() -> SensorMultilevel.SensorMultilevel:
    node = MockNode([SensorMultilevel.COMMAND_CLASS_SENSOR_MULTILEVEL])
    node.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=SensorMultilevel.
            COMMAND_CLASS_SENSOR_MULTILEVEL,
            commandClassVersion=5,
        ))
    node.queue(SensorMultilevel.SupportedSensorReport(bitMask=[1]))
    node.queue(
        SensorMultilevel.SupportedScaleReport(sensorType=1, scaleBitMask=3))
    return node.supported[SensorMultilevel.COMMAND_CLASS_SENSOR_MULTILEVEL]
def zwavePlusInfo() -> ZwavePlusInfo.ZwavePlusInfo:
    node = MockNode([ZwavePlusInfo.COMMAND_CLASS_ZWAVEPLUS_INFO])
    node.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=Version.COMMAND_CLASS_VERSION,
            commandClassVersion=1,
        ))
    node.queue(
        ZwavePlusInfo.Report(
            zwavePlusVersion=1,
            roleType=5,
            nodeType=0,
            installerIconType=1793,
            userIconType=1792,
        ))
    return node.supported[ZwavePlusInfo.COMMAND_CLASS_ZWAVEPLUS_INFO]
Exemple #7
0
def association() -> Association.Association:
    node = MockNode([Association.COMMAND_CLASS_ASSOCIATION])
    node.queue(
        Version.VersionCommandClassReport(
            requestedCommandClass=Version.COMMAND_CLASS_VERSION,
            commandClassVersion=1,
        ))
    node.queue(Association.GroupingsReport(supportedGroupings=1, ))
    node.queue(
        MultiChannelAssociation.MultiChannelReport(
            groupingIdentifier=1,
            maxNodesSupported=1,
            reportsToFollow=0,
            nodes=[(1, None), (2, 0)],
        ))
    node.queue(
        Association.Report(groupingIdentifier=1,
                           maxNodesSupported=1,
                           reportsToFollow=0,
                           nodes=[1]))
    return node.supported[Association.COMMAND_CLASS_ASSOCIATION]
Exemple #8
0
async def test_send(version: Version.Version):
    await version.send(Version.VersionGet())
    version.node.assert_message_sent(Version.VersionGet())
Exemple #9
0
async def test_handleMessage(version: Version.Version):
    listener = MagicMock()
    listener.onVersionCommandClassReport.return_value = True
    version.addListener(listener)
    assert await version.handleMessage(Version.VersionCommandClassReport(), 0) is True
    listener.onVersionCommandClassReport.assert_called_once()
Exemple #10
0
def test_getstate(version: Version):
    assert version.__getstate__() == {
        "version": 0,
        "interviewed": False,
        "zwaveLibraryType": 6,
    }