Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_dimmer(vera_controller_data: VeraControllerData) -> None:
"""Test function."""
controller = vera_controller_data.controller
device = cast(VeraDimmer, controller.get_device_by_id(DEVICE_LIGHT_ID))
controller.register(device, lambda device: None)
assert device.is_switched_on(refresh=True) is False
assert device.get_brightness(refresh=True) == 0
assert device.get_color(refresh=True) == [255, 100, 100]
device.switch_on()
assert device.is_switched_on() is True
assert device.get_brightness() == 255
device.set_brightness(66)
assert device.get_brightness() == 66
device.set_color([120, 130, 140])
assert device.get_color() == [120, 130, 140]
def map_vera_device(vera_device, remap):
"""Map vera classes to Home Assistant types."""
import pyvera as veraApi
if isinstance(vera_device, veraApi.VeraDimmer):
return 'light'
if isinstance(vera_device, veraApi.VeraBinarySensor):
return 'binary_sensor'
if isinstance(vera_device, veraApi.VeraSensor):
return 'sensor'
if isinstance(vera_device, veraApi.VeraArmableDevice):
return 'switch'
if isinstance(vera_device, veraApi.VeraLock):
return 'lock'
if isinstance(vera_device, veraApi.VeraThermostat):
return 'climate'
if isinstance(vera_device, veraApi.VeraCurtain):
return 'cover'
if isinstance(vera_device, veraApi.VeraSceneController):
return 'sensor'
if isinstance(vera_device, veraApi.VeraSwitch):
def map_vera_device(vera_device, remap):
"""Map vera classes to Home Assistant types."""
import pyvera as veraApi
if isinstance(vera_device, veraApi.VeraDimmer):
return "light"
if isinstance(vera_device, veraApi.VeraBinarySensor):
return "binary_sensor"
if isinstance(vera_device, veraApi.VeraSensor):
return "sensor"
if isinstance(vera_device, veraApi.VeraArmableDevice):
return "switch"
if isinstance(vera_device, veraApi.VeraLock):
return "lock"
if isinstance(vera_device, veraApi.VeraThermostat):
return "climate"
if isinstance(vera_device, veraApi.VeraCurtain):
return "cover"
if isinstance(vera_device, veraApi.VeraSceneController):
return "sensor"
if isinstance(vera_device, veraApi.VeraSwitch):