Skip to content

Commit

Permalink
Ok, so we are doing this...
Browse files Browse the repository at this point in the history
  • Loading branch information
thejeffreystone committed Dec 4, 2020
0 parents commit c6c3f10
Show file tree
Hide file tree
Showing 12 changed files with 750 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# ignore any of these files no matter where they are using double *
**.DS_Store
**._*
**.HA_VERSION
**.pyc
**.conf
**.uuid
**.txt
**.log
**.db
**.sqlite
**.xml
**secrets*
**known_devices.yaml
**google_calendars.yaml
**ip_bans.yaml
**.spotify-token-cache
**zones.yaml
**test.yaml
**testing.yaml
**.homekit*
**.vscode
**.pid
**.xml
**.csr
**.crt
**.key
**core.*
**OZW_Log.txt
**home-assistant.log
**home-assistant_v2.db
**.db-journal
**.db-shm
**.db-wal
**.sqlite
**__pycache__
**phue.conf
**ios.conf
**pyozw.sqlite
**ipchange.yaml
**production_auth.json
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div align="center">
<img src="images/slacker_labs.png">
<h1>Home Assistant Add-ons</h1>
<br>

## Installation

Add the repository URL under **Supervisor → Add-on store → ⋮ → Manage add-on repositories**:

https://github.com/thejeffreystone/hassio-addons

The repository includes one add-on:

- **acurite2mqtt** is a beta release that uses uses a SDR to connect Acurite Weather Sensors to Home Assistant
66 changes: 66 additions & 0 deletions acurite2mqtt/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

ARG BUILD_FROM
FROM $BUILD_FROM

ENV LANG C.UTF-8

MAINTAINER Jeffrey Stone

LABEL Description="This image is used to start a the RTL433 to HASS script that will monitor for 433Mhz devcices and send the data to an MQTT server"

RUN apk add --no-cache --virtual build-deps alpine-sdk cmake git libusb-dev && \
mkdir /tmp/src && \
cd /tmp/src && \
git clone git://git.osmocom.org/rtl-sdr.git && \
mkdir /tmp/src/rtl-sdr/build && \
cd /tmp/src/rtl-sdr/build && \
cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON -DCMAKE_INSTALL_PREFIX:PATH=/usr/local && \
make && \
make install && \
chmod +s /usr/local/bin/rtl_* && \
cd /tmp/src/ && \
git clone https://github.com/merbanan/rtl_433 && \
cd rtl_433/ && \
mkdir build && \
cd build && \
cmake ../ && \
make && \
make install && \
apk del build-deps && \
rm -r /tmp/src && \
apk add --no-cache libusb mosquitto-clients jq

WORKDIR /data

RUN apk add --no-cache python3 && \
apk add --no-cache py-pip

#
# Define environment variables
#
# Use this variable when creating a container to specify the MQTT broker host.
ENV MQTT_HOST 127.0.0.1
ENV MQTT_PORT 1883
ENV MQTT_USERNAME ""
ENV MQTT_PASSWORD ""
ENV MQTT_RETAIN "True"
ENV MQTT_TOPIC rtl_433
ENV PROTOCOL ""
ENV DISCOVERY_PREFIX homeassistant
ENV DISCOVERY_INTERVAL 600

#
# Install Paho-MQTT client
#
RUN pip3 install paho-mqtt

#
# Copy scripts, make executable
#
COPY entry.sh rtl_433_mqtt_hass.py /scripts/
RUN chmod +x /scripts/entry.sh
RUN chmod +x /scripts/rtl_433_mqtt_hass.py
#
# Execute entry script
#
ENTRYPOINT [ "/scripts/entry.sh" ]
21 changes: 21 additions & 0 deletions acurite2mqtt/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Slacker Labs / Jeffrey Stone

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 9 additions & 0 deletions acurite2mqtt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Home Assistant Add-on: Acurite2mqtt

A Home Assistant addon for a software defined radio tuned to listen for 433MHz RF transmissions from Acurite Weather Sensors and republish the data via MQTT.






35 changes: 35 additions & 0 deletions acurite2mqtt/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "Acurite to Home Assistant",
"version": "0.1",
"slug": "acurite2mqtt",
"description": "Acurite Sensors to Home Assistant via MQTT with Autodiscovery",
"url": "https://github.com/thejeffreystone/hassio-addons/acurite2mqtt",

"startup": "before",
"arch": ["aarch64", "amd64", "armhf", "armv7", "i386"],
"devices": ["/dev/bus/usb:/dev/bus/usb:rwm"],
"boot": "auto",
"options":
{
"mqtt_host": "192.168.1.100",
"mqtt_user": "user",
"mqtt_password": "pass",
"mqtt_topic": "rtl_433",
"mqtt_retain" : "true",
"protocol": "-R 11 -R 40 -R 41 -R 55 -R 74",
"discovery_prefix": "homeassistant",
"discovery_interval": 600
},
"schema":
{
"mqtt_host": "str",
"mqtt_user": "str",
"mqtt_password": "str",
"mqtt_topic": "str",
"mqtt_retain" : "str",
"protocol": "str",
"discovery_prefix": "str",
"discovery_interval": "int"
}
}

38 changes: 38 additions & 0 deletions acurite2mqtt/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

# Exit immediately if a command exits with a non-zero status:
set -e


export LANG=C
PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
export LD_LIBRARY_PATH=/usr/local/lib64
CONFIG_PATH=/data/options.json


MQTT_HOST="$(jq --raw-output '.mqtt_host' $CONFIG_PATH)"
MQTT_USERNAME="$(jq --raw-output '.mqtt_user' $CONFIG_PATH)"
MQTT_PASSWORD="$(jq --raw-output '.mqtt_password' $CONFIG_PATH)"

MQTT_TOPIC="$(jq --raw-output '.mqtt_topic' $CONFIG_PATH)"
MQTT_RETAIN="$(jq --raw-output '.mqtt_retain' $CONFIG_PATH)"
PROTOCOL="$(jq --raw-output '.protocol' $CONFIG_PATH)"
DISCOVERY_PREFIX="$(jq --raw-output '.discovery_prefix' $CONFIG_PATH)"
DISCOVERY_INTERVAL="$(jq --raw-output '.discovery_interval' $CONFIG_PATH)"

# Start the listener and enter an endless loop
echo "Starting RTL_433 with parameters:"
echo "MQTT Host =" $MQTT_HOST
echo "MQTT port =" $MQTT_PORT
echo "MQTT User =" $MQTT_USERNAME
echo "MQTT Password =" $MQTT_PASSWORD
echo "MQTT Topic =" $MQTT_TOPIC
echo "MQTT Retain =" $MQTT_RETAIN
echo "PROTOCOL =" $PROTOCOL
echo "DISCOVERY_PREFIX =" $DISCOVERY_PREFIX
echo "DISCOVERY_INTERVAL =" $DISCOVERY_INTERVAL




rtl_433 $PROTOCOL -C si -F mqtt://$MQTT_HOST:$MQTT_PORT,user=$MQTT_USERNAME,pass=$MQTT_PASSWORD,retain=$MQTT_RETAIN,events=$MQTT_TOPIC/events,states=$MQTT_TOPIC/states,devices=$MQTT_TOPIC[/model][/id][/channel:0] -M time -M protocol -M level | /scripts/rtl_433_mqtt_hass.py
Binary file added acurite2mqtt/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added acurite2mqtt/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c6c3f10

Please sign in to comment.