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 action buttons #75

Merged
merged 11 commits into from Feb 23, 2020
Merged

✨ Add action buttons #75

merged 11 commits into from Feb 23, 2020

Conversation

Clewsy
Copy link
Contributor

@Clewsy Clewsy commented Feb 17, 2020

Proposed Changes

By moving the motioneye configuration directory from /data/motioneye to /config/motioneye, and mapping /config in the config.json file, the config files can be easily accessed using the ssh and/or samba addons. This is neccessary for creating/modifying action buttons.

Without this change, creating action buttons requires the user to use docker exec from the host to directly access the motioneye addon container.

Related Issues

#74 - Unable to easily create action buttons

@Clewsy Clewsy requested a review from frenck February 17, 2020 21:53
@frenck
Copy link
Member

frenck commented Feb 18, 2020

We should not expose it this way, but create add-on configuration instead.

@Clewsy
Copy link
Contributor Author

Clewsy commented Feb 19, 2020

Hi Franck, yes I see now that is a much nicer way to configure action buttons. I think I have achieved this with my last commit.

bashio::log.info "Configuring action buttons."
for button in $(bashio::config "action_buttons|keys"); do
BUTTON_TYPE=$(bashio::config "action_buttons[${button}].type")
CAMERA_NUMBER=$(bashio::config "action_buttons[${button}].camera")
Copy link
Member

Choose a reason for hiding this comment

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

  • You are mixing tabs & spaces
  • Only constants should be capitalized
  • Variables are not declared


# Remove any existing action buttons before recreating
for old_action in lock unlock light alarm up right down left zoom preset; do
if ls /data/motioneye/${old_action}* > /dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

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

Use find instead

CAMERA_NUMBER=$(bashio::config "action_buttons[${button}].camera")
BUTTON_COMMAND=$(bashio::config "action_buttons[${button}].command")
bashio::log.debug "File: ${BUTTON_TYPE}_${CAMERA_NUMBER}, Command: ${BUTTON_COMMAND}"
echo "#!/bin/bash" > "/data/motioneye/${BUTTON_TYPE}_${CAMERA_NUMBER}"
Copy link
Member

Choose a reason for hiding this comment

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

Multiple echo's to a single file can be combined using a single redirect.
e.g.:

{
  echo "Line 1"
  echo "Line 2"
} > file

@Clewsy
Copy link
Contributor Author

Clewsy commented Feb 20, 2020

Thanks for the fast review, I think I have covered all the needed fixes.

@frenck frenck changed the title Enable action buttons ✨ Add action buttons Feb 23, 2020
@frenck frenck merged commit d14bcbe into hassio-addons:master Feb 23, 2020
@Clewsy Clewsy deleted the enable_action_buttons branch February 23, 2020 21:34
@addons-assistant
Copy link

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@addons-assistant addons-assistant bot locked as resolved and limited conversation to collaborators Mar 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants