-
Notifications
You must be signed in to change notification settings - Fork 482
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 initial support for ZHADoorLock sensor. #4540
Conversation
To test the code, you need to use direclty the API, as third app don't use this sensor yet #3750 (comment) |
Nice, thanks @Smanar ! Some remarks:
|
Does this work with YRD256-NR-619 from https://smile.amazon.com/dp/B077YRHFHQ/ref=cm_sw_r_cp_api_glt_fabc_EKH4YHMMTZA847B9S1EN?_encoding=UTF8&psc=1 ? |
Sorry, I though it was requesting me to review, but apparently this was only a suggestion. Not sure how I can mark this as "reviewed". |
Yes ( ZHALightLevel)
For that it will be config/lock, the state/lockstate can have more values locked/unlocked/undefined/not fully locked
Yep, the whitelist is exactly for that
I m using this kind of check
So the code is only used for this kind of sensor, I m making this check at line 3286 binding.cpp and line 9495 in de_web_plugin.cpp, not sure it will be enought ...
Hu ? here I have not understand what i need to do ? @gabriellanata if you give me the model id visible in deconz, I can add it, all yale are working for the moment, realy standard zigbee use. |
That's a good reason! |
@Smanar Thanks! Unsure which one is the model id though: Ah I think I found where it should be but it's blank, even after asking it to read the configuration :/ I'll try a few things |
Created a PR to your fork to maybe save you some time. Thanks again! Smanar#22 |
Add Yale YRD256 model ID
Nice perfect ^^, thx. So the code is working too for this device ? |
rest_sensors.cpp
Outdated
//if (item->lastChanged() == item->lastSet()) | ||
//{ |
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 expected to be commented out?
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.
IDK ^^.
I have commented it during my test, but I don't see the utility of this code. If the state don't change, you will not have notification, and the state don't change every hour, so not sure it s usefull ....
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'd suggest to remove commented out/dead code, otherwise it will sit there for ages ;)
I haven't tried it honestly. It should be the same as the others though. I verified the state values and commands for lock/unlock match in code. |
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.
Some small comments
rest_sensors.cpp
Outdated
@@ -789,6 +789,42 @@ int DeRestPluginPrivate::changeSensorConfig(const ApiRequest &req, ApiResponse & | |||
else if (rid.suffix == RConfigTempThreshold || rid.suffix == RConfigHumiThreshold) | |||
{ | |||
} | |||
else if (rid.suffix == RConfigLock) | |||
{ | |||
bool val = map[pi.key()].toBool(); |
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.
Could you please add a type check here, as we have it further down below in that function (e.g. for thermostats)? Please also don't forget about the error message returned in case it's not a bool value ;)
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.
Done
rest_sensors.cpp
Outdated
rspItemState[QString("/sensors/%1/config/lock").arg(id)] = map["lock"]; | ||
rspItem["success"] = rspItemState; | ||
//if (item->lastChanged() == item->lastSet()) | ||
//{ | ||
updated = true; | ||
//} |
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 guess we only require the updated
part 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.
Good question why was for the code I commented ?
I don't see the utility of it ...
Do I need to use it or remove it ?
rest_sensors.cpp
Outdated
rsp.list.append(errorToMap(ERR_INVALID_VALUE, QString("/sensors/%1/config/lock").arg(id), QString("Command error, %1, for parameter, lock").arg(map[pi.key()].toString()))); | ||
rsp.httpStatus = HttpStatusBadRequest; | ||
return REQ_READY_SEND; |
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 guess we should have the error here homogeneously? So just the part which contains ERR_ACTION_ERROR
as further down below.
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.
Done
@@ -9432,6 +9492,57 @@ void DeRestPluginPrivate::updateSensorNode(const deCONZ::NodeEvent &event) | |||
} | |||
} | |||
} | |||
else if (i->type() == QLatin1String("ZHADoorLock")) // Door lock |
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.
General question to all: do we want to have/leave it here or have an extra file for 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.
I need one.
Because of notifications, need too much code, it will be in next version, WIP
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.
+1 splitting up door lock in separate file sounds clean like it is done for window covering.
But I'm fine when this is done in a extra PR.
de_web_plugin.cpp
Outdated
else | ||
{ | ||
checkSensorNodeReachable(sensor); | ||
checkIasEnrollmentStatus(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.
Just wandering if the IAS check is required here, persumably not?
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, at all, removed
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.
Added my usual code style requests, can you please have a look. :)
In future I hope to automate these checks with clang-tidy to get a more consistent style across the code base.
@@ -9432,6 +9492,57 @@ void DeRestPluginPrivate::updateSensorNode(const deCONZ::NodeEvent &event) | |||
} | |||
} | |||
} | |||
else if (i->type() == QLatin1String("ZHADoorLock")) // Door lock |
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.
+1 splitting up door lock in separate file sounds clean like it is done for window covering.
But I'm fine when this is done in a extra PR.
rest_sensors.cpp
Outdated
//if (item->lastChanged() == item->lastSet()) | ||
//{ |
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'd suggest to remove commented out/dead code, otherwise it will sit there for ages ;)
Ok so I m not able to resolve all, but all is resolved. Just 2 comments.
On my side worked better just with
|
This is used to set updated only if the value was indeed be updated and is different from the previous set value. It depends on use case and code which follows. For example for button events they should trigger an event even if the value hasn't been changed but the timestamp since the same button was pressed multiple times. In short, we use |
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, looking better now. I found a missing error handling can you please check.
This code create ZHAdoorlock sensor for new doorlock, older one are not impacted and still use "light" type.
The JSON look like this one
The code add too some attribute and fonction to the GUI for doorlock cluster 0x0101
It add support for thoses devices.
Not all are tested, have some issue for the EasyAccess EasyCodeTouch #4253
To unlock/lock the device, use config/lock.
State/lockstate give the device state (locked/unlocked/undefined/not fully locked)
Lasted issue used #3750