"""Test Z-Wave lights."""
from unittest.mock import MagicMock, patch

from homeassistant.components import zwave
from homeassistant.components.light import (
    ATTR_BRIGHTNESS,
    ATTR_COLOR_TEMP,
    ATTR_RGB_COLOR,
    ATTR_RGBW_COLOR,
    ATTR_TRANSITION,
    COLOR_MODE_BRIGHTNESS,
    COLOR_MODE_COLOR_TEMP,
    COLOR_MODE_RGB,
    COLOR_MODE_RGBW,
    SUPPORT_TRANSITION,
)
from homeassistant.components.zwave import const, light

from tests.mock.zwave import MockEntityValues, MockNode, MockValue, value_changed


class MockLightValues(MockEntityValues):
    """Mock Z-Wave light values."""

    def __init__(self, **kwargs):
        """Initialize the mock zwave values."""
        self.dimming_duration = None
        self.color = None
        self.color_channels = None
        super().__init__(**kwargs)


def test_get_device_detects_dimmer(mock_openzwave):
    """Test get_device returns a normal dimmer."""
    node = MockNode()
    value = MockValue(data=0, node=node)
    values = MockLightValues(primary=value)

    device = light.get_device(node=node, values=values, node_config={})
    assert isinstance(device, light.ZwaveDimmer)
    assert device.color_mode == COLOR_MODE_BRIGHTNESS
    assert device.supported_features is None
    assert device.supported_color_modes == {COLOR_MODE_BRIGHTNESS}


def test_get_device_detects_colorlight(mock_openzwave):
    """Test get_device returns a color light."""
    node = MockNode(command_classes=[const.COMMAND_CLASS_SWITCH_COLOR])
    value = MockValue(data=0, node=node)
    values = MockLightValues(primary=value)

    device = light.get_device(node=node, values=values, node_config={})
    assert isinstance(device, light.ZwaveColorLight)
    assert device.color_mode == COLOR_MODE_RGB
    assert device.supported_features is None
    assert device.supported_color_modes == {COLOR_MODE_RGB}


def test_get_device_detects_zw098(mock_openzwave):
    """Test get_device returns a zw098 color light."""
    node = MockNode(
        manufacturer_id="0086",
        product_id="0062",