Skip to content

Commit

Permalink
Merge pull request #15 from raetha/devel
Browse files Browse the repository at this point in the history
1.1
  • Loading branch information
raetha authored Jul 17, 2020
2 parents 80d3567 + b387e18 commit 6d3bf5d
Show file tree
Hide file tree
Showing 12 changed files with 689 additions and 73 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# WyzeSense2MQTT files
config.yaml
sensors.yaml
config/
logs/

# Byte-compiled / optimized / DLL files
Expand Down
11 changes: 2 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# see hooks/build and hooks/.config
ARG BASE_IMAGE_PREFIX
FROM ${BASE_IMAGE_PREFIX}alpine
FROM ${BASE_IMAGE_PREFIX}python:3.8-slim-buster

# see hooks/post_checkout
ARG ARCH
Expand All @@ -9,16 +9,9 @@ COPY qemu-${ARCH}-static /usr/bin
# Begin WyzeSense2MQTT
LABEL maintainer="Raetha"

ENV TZ="America/New_York"

COPY wyzesense2mqtt /wyzesense2mqtt/

RUN apk add --update \
py3-pip \
python3 \
tzdata \
&& rm -rf /var/cache/apk/* \
&& pip3 install --no-cache-dir --upgrade pip \
RUN pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir -r /wyzesense2mqtt/requirements.txt \
&& chmod u+x /wyzesense2mqtt/service.sh

Expand Down
11 changes: 2 additions & 9 deletions Dockerfile.manual
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
FROM alpine:latest
FROM python:3.8-slim-buster

LABEL maintainer="Raetha"

ENV TZ="America/New_York"

COPY wyzesense2mqtt /wyzesense2mqtt/

RUN apk add --update \
py3-pip \
python3 \
tzdata \
&& rm -rf /var/cache/apk/* \
&& pip3 install --no-cache-dir --upgrade pip \
RUN pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir -r /wyzesense2mqtt/requirements.txt \
&& chmod u+x /wyzesense2mqtt/service.sh

Expand Down
40 changes: 28 additions & 12 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![GitHub Issues](https://img.shields.io/github/issues/raetha/wyzesense2mqtt)](https://github.com/raetha/wyzesense2mqtt/issues)
[![GitHub PRs](https://img.shields.io/github/issues-pr/raetha/wyzesense2mqtt)](https://github.com/raetha/wyzesense2mqtt/pulls)
[![GitHub Release](https://img.shields.io/github/v/release/raetha/wyzesense2mqtt)](https://github.com/raetha/wyzesense2mqtt/releases)
[![Python Validation](https://github.com/raetha/wyzesense2mqtt/workflows/Python%20Validation/badge.svg)]()
[![Python Validation](https://github.com/raetha/wyzesense2mqtt/workflows/Python%20Validation/badge.svg)](https://github.com/raetha/wyzesense2mqtt/actions?query=workflow%3A%22Python+Validation%22)
[![GitHub Downloads](https://img.shields.io/github/downloads/raetha/wyzesense2mqtt/total)]()

[![dockeri.co](https://dockeri.co/image/raetha/wyzesense2mqtt)](https://hub.docker.com/r/raetha/wyzesense2mqtt)
Expand All @@ -32,6 +32,7 @@ Configurable WyzeSense to MQTT Gateway intended for use with Home Assistant or o
- [Usage](#usage)
- [Pairing a Sensor](#pairing-a-sensor)
- [Removing a Sensor](#removing-a-sensor)
- [Reload Sensors](#reload-sensors)
- [Command Line Tool](#command-line-tool)
- [Home Assistant](#home-assistant)
- [Tested On](#tested-on)
Expand All @@ -42,7 +43,7 @@ Configurable WyzeSense to MQTT Gateway intended for use with Home Assistant or o
This is the most highly tested method of running the gateway. It allows for persistance and easy migration assuming the hardware dongle moves along with the configuration. All steps are performed from Docker host, not container.

1. Plug Wyze Sense Bridge into USB port on Docker host. Confirm that it shows up as /dev/hidraw0, if not, update devices entry in Docker Compose file with correct path.
2. Create a Docker Compose file similar to the following. See [Docker Compose Docs](https://docs.docker.com/compose/) for more details on the file format and options.
2. Create a Docker Compose file similar to the following. See [Docker Compose Docs](https://docs.docker.com/compose/) for more details on the file format and options. If you would like to help test in development feaures, please change the image to "devel" instead of "latest".
```yaml
version: "3.7"
services:
Expand All @@ -67,8 +68,8 @@ services:
mkdir /docker/wyzesense2mqtt/config
mkdir /docker/wyzesense2mqtt/logs
```
4. Create or copy a config.yaml file into the config folder (see sample below or copy from repository)
5. Copy a logging.yaml file into the config folder (see sample below or copy from repository)
4. Create or copy a config.yaml file into the config folder (see sample below or copy from repository). The script will automatically create a default config.yaml if one is not found, but it will need to be modified with your MQTT details before things will work.
5. Copy a logging.yaml file into the config folder (see sample below or copy from repository). The script will automatically create a default logging.yaml if one does not exist. You only need to modify this if more complex logging is required.
6. If desired, pre-populate a sensors.yaml file into the config folder with your existing sensors. This file will automatically be created if it doesn't exist. (see sample below or copy from repository)
7. Start the Docker container
```bash
Expand All @@ -78,7 +79,7 @@ docker-compose up -d

### Linux Systemd

The gateway can also be run as a systemd service for those not wanting to use Docker.
The gateway can also be run as a systemd service for those not wanting to use Docker. Requires Python 3.6 or newer.
1. Plug Wyze Sense Bridge into USB port on Linux host.
2. Pull down a copy of the repository
```bash
Expand All @@ -93,16 +94,17 @@ cd /wyzesense2mqtt
```
4. Prepare config.yaml file. You must set MQTT host parameters! Username and password can be blank if unused. (see sample below)
```bash
mv config/config.yaml.sample config/config.yaml
cp samples/config.yaml config/config.yaml
vim config/config.yaml
```
5. Modify logging.yaml file if desired (optional)
```bash
cp samples/logging.yaml config/logging.yaml
vim config/logging.yaml
```
6. If desired, pre-populate a sensors.yaml file with your existing sensors. This file will automatically be created if it doesn't exist. (see sample below)
6. If desired, pre-populate a sensors.yaml file with your existing sensors. This file will automatically be created if it doesn't exist. (see sample below) (optional)
```bash
mv config/sensors.yaml.sample config/sensors.yaml
cp samples/sensors.yaml config/sensors.yaml
vim config/sensors.yaml
```
7. Install dependencies
Expand Down Expand Up @@ -137,6 +139,7 @@ mqtt_qos: 2
mqtt_retain: true
self_topic_root: wyzesense2mqtt
hass_topic_root: homeassistant
publish_sensor_name: true
usb_dongle: auto
```
Expand Down Expand Up @@ -176,15 +179,23 @@ This file will store basic information about each sensor paired to the Wyse Sens
'AAAAAAAA':
class: door
name: Entry Door
invert_state: false
'BBBBBBBB':
class: window
name: Kitchen Window
name: Office Window
invert_state: false
'CCCCCCCC':
class: opening
name: Fridge
name: Kitchen Fridge
invert_state: false
'DDDDDDDD':
class: motion
name: Hallway Motion
invert_state: false
'EEEEEEEE':
class: moisture
name: Basement Moisture
invert_state: true
```
Expand All @@ -199,6 +210,11 @@ At this time only a single sensor can be properly paired at once. So please repe
1. Publish a message containing the MAC to be removed to the MQTT topic "self_topic_root/remove" where self_topic_root is the value from the configuration file. The default MQTT topic would be "wyzesense2mqtt/remove" if you haven't changed the configuration. The payload should look like "AABBCCDD". This can be performed via Home Assistant or any MQTT client.
### Reload Sensors
If you've changed your sensors.yaml file while the gateway is running, you can trigger a reload of the sensors.yaml file without restarting the gateway or Docker container.
1. Publish a blank message to the MQTT topic "self_topic_root/reload" where self_topic_root is the value from the configuration file. The default MQTT topic would be "wyzesense2mqtt/reload" if you haven't changed the configuration. This can be performed via Home Assistant or any MQTT client.
### Command Line Tool
The bridge_tool_cli.py script can be used to interact with your bridge to perform a few simple functions. Make sure to specify the correct device for your environment.
```bash
Expand All @@ -216,5 +232,5 @@ Home Assistant simply needs to be configured with the MQTT broker that the gatew


## Tested On
* Alpine Linux (Docker)
* Raspbian
* Alpine Linux (Docker image)
* Raspbian Buster
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.2
1.1
12 changes: 0 additions & 12 deletions wyzesense2mqtt/config/sensors.yaml.sample

This file was deleted.

13 changes: 7 additions & 6 deletions wyzesense2mqtt/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Pip requirements file
#
# WyseSensePy
six
# wyzesense2mqtt requirements
paho-mqtt

# WyzeSense2MQTT requirements
paho_mqtt
retrying
pyyaml
wyzesense
# bridge_tool_cli requirements
# Now includes custom WyzeSensePy library to resolve assertion error, issues #12, #17
#wyzesense

# Bridge Tool CLI Requirements
docopt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ mqtt_password: <password>
mqtt_client_id: wyzesense2mqtt
mqtt_clean_session: false
mqtt_keepalive: 60
mqtt_qos: 2
mqtt_qos: 0
mqtt_retain: true
self_topic_root: wyzesense2mqtt
hass_topic_root: homeassistant
publish_sensor_name: true
usb_dongle: auto
File renamed without changes.
20 changes: 20 additions & 0 deletions wyzesense2mqtt/samples/sensors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'AAAAAAAA':
class: door
name: Entry Door
invert_state: false
'BBBBBBBB':
class: window
name: Office Window
invert_state: false
'CCCCCCCC':
class: opening
name: Kitchen Fridge
invert_state: false
'DDDDDDDD':
class: motion
name: Hallway Motion
invert_state: false
'EEEEEEEE':
class: moisture
name: Basement Moisture
invert_state: true
Loading

0 comments on commit 6d3bf5d

Please sign in to comment.