Skip to content

Commit

Permalink
Merge pull request #41 from raetha/devel
Browse files Browse the repository at this point in the history
1.2
  • Loading branch information
raetha authored Feb 11, 2021
2 parents 6d3bf5d + 185cc2c commit 7198387
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 184 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master, devel ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, devel ]
schedule:
- cron: '40 14 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ RUN pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir -r /wyzesense2mqtt/requirements.txt \
&& chmod u+x /wyzesense2mqtt/service.sh

RUN apt-get update \
&& apt-get install -y --no-install-recommends vim \
&& rm -rf /var/lib/apt/lists/*

VOLUME /wyzesense2mqtt/config /wyzesense2mqtt/logs

ENTRYPOINT /wyzesense2mqtt/service.sh
4 changes: 4 additions & 0 deletions Dockerfile.manual
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ RUN pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir -r /wyzesense2mqtt/requirements.txt \
&& chmod u+x /wyzesense2mqtt/service.sh

RUN apt-get update \
&& apt-get install -y --no-install-recommends vim \
&& rm -rf /var/lib/apt/lists/*

VOLUME /wyzesense2mqtt/config /wyzesense2mqtt/logs

ENTRYPOINT /wyzesense2mqtt/service.sh
27 changes: 16 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
[![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)](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)

Configurable WyzeSense to MQTT Gateway intended for use with Home Assistant or other platforms that use MQTT discovery mechanisms. The gateway allows direct local access to [Wyze Sense](https://wyze.com/wyze-sense.html) products without the need for a Wyze Cam or cloud services. This project and its dependencies have no relation to Wyze Labs Inc.

## Special Thanks
* [HcLX](https://hclxing.wordpress.com) for [WyzeSensePy](https://github.com/HclX/WyzeSensePy), the core library this component uses.
* [Kevin Vincent](http://kevinvincent.me) for [HA-WyzeSense](https://github.com/kevinvincent/ha-wyzesense), the refernce code I used to get things working right with the calls to WyzeSensePy.
* [HcLX](https://hclxing.wordpress.com) for [WyzeSensePy](https://github.com/HclX/WyzeSensePy), the core library this project uses.
* [Kevin Vincent](http://kevinvincent.me) for [HA-WyzeSense](https://github.com/kevinvincent/ha-wyzesense), the reference code I used to get things working right with the calls to WyzeSensePy.
* [ozczecho](https://github.com/ozczecho) for [wyze-mqtt](https://github.com/ozczecho/wyze-mqtt), the inspiration for this project.
* [rmoriz](https://roland.io/) for [multiarch-test](https://github.com/rmoriz/multiarch-test), this allowed the Docker Hub Autobuilder to work for multiple architectures including ARM32v7 (Raspberry Pi) and AMD64 (Linux).

Expand Down Expand Up @@ -75,22 +74,26 @@ mkdir /docker/wyzesense2mqtt/logs
```bash
docker-compose up -d
```
8. Pair sensors following instructions below. You do NOT need to re-pair sensors that were already paired, they should be found automatically on start and added to the config file with default values, but the sensor version will be unknown.
8. Pair sensors following [instructions below](#pairing-a-sensor). You do NOT need to re-pair sensors that were already paired, they should be found automatically on start and added to the config file with default values, but the sensor version will be unknown.

### Linux Systemd

The gateway can also be run as a systemd service for those not wanting to use Docker. Requires Python 3.6 or newer.
The gateway can also be run as a systemd service for those not wanting to use Docker. Requires Python 3.6 or newer. You may need to do all commands as root, depending on filesystem permissions.
1. Plug Wyze Sense Bridge into USB port on Linux host.
2. Pull down a copy of the repository
```bash
cd /tmp
git clone https://github.com/raetha/wyzesense2mqtt.git
# Use the below command instead if you want to help test the devel branch
# git clone -b devel https://github.com/raetha/wyzesense2mqtt.git
```
3. Create local application folder (Select a location that works for you, example uses /wyzesense2mqtt)
3. Create local application folders (Select a location that works for you, example uses /wyzesense2mqtt)
```bash
mv /tmp/wyzesense2mqtt/wyzesense2mqtt /wyzesense2mqtt
rm -rf /tmp/wyzesense2mqtt
cd /wyzesense2mqtt
mkdir config
mkdir logs
```
4. Prepare config.yaml file. You must set MQTT host parameters! Username and password can be blank if unused. (see sample below)
```bash
Expand All @@ -109,17 +112,18 @@ vim config/sensors.yaml
```
7. Install dependencies
```bash
pip3 install -r requirements.txt
sudo pip3 install -r requirements.txt
```
8. Start the service.
8. Configure the service
```bash
vim wyzesense2mqtt.service # Only modify if not using default application path
sudo cp wyzesense2mqtt.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start wyzesense2mqtt
sudo systemctl status wyzesense2mqtt
sudo systemctl enable wyzesense2mqtt # Enable start on reboot
```
9. Pair sensors following instructions below. You do NOT need to re-pair sensors that were already paired, they should be found automatically on start and added to the config file with default values, but the sensor version will be unknown.
9. Pair sensors following [instructions below](#pairing-a-sensor). You do NOT need to re-pair sensors that were already paired, they should be found automatically on start and added to the config file with default values, but the sensor version will be unknown.


## Config Files
Expand All @@ -139,6 +143,7 @@ mqtt_qos: 2
mqtt_retain: true
self_topic_root: wyzesense2mqtt
hass_topic_root: homeassistant
hass_discovery: true
publish_sensor_name: true
usb_dongle: auto
```
Expand Down Expand Up @@ -232,5 +237,5 @@ Home Assistant simply needs to be configured with the MQTT broker that the gatew


## Tested On
* Alpine Linux (Docker image)
* Raspbian Buster
* Debian Buster (Docker)
* Raspbian Buster (RPi 4)
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1
1.2
6 changes: 3 additions & 3 deletions wyzesense2mqtt/bridge_tool_cli.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def Unpair(mac_list):

def Fix(unused_args):
invalid_mac_list = [
"00000000",
"\0\0\0\0\0\0\0\0",
"\x00\x00\x00\x00\x00\x00\x00\x00"
"00000000",
"\0\0\0\0\0\0\0\0",
"\x00\x00\x00\x00\x00\x00\x00\x00"
]
print("Un-pairing bad sensors")
logging.debug("Un-pairing bad sensors")
Expand Down
1 change: 1 addition & 0 deletions wyzesense2mqtt/samples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ mqtt_qos: 0
mqtt_retain: true
self_topic_root: wyzesense2mqtt
hass_topic_root: homeassistant
hass_discovery: true
publish_sensor_name: true
usb_dongle: auto
Empty file modified wyzesense2mqtt/service.sh
100644 → 100755
Empty file.
Loading

0 comments on commit 7198387

Please sign in to comment.