Skip to content

Commit a53de40

Browse files
Robert UgodzinskiRobert Ugodzinski
Robert Ugodzinski
authored and
Robert Ugodzinski
committed
Init commit
1 parent f7230fd commit a53de40

File tree

3 files changed

+96
-87
lines changed

3 files changed

+96
-87
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/venv/
2+
./idea/

Diff for: README.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Light Controller
2+
===============
3+
Controls light according to programmed scenes based on multiple inputs
4+
like switches, motions sensors and door/window sensors.
5+
Suitable for users, that have smart light always power on and zigbee switches.
6+
7+
Main features:
8+
* Supports 3 build-in, configurable scenes
9+
- cold - used during daylight
10+
- warm - used for afternoon
11+
- dimmed - as a night light
12+
* Speed - where it is possible, state is cached to speed up calculation of response
13+
* Commands and responses are send via mqtt, but light can be controlled via HA as well
14+
* Sun on/off detection
15+
* Support motions sensors
16+
* Support contact sensors
17+
18+
Minimal configuration:
19+
```yaml
20+
# Name of app instance
21+
light_ctrl:
22+
# Module name
23+
module: lightcontroller
24+
# Module class
25+
class: LightController
26+
# Define light entity to control.
27+
light_entity: light.light_1
28+
# Define z2m names of switches.
29+
# Switch needs to support at least single click, ideally double and hold as well
30+
switches:
31+
- name: switch_1
32+
```
33+
34+
Notes:
35+
* z2m main topic needs to de default one (zigbee2mqtt)
36+
37+
Switch event behavior:
38+
* single - turn off or turn on default scene (warm or cold depending on current time)
39+
* double - when off or not warm - set to warm. If warm - set to cold. Convenient way to change scene.
40+
* hold - set dimmed scene
41+
42+
Full configuration:
43+
```yaml
44+
# Name of app instance
45+
light_ctrl:
46+
# Module name
47+
module: lightcontroller
48+
# Module class
49+
class: LightController
50+
# Scenes configuration. If not defined, some defaults will be used.
51+
scene_cold:
52+
color_temp: 250
53+
brightness: 255
54+
scene_warm:
55+
color_temp: 389
56+
brightness: 150
57+
scene_dimm:
58+
color_temp: 500
59+
brightness: 1
60+
# If light don't support color_temp, then it is needed to set following flag to false:
61+
color_temp_support: True
62+
# If you want to automatically change the light color on some events like sunset, then set following flag:
63+
auto_color_temp_change: True
64+
# Suppress multiple clicks for x seconds:
65+
debounce: 1
66+
# Define HA light entity to control. Still needed, even if z2m entity is defined.
67+
light_entity: light.light_1
68+
# It is possible to define z2m name topic to control light,
69+
# then command will be send directly to z2m via mqtt:
70+
mqtt_entity: light_1
71+
# Define input switches as z2m names with associated 'action' attribute value.
72+
# If given switch don't support double/hold action, then some functionality will be reduced.
73+
switches:
74+
- name: switch_1
75+
single: "left_single"
76+
double: "left_double"
77+
hold: "left_hold"
78+
# Define additional time bounds for cold scene.
79+
# If not defined, cold/warm scene will be selected based on sun position only.
80+
cold_scene_time:
81+
start: "07:00:00"
82+
end: "19:00:00"
83+
# Define z2m motion sensors to define auto on function and timeout function
84+
motion_sensors:
85+
- name: occupancy_1
86+
turn_on: True # defult True, defines if given motion sensor can trigger light on action
87+
# if set to false, it will be used only to check, if timeout can be started to count
88+
# Timeout for motion sensors, that is after which time light should be turned off after not detecting a move.
89+
motion_timeout: 300 # seconds
90+
# Contacts, that can trigger light on acion when contact=false.
91+
# To be used with door sensor, so when door goes open, light will turn on.
92+
contacts:
93+
- name: contact_1

Diff for: apps/lightcontroller.py

+1-87
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,7 @@
22
LightController - controls light according to programmed scenes based on multiple inputs
33
like switches, motions sensors and door/window sensors
44
5-
Main features:
6-
* Supports 3 build-in, configurable scenes
7-
- cold - used during daylight
8-
- warm - used for afternoon
9-
- dimmed - as a night light
10-
* Speed - where it is possible, state is cached to speed up calculation of response
11-
* Commands and responses are send via mqtt, but light can be controlled via HA as well
12-
* Sun on/off detection
13-
* Support motions sensors
14-
* Support contact sensors
15-
16-
Minimal configuration:
17-
```
18-
# Name of app instance
19-
light_ctrl:
20-
# Module name
21-
module: lightcontroller
22-
# Module class
23-
class: LightController
24-
# Define light entity to control.
25-
light_entity: light.light_1
26-
# Define z2m names of switches.
27-
Switch needs to support at least single click, ideally double and hold as well
28-
switches:
29-
- name: switch_1
30-
```
31-
32-
Notes:
33-
* z2m main topic needs to de default one (zigbee2mqtt)
34-
35-
Switch event behavior:
36-
* single - turn off or turn on default scene (warm or cold depending on current time)
37-
* double - when off or not warm - set to warm. If warm - set to cold. Convenient way to change scene.
38-
* hold - set dimmed scene
39-
40-
Full configuration:
41-
```
42-
# Name of app instance
43-
light_ctrl:
44-
# Module name
45-
module: lightcontroller
46-
# Module class
47-
class: LightController
48-
# Scenes configuration. If not defined, some defaults will be used.
49-
scene_cold:
50-
color_temp: 250
51-
brightness: 255
52-
scene_warm:
53-
color_temp: 389
54-
brightness: 150
55-
scene_dimm:
56-
color_temp: 500
57-
brightness: 1
58-
# If light don't support color_temp, then it is needed to set following flag to false:
59-
color_temp_support: True
60-
# If you want to automatically change the light color on some events like sunset, then set following flag:
61-
auto_color_temp_change: True
62-
# Suppress multiple clicks for x seconds:
63-
debounce: 1
64-
# Define HA light entity to control. Still needed, even if z2m entity is defined.
65-
light_entity: light.light_1
66-
# It is possible to define z2m name topic to control light,
67-
# then command will be send directly to z2m via mqtt:
68-
mqtt_entity: light_1
69-
# Define input switches as z2m names with associated 'action' attribute value.
70-
# If given switch don't support double/hold action, then some functionality will be reduced.
71-
switches:
72-
- name: switch_1
73-
single: "left_single"
74-
double: "left_double"
75-
hold: "left_hold"
76-
# Define additional time bounds for cold scene.
77-
# If not defined, cold/warm scene will be selected based on sun position only.
78-
cold_scene_time:
79-
start: "07:00:00"
80-
end: "19:00:00"
81-
# Define z2m motion sensors to define auto on function and timeout function
82-
motion_sensors:
83-
- name: occupancy_1
84-
turn_on: True # defult True, defines if given motion sensor can trigger light on action
85-
# if set to false, it will be used only to check, if timeout can be started to count
86-
# Timeout for motion sensors, that is after which time light should be turned off after not detecting a move.
87-
motion_timeout: 300 # seconds
88-
# Contacts, that can trigger light on acion when contact=false.
89-
# To be used with door sensor, so when door goes open, light will turn on.
90-
contacts:
91-
- name: contact_1
5+
For more info read README.md
926
```
937
948
"""

0 commit comments

Comments
 (0)