Skip to content

Commit

Permalink
feat(device): add new OSRAM device integration for ZHA
Browse files Browse the repository at this point in the history
related to #153
  • Loading branch information
xaviml committed Oct 18, 2020
1 parent f1fcf72 commit c67a294
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/controllerx/controllerx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
from cx_devices.ikea import *
from cx_devices.legrand import *
from cx_devices.lutron import *
from cx_devices.muller_licht import *
from cx_devices.osram import *
from cx_devices.philips import *
from cx_devices.smartthings import *
from cx_devices.trust import *
from cx_devices.muller_licht import *
35 changes: 35 additions & 0 deletions apps/controllerx/cx_devices/osram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import Optional
from cx_const import Light, TypeActionsMapping
from cx_core import LightController


class OsramAC025XX00NJLightController(LightController):
# This mapping works for: AC0251100NJ / AC0251400NJ / AC0251600NJ / AC0251700NJ
# (different models are just different colours)
def get_zha_actions_mapping(self) -> TypeActionsMapping:
return {
"1_on": Light.ON,
"1_move_with_on_off": Light.HOLD_BRIGHTNESS_UP,
"1_stop": Light.RELEASE,
# "3_move_to_level_with_on_off" : "", # Nothing
"3_move_to_color_temp": Light.SYNC,
"3_move_to_saturation": Light.HOLD_COLOR_UP,
"3_move_hue": Light.RELEASE,
"2_off": Light.OFF,
"2_move": Light.HOLD_BRIGHTNESS_DOWN,
"2_stop": Light.RELEASE,
}

def get_zha_action(self, data: dict) -> Optional[str]:
return f"{data['endpoint_id']}_{data['command']}"


# on: Sent when arrow up is pressed
# move_with_on_off: Sent when arrow up is held
# stop: Sent when arrow up or down is released after hold
# move_to_level_with_on_off: Sent when circle button is pressed
# move_to_color_temp: Sent when circle button is released after press
# move_to_saturation: Sent when circle button is held
# move_hue: Sent when circle button is released after hold
# off: Sent when arrow down is pressed
# move: Sent when arrow down is held
29 changes: 29 additions & 0 deletions docs/_data/controllers/OSRAM-AC02511XXNJ.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: AC02511XXNJ (OSRAM)
device_support:
- type: Light
domain: light
controller: OsramAC025XX00NJLightController
delay: 350
mapping:
- press arrow up button → Turn on
- hold arrow up button → Brighten up
- press circle button → Sync (Full brightness; 2700K/White colour)
- hold circle button → Color temp up / Right color wheel
- press arrow down button → Turn off
- hold arrow down button → Dim down
integrations:
- name: ZHA
codename: zha
actions:
- 1_on → Click arrow up
- 1_move_with_on_off → Hold arrow up
- 1_stop → Release arrow up after hold
- 3_move_to_level_with_on_off → Click circle button
- 3_move_to_color_temp → Release circle button after click
- 3_move_to_saturation → Hold circle button
- 3_move_hue → Release circle button
- 2_off → Click arrow down
- 2_move → Hold arrow down
- 2_stop → Release arrow down after hold
note: >-
This controller is supported for AC0251100NJ / AC0251400NJ / AC0251600NJ / AC0251700NJ. Different models are just different colours.
Binary file added docs/assets/img/OSRAM-AC02511XXNJ.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/controllers/OSRAM-AC02511XXNJ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: controller
title: AC02511XXNJ (OSRAM)
device: OSRAM-AC02511XXNJ
---
4 changes: 3 additions & 1 deletion tests/unit_tests/cx_devices/devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def test_devices(hass_mock, device_class):

# We first check that all devices are importable from controllerx module
device_from_controllerx = get_controller("controllerx", device_class.__name__)
assert device_from_controllerx is not None
assert (
device_from_controllerx is not None
), f"'{device_class.__name__}' not importable from controllerx.py"

type_actions_mapping = device.get_type_actions_mapping()
if type_actions_mapping is None:
Expand Down

0 comments on commit c67a294

Please sign in to comment.