Skip to content
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 swichbotmeter plugin #1236

Merged
merged 3 commits into from
Aug 23, 2021

Conversation

shakemid
Copy link
Contributor

Hi,
I would like to add switchbotmeter plugin.
SwitchBot Meter is IoT temperature/humidity meter and has capability to get data with REST API.
https://www.switch-bot.com/products/switchbot-meter
This plugin aims to get temperature/humidity from SwitchBot Meter by using REST API.
Please review the pull request.

Thank you,
K.Cima

Copy link
Collaborator

@sumpfralle sumpfralle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing this new plugin!

It looks good to me.
Please take a look at my minor nitpicks. Most of them are just cosmetic - feel free to ignore these.

;;
config)
config
[ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ] && fetch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for the style: this compound statement can be tricky, if errexit is enabled, since it could turn the exitcode of the case command into non-zero (and cause an early exit with failure).
Thus it is advisable to avoid the above compound statement as the last operation anywhere (or simply: always use if instead).

Example:

$ (set -e; if true; then true && false; fi; echo "FINISH"); echo $?
1

Just a hint - feel free to ignore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I will change it to if

tempunit=${tempunit:-C}

autoconf() {
echo 'no'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not pretend to handle autoconf, if you do not advertise this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does 'advertise' mean capabilities statement in magic markers? I would like to remove autoconf function and case selection. Is it ok?

=head1 LICENSE

GPLv2

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you want to add an SPDX identifier:

SPDX-License-Identifier: GPL-2.0-only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right. I will add it.


statusCode=$( echo "${response}" | jq '.statusCode' )
if [ "${statusCode}" -ne 100 ]; then
echo Error with statusCode = "${statusCode}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please send this message to stderr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it.

@shakemid
Copy link
Contributor Author

Thank you for your review! I will fix it.

@shakemid
Copy link
Contributor Author

@sumpfralle
I have tried to fix it. Could you check it?
Thanks!

@sumpfralle sumpfralle merged commit 818886b into munin-monitoring:master Aug 23, 2021
@sumpfralle
Copy link
Collaborator

Thank you for contributing this new plugin and for going through all my nitpicking remarks!

@shakemid
Copy link
Contributor Author

Your detailed reviews are totally acceptable. Thank you, too!

@shakemid shakemid deleted the add_switchbotmeter branch August 24, 2021 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants