@@ -23,11 +23,14 @@ local device_management = require "st.zigbee.device_management"
23
23
local CONTACT_SWITCH = IasZoneType .CONTACT_SWITCH
24
24
local MOTION_SENSOR = IasZoneType .MOTION_SENSOR
25
25
local WATER_SENSOR = IasZoneType .WATER_SENSOR
26
+ local REMOTE_CONTROL = IasZoneType .REMOTE_CONTROL
26
27
27
28
local ZIGBEE_GENERIC_SENSOR_PROFILE = " generic-sensor"
28
29
local ZIGBEE_GENERIC_CONTACT_SENSOR_PROFILE = " generic-contact-sensor"
29
30
local ZIGBEE_GENERIC_MOTION_SENSOR_PROFILE = " generic-motion-sensor"
30
31
local ZIGBEE_GENERIC_WATERLEAK_SENSOR_PROFILE = " generic-waterleak-sensor"
32
+ local ZIGBEE_GENERIC_MOTION_ILLUMINANCE_PROFILE = " generic-motion-illuminance"
33
+ local ZIGBEE_GENERIC_REMOTE_CONTROL_PROFILE = " generic-remote-control"
31
34
32
35
local ZONETYPE = " ZoneType"
33
36
local IASZone = clusters .IASZone
@@ -55,12 +58,18 @@ local function update_profile(device, zone_type)
55
58
local profile = ZIGBEE_GENERIC_SENSOR_PROFILE
56
59
if zone_type == CONTACT_SWITCH then
57
60
profile = ZIGBEE_GENERIC_CONTACT_SENSOR_PROFILE
58
- elseif zone_type == MOTION_SENSOR then
59
- profile = ZIGBEE_GENERIC_MOTION_SENSOR_PROFILE
61
+ elseif zone_type == REMOTE_CONTROL then
62
+ profile = ZIGBEE_GENERIC_REMOTE_CONTROL_PROFILE
60
63
elseif zone_type == WATER_SENSOR then
61
64
profile = ZIGBEE_GENERIC_WATERLEAK_SENSOR_PROFILE
65
+ elseif zone_type == MOTION_SENSOR then
66
+ profile = ZIGBEE_GENERIC_MOTION_SENSOR_PROFILE
67
+ for _ , ep in ipairs (device .zigbee_endpoints ) do
68
+ if device :supports_server_cluster (clusters .IlluminanceMeasurement .ID , ep .id ) then
69
+ profile = ZIGBEE_GENERIC_MOTION_ILLUMINANCE_PROFILE
70
+ end
71
+ end
62
72
end
63
-
64
73
device :try_update_metadata ({profile = profile })
65
74
end
66
75
@@ -70,44 +79,6 @@ local ias_zone_type_attr_handler = function (driver, device, attr_val)
70
79
update_profile (device , attr_val .value )
71
80
end
72
81
73
- -- since we don't have button devices using IASZone, the driver here is remaining to be updated
74
- local generate_event_from_zone_status = function (driver , device , zone_status , zb_rx )
75
- local type = device :get_field (ZONETYPE )
76
- local event
77
- if type == CONTACT_SWITCH then
78
- if zone_status :is_alarm1_set () or zone_status :is_alarm2_set () then
79
- event = capabilities .contactSensor .contact .open ()
80
- else
81
- event = capabilities .contactSensor .contact .closed ()
82
- end
83
- elseif type == MOTION_SENSOR then
84
- if zone_status :is_alarm1_set () or zone_status :is_alarm2_set () then
85
- event = capabilities .motionSensor .motion .active ()
86
- else
87
- event = capabilities .motionSensor .motion .inactive ()
88
- end
89
- elseif type == WATER_SENSOR then
90
- if zone_status :is_alarm1_set () then
91
- event = capabilities .waterSensor .water .wet ()
92
- else
93
- event = capabilities .waterSensor .water .dry ()
94
- end
95
- end
96
- if event ~= nil then
97
- device :emit_event_for_endpoint (
98
- zb_rx .address_header .src_endpoint .value ,
99
- event )
100
- end
101
- end
102
-
103
- local ias_zone_status_attr_handler = function (driver , device , zone_status , zb_rx )
104
- generate_event_from_zone_status (driver , device , zone_status , zb_rx )
105
- end
106
-
107
- local ias_zone_status_change_handler = function (driver , device , zb_rx )
108
- generate_event_from_zone_status (driver , device , zb_rx .body .zcl_body .zone_status , zb_rx )
109
- end
110
-
111
82
local zigbee_generic_sensor_template = {
112
83
supported_capabilities = {
113
84
capabilities .battery ,
@@ -117,13 +88,7 @@ local zigbee_generic_sensor_template = {
117
88
zigbee_handlers = {
118
89
attr = {
119
90
[IASZone .ID ] = {
120
- [IASZone .attributes .ZoneType .ID ] = ias_zone_type_attr_handler ,
121
- [IASZone .attributes .ZoneStatus .ID ] = ias_zone_status_attr_handler
122
- }
123
- },
124
- cluster = {
125
- [IASZone .ID ] = {
126
- [IASZone .client .commands .ZoneStatusChangeNotification .ID ] = ias_zone_status_change_handler
91
+ [IASZone .attributes .ZoneType .ID ] = ias_zone_type_attr_handler
127
92
}
128
93
}
129
94
},
@@ -132,6 +97,14 @@ local zigbee_generic_sensor_template = {
132
97
doConfigure = do_configure ,
133
98
infoChanged = info_changed
134
99
},
100
+ sub_drivers = {
101
+ require (" contact" ),
102
+ require (" motion" ),
103
+ require (" waterleak" ),
104
+ require (" motion-illuminance" ),
105
+ require (" meian" ),
106
+ require (" ezviz" )
107
+ },
135
108
ias_zone_configuration_method = constants .IAS_ZONE_CONFIGURE_TYPE .AUTO_ENROLL_RESPONSE
136
109
}
137
110
0 commit comments