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


Python zwave.value_changed函数代码示例

本文整理汇总了Python中tests.mock.zwave.value_changed函数的典型用法代码示例。如果您正苦于以下问题:Python value_changed函数的具体用法?Python value_changed怎么用?Python value_changed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了value_changed函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_temperature_unit

def test_temperature_unit(device):
    """Test temperature unit."""
    assert device.temperature_unit == TEMP_CELSIUS
    device.values.temperature.units = 'F'
    value_changed(device.values.temperature)
    assert device.temperature_unit == TEMP_FAHRENHEIT
    device.values.temperature.units = 'C'
    value_changed(device.values.temperature)
    assert device.temperature_unit == TEMP_CELSIUS
开发者ID:azogue,项目名称:home-assistant,代码行数:9,代码来源:test_zwave.py

示例2: test_switch_value_changed

def test_switch_value_changed(mock_openzwave):
    """Test value changed for Z-Wave switch."""
    node = MockNode()
    value = MockValue(data=False, node=node)
    values = MockEntityValues(primary=value)
    device = zwave.get_device(node=node, values=values, node_config={})

    assert not device.is_on

    value.data = True
    value_changed(value)

    assert device.is_on
开发者ID:azogue,项目名称:home-assistant,代码行数:13,代码来源:test_zwave.py

示例3: test_alarm_sensor_value_changed

def test_alarm_sensor_value_changed(mock_openzwave):
    """Test value changed for Z-Wave sensor."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_ALARM,
                                     const.COMMAND_CLASS_SENSOR_ALARM])
    value = MockValue(data=12.34, node=node, units='%')
    values = MockEntityValues(primary=value)

    device = sensor.get_device(node=node, values=values, node_config={})
    assert device.state == 12.34
    assert device.unit_of_measurement == '%'
    value.data = 45.67
    value_changed(value)
    assert device.state == 45.67
开发者ID:arsaboo,项目名称:home-assistant,代码行数:13,代码来源:test_sensor.py

示例4: test_dimmer_value_changed

def test_dimmer_value_changed(mock_openzwave):
    """Test value changed for dimmer lights."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    device = zwave.get_device(node, value, {})

    assert not device.is_on

    value.data = 46
    value_changed(value)

    assert device.is_on
    assert device.brightness == 118
开发者ID:zebpalmer,项目名称:home-assistant,代码行数:13,代码来源:test_zwave.py

示例5: test_multilevelsensor_value_changed_integer

def test_multilevelsensor_value_changed_integer(mock_openzwave):
    """Test value changed for Z-Wave multilevel sensor for other units."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,
                                     const.COMMAND_CLASS_METER])
    value = MockValue(data=5, units='counts', node=node)
    values = MockEntityValues(primary=value)

    device = sensor.get_device(node=node, values=values, node_config={})
    assert device.state == 5
    assert device.unit_of_measurement == 'counts'
    value.data = 6
    value_changed(value)
    assert device.state == 6
开发者ID:arsaboo,项目名称:home-assistant,代码行数:13,代码来源:test_sensor.py

示例6: test_multilevelsensor_value_changed_temp_fahrenheit

def test_multilevelsensor_value_changed_temp_fahrenheit(mock_openzwave):
    """Test value changed for Z-Wave multilevel sensor for temperature."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,
                                     const.COMMAND_CLASS_METER])
    value = MockValue(data=190.95555, units='F', node=node)
    values = MockEntityValues(primary=value)

    device = zwave.get_device(node=node, values=values, node_config={})
    assert device.state == 191.0
    assert device.unit_of_measurement == homeassistant.const.TEMP_FAHRENHEIT
    value.data = 197.95555
    value_changed(value)
    assert device.state == 198.0
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:13,代码来源:test_zwave.py

示例7: test_multilevelsensor_value_changed_temp_celsius

def test_multilevelsensor_value_changed_temp_celsius(mock_openzwave):
    """Test value changed for Z-Wave multilevel sensor for temperature."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_SENSOR_MULTILEVEL,
                                     const.COMMAND_CLASS_METER])
    value = MockValue(data=38.85555, units='C', node=node)
    values = MockEntityValues(primary=value)

    device = sensor.get_device(node=node, values=values, node_config={})
    assert device.state == 38.9
    assert device.unit_of_measurement == homeassistant.const.TEMP_CELSIUS
    value.data = 37.95555
    value_changed(value)
    assert device.state == 38.0
开发者ID:arsaboo,项目名称:home-assistant,代码行数:13,代码来源:test_sensor.py

示例8: test_switch_garage_value_changed

def test_switch_garage_value_changed(hass, mock_openzwave):
    """Test position changed."""
    node = MockNode()
    value = MockValue(data=False, node=node,
                      command_class=const.COMMAND_CLASS_SWITCH_BINARY)
    values = MockEntityValues(primary=value, node=node)
    device = cover.get_device(hass=hass, node=node, values=values,
                              node_config={})

    assert device.is_closed

    value.data = True
    value_changed(value)
    assert not device.is_closed
开发者ID:arsaboo,项目名称:home-assistant,代码行数:14,代码来源:test_cover.py

示例9: test_dimmer_value_changed

def test_dimmer_value_changed(mock_openzwave):
    """Test value changed for dimmer lights."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    values = MockLightValues(primary=value)
    device = light.get_device(node=node, values=values, node_config={})

    assert not device.is_on

    value.data = 46
    value_changed(value)

    assert device.is_on
    assert device.brightness == 118
开发者ID:arsaboo,项目名称:home-assistant,代码行数:14,代码来源:test_light.py

示例10: test_binary_sensor_value_changed

def test_binary_sensor_value_changed(mock_openzwave):
    """Test value changed for binary sensor."""
    node = MockNode()
    value = MockValue(data=False, node=node,
                      command_class=const.COMMAND_CLASS_SENSOR_BINARY)
    values = MockEntityValues(primary=value)
    device = zwave.get_device(node=node, values=values, node_config={})

    assert not device.is_on

    value.data = True
    value_changed(value)

    assert device.is_on
开发者ID:PetitCircuitLab,项目名称:home-assistant,代码行数:14,代码来源:test_zwave.py

示例11: test_garage_value_changed

def test_garage_value_changed(mock_openzwave):
    """Test position changed."""
    node = MockNode()
    value = MockValue(data=False, node=node,
                      command_class=const.COMMAND_CLASS_BARRIER_OPERATOR)
    values = MockEntityValues(primary=value, node=node)
    device = zwave.get_device(node=node, values=values, node_config={})

    assert device.is_closed

    value.data = True
    value_changed(value)

    assert not device.is_closed
开发者ID:nunofgs,项目名称:home-assistant,代码行数:14,代码来源:test_zwave.py

示例12: test_lock_alarm_type

def test_lock_alarm_type(mock_openzwave):
    """Test alarm type for Z-Wave lock."""
    node = MockNode()
    values = MockEntityValues(
        primary=MockValue(data=None, node=node),
        access_control=None,
        alarm_type=MockValue(data=None, node=node),
        alarm_level=None,
    )
    device = zwave.get_device(node=node, values=values, node_config={})

    assert zwave.ATTR_LOCK_STATUS not in device.device_state_attributes

    values.alarm_type.data = 21
    value_changed(values.alarm_type)
    assert device.device_state_attributes[zwave.ATTR_LOCK_STATUS] == \
        'Manually Locked None'

    values.alarm_type.data = 18
    value_changed(values.alarm_type)
    assert device.device_state_attributes[zwave.ATTR_LOCK_STATUS] == \
        'Locked with Keypad by user None'

    values.alarm_type.data = 161
    value_changed(values.alarm_type)
    assert device.device_state_attributes[zwave.ATTR_LOCK_STATUS] == \
        'Tamper Alarm: None'

    values.alarm_type.data = 9
    value_changed(values.alarm_type)
    assert device.device_state_attributes[zwave.ATTR_LOCK_STATUS] == \
        'Deadbolt Jammed'
开发者ID:BaptisteSim,项目名称:home-assistant,代码行数:32,代码来源:test_zwave.py

示例13: test_lock_state_workaround

def test_lock_state_workaround(mock_openzwave):
    """Test value changed for Z-Wave lock using notification state."""
    node = MockNode(manufacturer_id='0090', product_id='0440')
    values = MockEntityValues(
        primary=MockValue(data=True, node=node),
        access_control=MockValue(data=1, node=node),
        alarm_type=None,
        alarm_level=None,
    )
    device = zwave.get_device(node=node, values=values)
    assert device.is_locked
    values.access_control.data = 2
    value_changed(values.access_control)
    assert not device.is_locked
开发者ID:Martwall,项目名称:home-assistant,代码行数:14,代码来源:test_zwave.py

示例14: test_rgbcw_value_changed

def test_rgbcw_value_changed(mock_openzwave):
    """Test value changed for rgb lights."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_SWITCH_COLOR])
    value = MockValue(data=0, node=node)
    color = MockValue(data=b'#0000000000', node=node)
    # Suppoorts RGB, Cold White
    color_channels = MockValue(data=0x1e, node=node)
    values = MockLightValues(primary=value, color=color,
                             color_channels=color_channels)
    device = zwave.get_device(node=node, values=values, node_config={})

    assert device.rgb_color == [0, 0, 0]

    color.data = b'#c86400c800'
    value_changed(color)

    assert device.rgb_color == [200, 150, 100]
开发者ID:nunofgs,项目名称:home-assistant,代码行数:17,代码来源:test_zwave.py

示例15: test_rgb_value_changed

def test_rgb_value_changed(mock_openzwave):
    """Test value changed for rgb lights."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_SWITCH_COLOR])
    value = MockValue(data=0, node=node)
    color = MockValue(data='#0000000000', node=node)
    # Supports RGB only
    color_channels = MockValue(data=0x1c, node=node)
    values = MockLightValues(primary=value, color=color,
                             color_channels=color_channels)
    device = zwave.get_device(node=node, values=values, node_config={})

    assert device.hs_color == (0, 0)

    color.data = '#ffbf800000'
    value_changed(color)

    assert device.hs_color == (29.764, 49.804)
开发者ID:chuchock,项目名称:home-assistant,代码行数:17,代码来源:test_zwave.py


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