-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[netatmo] Add support for Presence camera events (#3059) #7807
[netatmo] Add support for Presence camera events (#3059) #7807
Conversation
@Novanic : I really like the update of the pom regarding swagger generation. Nice shot. |
|
Hi @Novanic, |
Hm, interesting, this is just missing in the README, for the welcome camera too. Just use PaperUI, there the things are discovered automatically after the Netatmo API thing is created. ;-) Maybe we can extract it from there (to document it)? |
Ok, I got it working now and have now updated the readme with this pull-request. Here is my example. The home thing is also required and the IDs from Netatmo are important, maybe that was missing/broken in your configuration. To use PaperUI instead is really simple, just enter the credentials for the Netatmo API and everything is found and configured. ;-)
|
Put |
Wow, are you sure that it is a good approach? ;-) I think it makes it more unreadable and it's not necessary at some places (but the IDE gives a warning when the annotation isn't present). Example: |
All the currently PR merge takes this approach, the whole OH core is underconvertion on this. |
Normally no new PR is accepted without null annotations. |
@Novanic Thanks for your contribution. This is a really nice example for using a Trigger Channel instead of three separate State Channels. You could emit a special event for each entity detected by the Netatmo Camera. Trigger Channels can be nicely combined with a specific binding Profile or used directly as Channel-Based Trigger in a Rule. Wdyt? <channel-type id="camara-event">
<kind>trigger</kind>
<label>Camara Event</label>
<event>
<options>
<option value="ANIMAL_DETECTED">Animal Detected</option>
<option value="HUMAN_DETECTED">Human Detected</option>
<option value="VEHICLE_DETECTED">Vehicle Detected</option>
</options>
</event>
</channel-type> |
NonNullByDefault is now used Update: OMG, it breaks the build without showing issues within the IDE. How terrible is that...?! I have now solved it, but I think the "feature" is also buggy. See method NAWelcomeHomeHandler#findFirstSubEvent(...). I had to make this method to be NULL-safe, but it is never called with NULL... |
@Novanic : I think @cweitkamp remark regarding event channels is very valid and make a cleaner interface. |
Ok, I will tryout the trigger channel. Is there anything more which I should change before the pull-request can get accepted and merged? |
Ok, I got the trigger channel now running. But it is not yet within the pull-request, because I don't know if it's not too confusing for the user. What is your opinion? There are currently 2 solutions to provide event information: Now the new "cameraEvent" trigger channel will be introduced for concept 1 also at the home thing level. The user has to know that the homeEvent trigger channel has another concept of usage than the new cameraEvent trigger channel. The cameraEvent channel has to get used in combination with the other channels and the homeEvent channel has another trigger (webhook) and has nothing to do with the other channels of the home thing. To add the cameraEvent channel only to the Presence thing wouldn't work. That wouldn't fit to concept 1 and all the other event information would be missing because the channels are on the home thing level. I see 2 options: Which solution are you prefering? Or do you have other ideas? (but I would not make it too compilicated, I hope that the pull-request can get applied for OpenHAB 2.5.6 to complete the support of the Presence camera which has begun with 2.5.6) ;-) Thank you in advance. |
I have now updated the pull-request to use the suggested cameraEvent trigger channel instead of 3 separate channels for human, animal and vehicle detected. New is also:
Please check if you like this solution more than the 3 channels and if the pull-request can get successfully reviewed and merged soon. |
.../src/main/java/org/openhab/binding/netatmo/internal/handler/AbstractNetatmoThingHandler.java
Outdated
Show resolved
Hide resolved
...netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandler.java
Outdated
Show resolved
Hide resolved
...netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandler.java
Outdated
Show resolved
Hide resolved
...netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandler.java
Outdated
Show resolved
Hide resolved
...netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandler.java
Show resolved
Hide resolved
Signed-off-by: Sven Strohschein <[email protected]>
Signed-off-by: Sven Strohschein <[email protected]>
Signed-off-by: Sven Strohschein <[email protected]>
Signed-off-by: Sven Strohschein <[email protected]>
…code (mapping code could get removed) Signed-off-by: Sven Strohschein <[email protected]>
Travis tests were successfulHey @Novanic, |
1 similar comment
Travis tests were successfulHey @Novanic, |
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 was not my intention to set you down a painful road of refactoring, I only mentioned dealing with the warnings because you decided to add @NonNullByDefault
to the top of the handler class.
I guess I misunderstood your intent when you added that annotation as an indication that you wanted to update the code to modern binding coding guidelines. I would have been perfectly ok with you not adding that annotation since you were only modifying the code of an existing binding. But I guess we are past the point of going back so lets progress forward.
I really appreciate you taking the time to deal with the warnings even if it wasn't what you intended to do.
Also wrt addressing most of the "false positive" warnings the easiest solution is often to cache fields to local variables and perform all the logic on the local variables instead. The reason that you see these "false positives" is that the null checker is trying to prevent NPE from occurring in a concurrent environments where the field values might be changed by another thread during execution.
Anyway, other than these last few changes I think everything looks good.
...netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandler.java
Outdated
Show resolved
Hide resolved
...netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeHomeHandler.java
Outdated
Show resolved
Hide resolved
@cpmeister It was requested as a review result within this pull-request "Would you mind by the way starting the refactoring of the NAWelcomeHandler with @NonNullByDefault ?" I think I should have answered with just "No" / "No, I don't start it"... ;-) |
Signed-off-by: Sven Strohschein <[email protected]>
Travis tests were successfulHey @Novanic, |
@clinique Is there anything else you want changed on this PR? |
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.
LGTM, thanks @Novanic
Yeah, thank you for your review and merge. :-) Now it's done for 2.5.6. @clinique @cpmeister @lolodomo @cpmeister Is someone of you an employee of Netatmo or has a good connection to Netatmo? I tried to contact Netatmo several times but got no answer... For example it would be interesting if it is allowed (for this project) to use inofficial API endpoints. That would allow to switch the floodlight of the Presence camera or start and stop the video recording. |
@Novanic : unfortunately no, I have no connection with Netatmo - but if you've identified unofficial API endpoints, nothing prevents you to use them. The only issue may be that unofficial endpoints may change without notification. |
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]> Signed-off-by: CSchlipp <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]> Signed-off-by: Daan Meijer <[email protected]>
* - Netatmo API updated (to support the sub-event structure which is used by the Presence events) - The message and snapshot data of the Presence events is now available at the home thing - New channels to the home thing added to report if a human, animal or vehicle was detected - Process of updating the Netatmo API simplified (the retrofit code generation is now embedded within the Maven build, therefore the netatmo-swagger-api project doesn't require an additional update and release anymore) * README extended for the Presence outdoor camera thing configuration example * NonNullByDefault is now used because it was mentioned in the code-review * The new 3 channels (for human, animal and vehicle detection) are now replaced by a trigger channel called "cameraEvent". Trigger channels are triggered after the other channels are updated (so a rule can react on a trigger and get the other event information from the other updated channels). Movement event option - A Presence camera reports also generic movements when a movement is not recognizable as a human, animal or vehicle. Signed-off-by: Sven Strohschein <[email protected]>
This pull-request adds support for the events of the Netatmo Presence camera.
It ...
Please see issue 3059 for more information: #3059