From fb6b964857fc75193e25551d81740f2cc89efc03 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 3 Nov 2019 19:21:58 +0100 Subject: [PATCH] added Home Assistant documentation --- Dockerfile | 17 ----------------- README.md | 2 +- doc/HOMEASSISTANT.md | 45 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 doc/HOMEASSISTANT.md diff --git a/Dockerfile b/Dockerfile index 22deb54..8b63549 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,23 +4,6 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends wget default-jre software-properties-common git \ && rm -rf /var/lib/apt/lists/* -#RUN add-apt-repository ppa:gophers/archive -#RUN apt-get update -#RUN apt-get install -y golang-1.11-go - - -# ARM -#RUN wget -P /tmp/ https://dl.google.com/go/go1.12.5.linux-armv6l.tar.gz \ -# && tar -C /usr/local -xzf /tmp/go1.12.5.linux-armv6l.tar.gz \ -# && rm -rf /tmp/go1.12.5.linux-armv6l.tar.gz - -#RUN wget -P /tmp/ https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz \ -# && tar -C /user/local -xzf /tmp/go1.12.5.linux-amd64.tar.gz \ -# && rm -rf /tmp/go1.12.5.linux-amd64.tar.gz - -#ENV PATH /usr/lib/go-1.11/bin/:$PATH - - RUN wget -P /tmp/ https://github.com/AsamK/signal-cli/releases/download/v0.6.2/signal-cli-0.6.2.tar.gz \ && tar -C /usr/bin -xzf /tmp/signal-cli-0.6.2.tar.gz \ && rm -rf /tmp/signal-cli-0.6.2.tar.gz diff --git a/README.md b/README.md index 91f096d..7eacc40 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ services: Sample REST API calls: * Register a number (with SMS verification) -```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/register/'``` +```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/'``` e.g: ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291'``` diff --git a/doc/HOMEASSISTANT.md b/doc/HOMEASSISTANT.md new file mode 100644 index 0000000..5fa41c8 --- /dev/null +++ b/doc/HOMEASSISTANT.md @@ -0,0 +1,45 @@ +# README + +This document describes how to use the Signal Messenger REST API together with Home Assistant. + +prerequisites: +* docker + docker-compose +* a phone number to spare + +## Set up the docker container + +* Create a `docker-compose.yml` file with the following contents: + +``` +version: "3" +services: + signal-cli-rest-api: + image: bbernhard/signal-cli-rest-api:latest + ports: + - "8080:8080" # map docker port 8080 to host port 8080. + network_mode: "host" + volumes: + - "./signal-cli-config:/home/.local/share/signal-cli" # map "signal-cli-config" folder on host system into docker container. the folder contains the password and cryptographic keys when a new number is registered +``` + +* start the docker container with `docker-compose up` + + +## Register phone number + +In order to send signal messages to other users, you first need to register your phone number. This can be done via REST requests with: + + +```curl -X POST -H "Content-Type: application/json" 'http://:/v1/register/'``` + +e.g: + +This registers the number `+431212131491291` to the Signal network. +```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291'``` + +After you've sent the registration request, you will receive a token via SMS for verfication. In order to complete the registration process you need to send the verification token back via the following REST request: + +```curl -X POST -H "Content-Type: application/json" 'http://:/v1/register//verify/'``` + +e.g: +```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291/verify/123-456'```