How to use homematicip - 10 common examples

To help you get started, we’ve selected a few homematicip 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 home-assistant / home-assistant / tests / components / homematicip_cloud / helper.py View on Github external
def get_and_check_entity_basics(
    hass, default_mock_hap, entity_id, entity_name, device_model
):
    """Get and test basic device."""
    ha_state = hass.states.get(entity_id)
    assert ha_state is not None
    if device_model:
        assert ha_state.attributes[ATTR_MODEL_TYPE] == device_model
    assert ha_state.name == entity_name

    hmip_device = default_mock_hap.hmip_device_by_entity_id.get(entity_id)

    if hmip_device:
        if isinstance(hmip_device, AsyncDevice):
            assert ha_state.attributes[ATTR_IS_GROUP] is False
        elif isinstance(hmip_device, AsyncGroup):
            assert ha_state.attributes[ATTR_IS_GROUP] is True
    return ha_state, hmip_device
github home-assistant / home-assistant / tests / components / homematicip_cloud / helper.py View on Github external
functional_channel = hmip_device.functionalChannels[channel]
        setattr(functional_channel, attribute, new_value)

    fire_target = hmip_device if fire_device is None else fire_device

    if isinstance(fire_target, AsyncHome):
        fire_target.fire_update_event(
            fire_target._rawJSONData  # pylint: disable=protected-access
        )
    else:
        fire_target.fire_update_event()

    await hass.async_block_till_done()


class HomeTemplate(Home):
    """
    Home template as builder for home mock.

    It is based on the upstream libs home class to generate hmip devices
    and groups based on the given homematicip_cloud.json.

    All further testing activities should be done by using the AsyncHome mock,
    that is generated by get_async_home_mock(self).

    The class also generated mocks of devices and groups for further testing.
    """

    _typeClassMap = TYPE_CLASS_MAP
    _typeGroupMap = TYPE_GROUP_MAP
    _typeSecurityEventMap = TYPE_SECURITY_EVENT_MAP
github home-assistant / home-assistant / tests / components / homematicip_cloud / test_light.py View on Github external
entity_name = "Treppe Top Notification"
    device_model = "HmIP-BSL"

    ha_state, hmip_device = get_and_check_entity_basics(
        hass, default_mock_hap, entity_id, entity_name, device_model
    )

    assert ha_state.state == STATE_OFF
    service_call_counter = len(hmip_device.mock_calls)

    # Send all color via service call.
    await hass.services.async_call(
        "light", "turn_on", {"entity_id": entity_id}, blocking=True
    )
    assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level"
    assert hmip_device.mock_calls[-1][1] == (2, RGBColorState.RED, 1.0)

    color_list = {
        RGBColorState.WHITE: [0.0, 0.0],
        RGBColorState.RED: [0.0, 100.0],
        RGBColorState.YELLOW: [60.0, 100.0],
        RGBColorState.GREEN: [120.0, 100.0],
        RGBColorState.TURQUOISE: [180.0, 100.0],
        RGBColorState.BLUE: [240.0, 100.0],
        RGBColorState.PURPLE: [300.0, 100.0],
    }

    for color, hs_color in color_list.items():
        await hass.services.async_call(
            "light",
            "turn_on",
            {"entity_id": entity_id, "hs_color": hs_color},
github home-assistant / home-assistant / tests / components / homematicip_cloud / test_light.py View on Github external
hass, default_mock_hap, entity_id, entity_name, device_model
    )

    assert ha_state.state == STATE_OFF
    service_call_counter = len(hmip_device.mock_calls)

    # Send all color via service call.
    await hass.services.async_call(
        "light", "turn_on", {"entity_id": entity_id}, blocking=True
    )
    assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level"
    assert hmip_device.mock_calls[-1][1] == (2, RGBColorState.RED, 1.0)

    color_list = {
        RGBColorState.WHITE: [0.0, 0.0],
        RGBColorState.RED: [0.0, 100.0],
        RGBColorState.YELLOW: [60.0, 100.0],
        RGBColorState.GREEN: [120.0, 100.0],
        RGBColorState.TURQUOISE: [180.0, 100.0],
        RGBColorState.BLUE: [240.0, 100.0],
        RGBColorState.PURPLE: [300.0, 100.0],
    }

    for color, hs_color in color_list.items():
        await hass.services.async_call(
            "light",
            "turn_on",
            {"entity_id": entity_id, "hs_color": hs_color},
            blocking=True,
        )
        assert hmip_device.mock_calls[-1][0] == "set_rgb_dim_level"
        assert hmip_device.mock_calls[-1][1] == (2, color, 0.0392156862745098)