Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/controllerx/controllerx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from cx_devices.livarno import *
from cx_devices.lutron import *
from cx_devices.muller_licht import *
from cx_devices.namron import *
from cx_devices.osram import *
from cx_devices.philips import *
from cx_devices.prolight import *
Expand Down
45 changes: 45 additions & 0 deletions apps/controllerx/cx_devices/namron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from cx_const import DefaultActionsMapping, Light
from cx_core import LightController


def generate_n45127772_chanmap(index: int) -> DefaultActionsMapping:
"""Generate mapping for a namron 45127772 channel group."""
if index not in range(1, 5):
raise ValueError("Only values between 1 and 4 are supported.")

return {
f"on_l{index}": Light.ON,
f"off_l{index}": Light.OFF,
f"brightness_move_up_l{index}": Light.HOLD_BRIGHTNESS_UP,
f"brightness_move_down_l{index}": Light.HOLD_BRIGHTNESS_DOWN,
f"brightness_stop_l{index}": Light.RELEASE,
}


class Namron4512772Controller(LightController):
"""Namron 4512772 Wall Switch with 8 buttons.

This controller is meant to handle up to four different lights, with on/off and
brightness up/down.

It has swappable physical buttons, and can support 1, 2 or 4 lights.
"""

def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
"""Actions mapping.

The controller is divided in to four groups all emitting the same events
suffixed with _l1 to _l4.

"""
mapping: DefaultActionsMapping = {}
for n in range(1, 5):
mapping |= generate_n45127772_chanmap(n)
return mapping

def default_delay(self) -> int:
"""Set a default delay.

This gives a better dimming experience.
"""
return 500
Binary file added docs/docs/assets/controllers/Namron4512772.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions docs/docs/examples/namron.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Namron 4512772 Example
layout: page
---

### Using the Namron 4512772 Wall Switch

The Namron 4512772 has four groups, and with swappable physical buttons it is intended to control one, two, or four buttons.

To make this work with ControllerX, you can use one app per light you want to control.

For example:

```yaml
test_switch:
module: controllerx
class: Namron4512772Controller
integration:
name: z2m
listen_to: mqtt
controller: My_Namron_Lightswitch # The name of the controller in Z2M
actions: # Ensure that only the buttons you are interested in are configured.
- on_l1 # l1 - l4 selects the group of buttons
- off_l1
- brightness_move_up_l1
- brightness_move_down_l1
- brightness_stop_l1
light: light.my_light_entity
```

#### Setup with two buttons

If the switch is installed with two physical buttons, it is recommended to configure groups 1 and **4**.

```yaml
test_switch_grp1:
module: controllerx
class: Namron4512772Controller
integration:
name: z2m
listen_to: mqtt
controller: My_Namron_Lightswitch
actions:
- on_l1
- off_l1
- brightness_move_up_l1
- brightness_move_down_l1
- brightness_stop_l1
light: light.my_light_entity

test_switch_grp2:
module: controllerx
class: Namron4512772Controller
integration:
name: z2m
listen_to: mqtt
controller: My_Namron_Lightswitch
actions:
- on_l4 # l4 is the other button needed in a two button setup.
- off_l4
- brightness_move_up_l4
- brightness_move_down_l4
- brightness_stop_l4
light: light.my_other_light_entity
```