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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for generic zigbee sensor #1921
base: main
Are you sure you want to change the base?
add support for generic zigbee sensor #1921
Changes from 1 commit
7a4d856
6b7d791
fa1311c
fb68377
f4cc05a
1dd4216
6113590
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I expect a category is required, but if that's not the case then this is fine.
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.
This profile applies when the
ZoneType
of theIASZone
has not yet been identified. In this case, the profile will be updated to other profiles to reflect other categories such as contact, motion, etc.Until the device receives the
ZoneType
, we have no definitive information regarding its category; all we know is that it is a sensor.Is there a specific device type that can solely describe a sensor?
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 have a
GenericSensor
category I believe. Not positive what the corresponding icon is, though.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 do found that device type in OCF device type wiki.
However, we have tested the profile with
GenericSenso
but noticed that there is no related icon displayed on the device card, only a default icon.Upon investigation, we confirmed that the
oic.d.sensor
, which is theOCFdtype
forGenericSensor
, does not exist in the CN production environment.Could you please assist us in confirming whether this device type exists in the Global production environment? If it does, we would like to request our cloud team to synchronize the device type with the CN production. Thank you for your assistance in advance.
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.
It could be that the default icon is also what's used on the global environments. I'm not sure, though. It's not a new category, so I'd be surprised if it was different on CN.
Mainly this comment was just in case the driver packager complained about the profile not including a category. I thought it might have been a required field. If it's not a required field then you can ignore this comment. Default icon is fine for a device with undetermined functionality.
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.
You could use https://github.ecodesamsung.com/iot-hub/scripting-engine/blob/main/lua_libs/st/zigbee/generated/types/IasZoneType.lua instead of re-defining these here
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.
OK. we will modify it.
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.
This function will be run every time the device is updated on the cloud side. You should not be reading an attribute here. If the intent is for this to happen at some point after the device is added, you should use the
call_with_delay
to have the driver wait some period and then send the read.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.
Instead of having a single function here that that branches, the standard way to handle this in drivers is with subdrivers. So if you had a subdriver that looked like:
There will be a bit more duplicate code, but the it allows us to separate all the different types into their own files, so if we need more complicated logic we don't end up with a big mess of a function.
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.
@pInksenberg
For this, we need to check the ZoneType can be determined before the 'can_handle' triggered.
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.
In this driver, we can seperate sub driver following zonetype, but this edge driver read zone type in add_handler. so this device wouldn't likely to handle some message in initial time potentially.
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.
The same problem exists whether this is a subdriver or a main driver here, until the ZONETYPE field is set on the device, we don't know what type of event we can generate, so we can't generate any event when the value changes. I still prefer the subdriver format as I think it's easier to separate the different devices, but I don't feel strongly about it, and I would be OK with this initial version, but that if any changes are made to add more complex logic that we split things out into subdrivers.
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.
The ZCL spec says that contact switches can use both alarm1 and alarm2 so I think both should be checked
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.
Please check the newly commit
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.
Motion sensors can use either alarm1 or alarm2 so I would suggest reporting
active
if either are setThere 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.
Please check the newly commit
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.
Thanks for making the changes, but can you use the
or
operator instead of the extraelseif
because it's more concise/easier to read?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.
No problem
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.
modified
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.
any reason why
alarm2
isn't used as a trigger here?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.
if it should be, this function could be simplified to use a map
something like that
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 will check that
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.
As we confirmed in ZCL library, the water sensor does not support
alarm2
trigger.(Table 8-5 in ZCL library file).
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.
nit: the linter noticed trailing whitespace here
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.
Is this being done to future-proof a possible implementation for a sensor with multiple different endpoints? I get the instinct but you'd have to have all the capabilities on the
main
component already in order to do this. It's probably best to just emit from the specific component rather than trying to (in the future) duplicate everything onto main as well.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.
OK, we will modify this one.
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.
It's pretty difficult to accurately translate voltage to battery level without knowing the details of the device and battery technology. I'd either suggest using the low battery indicator in the IAS Zone Status and/or switching from
batteryLevel
capability tobattery
and looking at theBatteryPercentageRemaining
attribute instead ofBatteryVoltage
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.
Apologies, I just saw the similar comment here: #1921 (comment)
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.
test result for BatteryPercentageRemaining:
using same type of battery
37 Meian meian water leak sensor Water Leak Sensor :100
20 EZVIZ EZVIZ T1C Smart Motion Sensor Motion sensor :90
21 Tuya Tuya Zigbee PIR Sensor Motion sensor :100
24 Tuya PIR Motion SensoR XZ-CGV2 Motion sensor :100
27 Tuya Tuya Human motion sensors Motion sensor :98
using different type of battery
38 EZVIZ EZVIZ T10C Water Leak Sensor Water Leak Sensor :98
34 Tuya Door Window Sensor Door and Window Sensor :100
33 EZVIZ EZVIZ T2C Door and Window Contact Sensor Door and Window Sensor :100
22 Tuya Tuya PIR Motion Sensor Motion sensor :100
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.
You can delete this.
capabilities.batteryLevel,
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.
Ok, i will delete it
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.
Only the
motionSensor
here can work.