@@ -69,3 +69,84 @@ void ZigbeeSwitch::find_endpoint(esp_zb_zdo_match_desc_req_param_t *cmd_req) {
69
69
70
70
esp_zb_zdo_match_cluster (&on_off_req, find_cb, NULL );
71
71
}
72
+
73
+ // Call to control the light
74
+ void ZigbeeSwitch::lightToggle () {
75
+ if (_is_bound) {
76
+ esp_zb_zcl_on_off_cmd_t cmd_req;
77
+ cmd_req.zcl_basic_cmd .src_endpoint = _endpoint;
78
+ cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
79
+ cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_TOGGLE_ID;
80
+ log_i (" Sending 'light toggle' command" );
81
+ esp_zb_zcl_on_off_cmd_req (&cmd_req);
82
+ } else {
83
+ log_e (" Light not bound" );
84
+ }
85
+ }
86
+
87
+ void ZigbeeSwitch::lightOn () {
88
+ if (_is_bound) {
89
+ esp_zb_zcl_on_off_cmd_t cmd_req;
90
+ cmd_req.zcl_basic_cmd .src_endpoint = _endpoint;
91
+ cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
92
+ cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_ON_ID;
93
+ log_i (" Sending 'light on' command" );
94
+ esp_zb_zcl_on_off_cmd_req (&cmd_req);
95
+ } else {
96
+ log_e (" Light not bound" );
97
+ }
98
+ }
99
+
100
+ void ZigbeeSwitch::lightOff () {
101
+ if (_is_bound) {
102
+ esp_zb_zcl_on_off_cmd_t cmd_req;
103
+ cmd_req.zcl_basic_cmd .src_endpoint = _endpoint;
104
+ cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
105
+ cmd_req.on_off_cmd_id = ESP_ZB_ZCL_CMD_ON_OFF_OFF_ID;
106
+ log_i (" Sending 'light off' command" );
107
+ esp_zb_zcl_on_off_cmd_req (&cmd_req);
108
+ } else {
109
+ log_e (" Light not bound" );
110
+ }
111
+ }
112
+
113
+ void ZigbeeSwitch::lightOffWithEffect (uint8_t effect_id, uint8_t effect_variant) {
114
+ if (_is_bound) {
115
+ esp_zb_zcl_on_off_off_with_effect_cmd_t cmd_req;
116
+ cmd_req.zcl_basic_cmd .src_endpoint = _endpoint;
117
+ cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
118
+ cmd_req.effect_id = effect_id;
119
+ cmd_req.effect_variant = effect_variant;
120
+ log_i (" Sending 'light off with effect' command" );
121
+ esp_zb_zcl_on_off_off_with_effect_cmd_req (&cmd_req);
122
+ } else {
123
+ log_e (" Light not bound" );
124
+ }
125
+ }
126
+
127
+ void ZigbeeSwitch::lightOnWithSceneRecall () {
128
+ if (_is_bound) {
129
+ esp_zb_zcl_on_off_on_with_recall_global_scene_cmd_t cmd_req;
130
+ cmd_req.zcl_basic_cmd .src_endpoint = _endpoint;
131
+ cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
132
+ log_i (" Sending 'light on with scene recall' command" );
133
+ esp_zb_zcl_on_off_on_with_recall_global_scene_cmd_req (&cmd_req);
134
+ } else {
135
+ log_e (" Light not bound" );
136
+ }
137
+ }
138
+ void ZigbeeSwitch::lightOnWithTimedOff (uint8_t on_off_control, uint16_t time_on, uint16_t time_off) {
139
+ if (_is_bound) {
140
+ esp_zb_zcl_on_off_on_with_timed_off_cmd_t cmd_req;
141
+ cmd_req.zcl_basic_cmd .src_endpoint = _endpoint;
142
+ cmd_req.address_mode = ESP_ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT;
143
+ cmd_req.on_off_control = on_off_control; // TODO: Test how it works, then maybe change API
144
+ cmd_req.on_time = time_on;
145
+ cmd_req.off_wait_time = time_off;
146
+ log_i (" Sending 'light on with time off' command" );
147
+ esp_zb_zcl_on_off_on_with_timed_off_cmd_req (&cmd_req);
148
+ } else {
149
+ log_e (" Light not bound" );
150
+ }
151
+ }
152
+
0 commit comments