-
Notifications
You must be signed in to change notification settings - Fork 484
generic_zigbee_sensor_improvement #2093
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Open
pInksenberg
wants to merge
1
commit into
SmartThingsCommunity:main
Choose a base branch
from
pInksenberg:generic_zigbee_sensor_improvement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,244
−52
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
drivers/SmartThings/zigbee-sensor/profiles/generic-motion-illuminance.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: generic-motion-illuminance | ||
components: | ||
- id: main | ||
capabilities: | ||
- id: motionSensor | ||
version: 1 | ||
- id: illuminanceMeasurement | ||
version: 1 | ||
config: | ||
values: | ||
- key: "illuminance.value" | ||
range: [0, 32000] | ||
- id: battery | ||
version: 1 | ||
- id: firmwareUpdate | ||
version: 1 | ||
- id: refresh | ||
version: 1 | ||
categories: | ||
- name: MotionSensor |
14 changes: 14 additions & 0 deletions
14
drivers/SmartThings/zigbee-sensor/profiles/generic-remote-control.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: generic-remote-control | ||
components: | ||
- id: main | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
- id: battery | ||
version: 1 | ||
- id: firmwareUpdate | ||
version: 1 | ||
- id: refresh | ||
version: 1 | ||
categories: | ||
- name: Button |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
-- Copyright 2025 SmartThings | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
local clusters = require "st.zigbee.zcl.clusters" | ||
local capabilities = require "st.capabilities" | ||
|
||
local IASZone = clusters.IASZone | ||
|
||
local is_contact_sensor = function(opts, driver, device) | ||
if device:supports_capability(capabilities.contactSensor) then | ||
return true | ||
end | ||
end | ||
|
||
local generate_event_from_zone_status = function(driver, device, zone_status, zb_rx) | ||
local event | ||
if zone_status:is_alarm1_set() or zone_status:is_alarm2_set() then | ||
event = capabilities.contactSensor.contact.open() | ||
else | ||
event = capabilities.contactSensor.contact.closed() | ||
end | ||
if event ~= nil then | ||
device:emit_event_for_endpoint( | ||
zb_rx.address_header.src_endpoint.value, | ||
event) | ||
end | ||
end | ||
|
||
|
||
local ias_zone_status_attr_handler = function(driver, device, zone_status, zb_rx) | ||
generate_event_from_zone_status(driver, device, zone_status, zb_rx) | ||
end | ||
|
||
local ias_zone_status_change_handler = function(driver, device, zb_rx) | ||
generate_event_from_zone_status(driver, device, zb_rx.body.zcl_body.zone_status, zb_rx) | ||
end | ||
Comment on lines
+26
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we overwriting the defaults somewhere that makes it necessary to redefine them here? |
||
|
||
|
||
local generic_contact_sensor = { | ||
NAME = "Generic Contact Sensor", | ||
zigbee_handlers = { | ||
attr = { | ||
[IASZone.ID] = { | ||
[IASZone.attributes.ZoneStatus.ID] = ias_zone_status_attr_handler | ||
} | ||
}, | ||
cluster = { | ||
[IASZone.ID] = { | ||
[IASZone.client.commands.ZoneStatusChangeNotification.ID] = ias_zone_status_change_handler | ||
} | ||
} | ||
}, | ||
can_handle = is_contact_sensor | ||
} | ||
|
||
return generic_contact_sensor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
-- Copyright 2025 SmartThings | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
local capabilities = require "st.capabilities" | ||
local defaults = require "st.zigbee.defaults" | ||
|
||
local EZVIZ_PRIVATE_CLUSTER = 0xFE05 | ||
local EZVIZ_PRIVATE_ATTRIBUTE = 0x0000 | ||
|
||
local EZVIZ_MFR = "EZVIZ" | ||
|
||
local is_ezviz_button = function(opts, driver, device) | ||
if device:supports_capability(capabilities.button) and device:get_manufacturer() == EZVIZ_MFR then | ||
return true | ||
end | ||
end | ||
|
||
-- We need an empty added here to override the added in root init.lua, because we already knows its profile | ||
local device_added = function(self, device) | ||
end | ||
|
||
local ezviz_private_cluster_button_handler = function(driver, device, zb_rx) | ||
local event | ||
local additional_fields = { | ||
state_change = true | ||
} | ||
if zb_rx.value == 0x01 then | ||
event = capabilities.button.button.pushed(additional_fields) | ||
elseif zb_rx.value == 0x02 then | ||
event = capabilities.button.button.double(additional_fields) | ||
elseif zb_rx.value == 0x03 then | ||
event = capabilities.button.button.held(additional_fields) | ||
end | ||
if event ~= nil then | ||
device:emit_event(event) | ||
end | ||
end | ||
|
||
local ezviz_button_handler = { | ||
NAME = "Ezviz Button", | ||
supported_capabilities = { | ||
capabilities.battery, | ||
capabilities.button, | ||
capabilities.refresh | ||
}, | ||
zigbee_handlers = { | ||
attr = { | ||
[EZVIZ_PRIVATE_CLUSTER] = { | ||
[EZVIZ_PRIVATE_ATTRIBUTE] = ezviz_private_cluster_button_handler | ||
} | ||
} | ||
}, | ||
lifecycle_handlers = { | ||
added = device_added | ||
}, | ||
can_handle = is_ezviz_button | ||
} | ||
defaults.register_for_default_handlers(ezviz_button_handler, ezviz_button_handler.supported_capabilities) | ||
return ezviz_button_handler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we usually capitalize the letters in our hex