-
-
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] Support for switching video surveillance on/off (#7938) #7968
[netatmo] Support for switching video surveillance on/off (#7938) #7968
Conversation
- The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels Signed-off-by: Sven Strohschein <[email protected]>
Signed-off-by: Sven Strohschein <[email protected]>
Travis tests were successfulHey @Novanic, |
Version deployed and I can confirm that last event and live picture are now correctly refreshed quickly just after switching on or off the surveillance. This is probably the enhancement that will add the best value to my home automation system since months. Thanks for finding that. Remains to review the 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.
Just a comment about the log level for me.
Your new method getModule() could be used in the same way in other handlers (to be done in separate PRs).
try { | ||
return executeGETRequest(url).map(JSONObject::new); | ||
} catch (JSONException e) { | ||
logger.warn("Error on parsing the content as JSON!", e); |
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.
A DEBUG log will be sufficient I think.
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.
Debug? When this error occurs, it is an error, the functionality is broken when it occurs. That shouldn't happen. Actually warning isn't enough.
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.
My general rule for logging levels is:
- trace - used for normal expected execution paths
- debug - used for unexepected execution paths, but well within normal operation
- info - used for notable points in an execution path, like a milestone. (in openhab we try reserve this logging level for the core, so bindings should rarely ever call this.)
- warn - used for notable unexpected execution paths that a regular user (not just a developer) should be notified of. Warnings should be used to indicate that something not-normal occurred and user intervention is required to resolve. Warnings do not indicate a failure to operate merely an abnormal condition of operation that can still be handled by the binding. Failures in binding operation should be indicated by changing the thing status to offline.
- error - used to indicate catastrophic program failure. This should be used to indicate a catastrophic failure in openhab's ability to operate. A failure in a binding would never cause openhab as a whole to fail so a failure in a bindings should never log an error. Instead that failure should be indicated by changing the thing status.
Now if a JSONException does occur here it doesn't really reflect a failure in the binding so much a failure in an external system and can be thought of more or less akin to connection loss. If you think that such a json parsing failure should be elevated above "warn" then I suggest changing the thing status to OFFLINE to reflect that.
return Optional.of(content); | ||
} | ||
} catch (IOException e) { | ||
logger.warn("Error on accessing local camera url!", e); |
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.
A DEBUG log will be sufficient I think.
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 think that such an exception should probably be elevated to the caller since I don't think that simple logging would be how all callers would like this particular issue to be handled.
Debug? When this error occurs, it is an error, the functionality is broken when it occurs. That shouldn't happen. Actually warning isn't enough. |
Please read the coding guidelines for binding developers, there is an explanation about log levels. |
@cpmeister will correct me if I am wrong in my comments. |
Signed-off-by: Sven Strohschein <[email protected]>
I have found a performance / network resource optimization. At the moment the home data (which is requested at least every 5 minutes and after every executed command) is requested with 30 events by default (+ sub-events), but the binding processes only the latest event. So the request within NetatmoBridgeHandler#getWelcomeDataBody(...) could get changed to request just 1 event (via a query-parameter). Should I change the line with this pull-request or should I open a new issue and pull-request? |
I would suggest a separate PR. |
Yes, I'm sure. Only the event with the newest time is processed, all other events are ignored/filtered. You can search for usages of NAWelcomeHome#getEvents(). There is only this one usage. |
Travis tests were successfulHey @Novanic, |
At this place, I see we are going through the list of events to filter on events relative to a person, that means it is not necessarily the most recent event. This must not be broken. |
@cpmeister : could you please review and tell us what should be done regarding log levels (my only comments about this PR). PS: I am waiting for the merge of this PR to restart adding null annotations. |
try { | ||
return executeGETRequest(url).map(JSONObject::new); | ||
} catch (JSONException e) { | ||
logger.warn("Error on parsing the content as JSON!", e); |
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.
My general rule for logging levels is:
- trace - used for normal expected execution paths
- debug - used for unexepected execution paths, but well within normal operation
- info - used for notable points in an execution path, like a milestone. (in openhab we try reserve this logging level for the core, so bindings should rarely ever call this.)
- warn - used for notable unexpected execution paths that a regular user (not just a developer) should be notified of. Warnings should be used to indicate that something not-normal occurred and user intervention is required to resolve. Warnings do not indicate a failure to operate merely an abnormal condition of operation that can still be handled by the binding. Failures in binding operation should be indicated by changing the thing status to offline.
- error - used to indicate catastrophic program failure. This should be used to indicate a catastrophic failure in openhab's ability to operate. A failure in a binding would never cause openhab as a whole to fail so a failure in a bindings should never log an error. Instead that failure should be indicated by changing the thing status.
Now if a JSONException does occur here it doesn't really reflect a failure in the binding so much a failure in an external system and can be thought of more or less akin to connection loss. If you think that such a json parsing failure should be elevated above "warn" then I suggest changing the thing status to OFFLINE to reflect that.
return Optional.of(content); | ||
} | ||
} catch (IOException e) { | ||
logger.warn("Error on accessing local camera url!", e); |
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 think that such an exception should probably be elevated to the caller since I don't think that simple logging would be how all callers would like this particular issue to be handled.
Hm, that you for the explanation, but I don't know what I should do. |
If you think that an IOException can be considered making the binding inoperable, then just set the thing to offline along with a message. Otherwise log it as a warn in order for the user to be notified of the issue. Debug should be used if those errors would be a regular occurrence during binding operation. |
So finally the WARN level was no so bad ;) |
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
I need the merge of this PR to progress. |
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 job. LGTM
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
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]> Signed-off-by: CSchlipp <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]> Signed-off-by: MPH80 <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]> Signed-off-by: Daan Meijer <[email protected]>
* [7938] Support for switching video surveillance on/off - The video surveillance can now get switched on/off - When the command is executed (floodlight or video surveillance switched on/off) a refresh is executed after 2 seconds to update all channels * Warnings fixed * New tests for isNewLastEvent added Signed-off-by: Sven Strohschein <[email protected]>
With this change it is possible to switch the video surveillance on and off (for all cameras / Welcome and Presence). See issue #7938 for more information.
When a camera related command is executed a refresh is executed after 2 seconds to update all channels. This has for example following effects: