Skip to content

✨ Add action buttons - #75

Merged
frenck merged 11 commits into
hassio-addons:masterfrom
Clewsy:enable_action_buttons
Feb 23, 2020
Merged

✨ Add action buttons#75
frenck merged 11 commits into
hassio-addons:masterfrom
Clewsy:enable_action_buttons

Conversation

@Clewsy

@Clewsy Clewsy commented Feb 17, 2020

Copy link
Copy Markdown
Contributor

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

frenck commented Feb 18, 2020

Copy link
Copy Markdown
Member

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

@Clewsy

Clewsy commented Feb 19, 2020

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Clewsy commented Feb 20, 2020

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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.

2 participants