Skip to content

Commit

Permalink
Merge pull request #16 from msazanov/main
Browse files Browse the repository at this point in the history
Custom IP addres field
  • Loading branch information
PoltoS authored Mar 27, 2023
2 parents 4b4bb89 + a3b2891 commit 7fff3ea
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
4 changes: 3 additions & 1 deletion zwave_me_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -qqy --no-install-recommends \
ca-certificates curl \
wget procps gpg iproute2 openssh-client openssh-server sudo logrotate
wget procps gpg iproute2 openssh-client openssh-server sudo logrotate jq

RUN wget -q -O - https://storage.z-wave.me/Z-Way-Install |bash
RUN rm -f /opt/z-way-server/automation/storage/*
Expand All @@ -20,6 +20,8 @@ RUN echo 'support:razberry' | chpasswd

RUN echo "ha" > /etc/z-way/box_type

RUN wget -O /opt/z-way-server/automation/classes/AutomationController.js https://raw.githubusercontent.com/Z-Wave-Me/home-automation/1c5ad7bb95453b5bb7749ad2d1e5907d6949ccc3/classes/AutomationController.js

COPY run.sh .
RUN chmod a+x run.sh

Expand Down
4 changes: 3 additions & 1 deletion zwave_me_server/Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -qqy --no-install-recommends \
ca-certificates curl \
wget procps gpg iproute2 openssh-client openssh-server sudo logrotate
wget procps gpg iproute2 openssh-client openssh-server sudo logrotate jq

RUN wget -q -O - https://storage.z-wave.me/RaspbianInstall |bash
RUN rm -f /opt/z-way-server/automation/storage/*
Expand All @@ -17,6 +17,8 @@ RUN echo 'support:razberry' | chpasswd

RUN echo "ha" > /etc/z-way/box_type

RUN wget -O /opt/z-way-server/automation/classes/AutomationController.js https://raw.githubusercontent.com/Z-Wave-Me/home-automation/1c5ad7bb95453b5bb7749ad2d1e5907d6949ccc3/classes/AutomationController.js

COPY run.sh .
RUN chmod a+x run.sh

Expand Down
4 changes: 3 additions & 1 deletion zwave_me_server/Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -qqy --no-install-recommends \
ca-certificates curl \
wget procps gpg iproute2 openssh-client openssh-server sudo logrotate
wget procps gpg iproute2 openssh-client openssh-server sudo logrotate jq

RUN wget -q -O - https://storage.z-wave.me/RaspbianInstall |bash
RUN rm -f /opt/z-way-server/automation/storage/*
Expand All @@ -17,6 +17,8 @@ RUN echo 'support:razberry' | chpasswd

RUN echo "ha" > /etc/z-way/box_type

RUN wget -O /opt/z-way-server/automation/classes/AutomationController.js https://raw.githubusercontent.com/Z-Wave-Me/home-automation/1c5ad7bb95453b5bb7749ad2d1e5907d6949ccc3/classes/AutomationController.js

COPY run.sh .
RUN chmod a+x run.sh

Expand Down
2 changes: 2 additions & 0 deletions zwave_me_server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ options:
remote_access: true
remote_support_access: false
zbw_password: razberry
local_ip: homeassistant.local
schema:
device: device(subsystem=tty)
configjson_device_replace: bool?
remote_access: bool?
remote_support_access: bool?
zbw_password: str
local_ip: str
webui: http://[HOST]:[PORT:8083]
ports_description:
8083/tcp: Z-Way UI
Expand Down
18 changes: 10 additions & 8 deletions zwave_me_server/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ defCJ=/opt/z-way-server/automation/defaultConfigs/config.json
# If we find file options.json, we use the interface and options from this file
if [ -f "/data/options.json" ]; then
# Get device path from Configuration tab of addon
device=$(grep -Eo '/dev/tty[A-Z]*[0-9]' /data/options.json)
forceDevice=$(grep "configjson_device_replace" /data/options.json | cut -d ":" -f 2 | tr -d ',')
remote_access=$(grep "remote_access" /data/options.json | cut -d ":" -f 2 | tr -d ',')
remote_support_access=$(grep "remote_support_access" /data/options.json | cut -d ":" -f 2 | tr -d ',')
zbw_password=$(grep "zbw_password" /data/options.json | cut -d ":" -f 2 | tr -d '," ')
device=$(jq -r '.device | select(. != null)' /data/options.json)
forceDevice=$(jq -r '.configjson_device_replace | select(. != null)' /data/options.json)
remote_access=$(jq -r '.remote_access | select(. != null)' /data/options.json)
remote_support_access=$(jq -r '.remote_support_access | select(. != null)' /data/options.json)
zbw_password=$(jq -r '.zbw_password | select(. != null)' /data/options.json)
local_ip=$(jq -r '.local_ip | select(. != null)' /data/options.json)
fi

# Change device path in /defailtConfig/config.json
Expand Down Expand Up @@ -67,11 +68,12 @@ fi
# Make simlinks
ln -sf /data/opt/z-way-server/configs/ /opt/z-way-server/

# Use homeassistant.local in ZBW (for find.z-wave.me) instead of the local IP as we can't get the IP outside the docker
echo homeassistant.local > /etc/zbw/local_ips
# Use variable local_ip in ZBW (for find.z-wave.me) instead of the local IP as we can't get the IP outside the docker
echo "$local_ip" > /etc/zbw/local_ips
echo "8083" > /etc/zbw/local_port

# And force Z-Way to report the same domain instead of the IP
echo '"homeassistant.local"' > /opt/z-way-server/automation/localIP.json
echo "\"$local_ip\"" > /opt/z-way-server/automation/localIP.json

# Check if remote access for support enable
if [ $remote_support_access ]; then
Expand Down
3 changes: 3 additions & 0 deletions zwave_me_server/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ configuration:
zbw_password:
name: Password for remote tech support
description: Set an SSH password for Z-Wave.Me technical. When contacting technical support, you might need to allow remote support access. Specify the password and inform technical support along with the remote access ID.
local_ip:
name: IP address of the controller
description: You can specify the real ip for z-way manually, this is necessary for those cases if you have problems with access via homeassistant.local:8083

0 comments on commit 7fff3ea

Please sign in to comment.