当前位置: 首页>>代码示例>>Python>>正文


Python MockNode.stats['lastReceivedMessage'][5]方法代码示例

本文整理汇总了Python中tests.mock.zwave.MockNode.stats['lastReceivedMessage'][5]方法的典型用法代码示例。如果您正苦于以下问题:Python MockNode.stats['lastReceivedMessage'][5]方法的具体用法?Python MockNode.stats['lastReceivedMessage'][5]怎么用?Python MockNode.stats['lastReceivedMessage'][5]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.mock.zwave.MockNode的用法示例。


在下文中一共展示了MockNode.stats['lastReceivedMessage'][5]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_track_message_workaround

# 需要导入模块: from tests.mock.zwave import MockNode [as 别名]
# 或者: from tests.mock.zwave.MockNode import stats['lastReceivedMessage'][5] [as 别名]
def test_track_message_workaround(mock_openzwave):
    """Test value changed for Z-Wave lock by alarm-clearing workaround."""
    node = MockNode(manufacturer_id='003B', product_id='5044',
                    stats={'lastReceivedMessage': [0] * 6})
    values = MockEntityValues(
        primary=MockValue(data=True, node=node),
        access_control=None,
        alarm_type=None,
        alarm_level=None,
    )

    # Here we simulate an RF lock. The first zwave.get_device will call
    # update properties, simulating the first DoorLock report. We then trigger
    # a change, simulating the openzwave automatic refreshing behavior (which
    # is enabled for at least the lock that needs this workaround)
    node.stats['lastReceivedMessage'][5] = const.COMMAND_CLASS_DOOR_LOCK
    device = zwave.get_device(node=node, values=values)
    value_changed(values.primary)
    assert device.is_locked
    assert device.device_state_attributes[zwave.ATTR_NOTIFICATION] == 'RF Lock'

    # Simulate a keypad unlock. We trigger a value_changed() which simulates
    # the Alarm notification received from the lock. Then, we trigger
    # value_changed() to simulate the automatic refreshing behavior.
    values.access_control = MockValue(data=6, node=node)
    values.alarm_type = MockValue(data=19, node=node)
    values.alarm_level = MockValue(data=3, node=node)
    node.stats['lastReceivedMessage'][5] = const.COMMAND_CLASS_ALARM
    value_changed(values.access_control)
    node.stats['lastReceivedMessage'][5] = const.COMMAND_CLASS_DOOR_LOCK
    values.primary.data = False
    value_changed(values.primary)
    assert not device.is_locked
    assert device.device_state_attributes[zwave.ATTR_LOCK_STATUS] == \
        'Unlocked with Keypad by user 3'

    # Again, simulate an RF lock.
    device.lock()
    node.stats['lastReceivedMessage'][5] = const.COMMAND_CLASS_DOOR_LOCK
    value_changed(values.primary)
    assert device.is_locked
    assert device.device_state_attributes[zwave.ATTR_NOTIFICATION] == 'RF Lock'
开发者ID:Martwall,项目名称:home-assistant,代码行数:44,代码来源:test_zwave.py


注:本文中的tests.mock.zwave.MockNode.stats['lastReceivedMessage'][5]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。