-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Quieter Logging #40
Quieter Logging #40
Conversation
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 looks great! Thank you for the contribution.
I have two little tweaks to suggest and then I can get this wrapped into the next release!
index.js
Outdated
@@ -480,7 +481,16 @@ class MagicOccupancy { | |||
} | |||
|
|||
_setOccupancyState (newVal) { | |||
// Capture the previous state and determine if the state change should be logged | |||
this.previousModeState = this.modeState; | |||
this.occupancyLoggingCondition = (newVal == 'Occupied' && this.previousModeState == 'Unoccupied' || newVal == 'Unoccupied') |
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.
Last little thing - this shouldn't be a class-wide variable. I would probably use const here instead
const occupancyLoggingCondition = (newVal == 'Occupied' && this.previousModeState == 'Unoccupied' || newVal == 'Unoccupied')
if (this.occupancyLogging && occupancyLoggingCondition) {
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.
That makes sense. Thanks for the suggestion! The change has been made in dc54e03.
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.
Great! Thank you for the contribution!
Thanks for your help along the way! |
This pull request makes the following changes and is related to issue #37:
Overall, this really cleans up the output to the Homebridge logs while allowing useful state change logging to be captured if desired.