From 3a791502bb5e00587ed93fb582c9ed082831008a Mon Sep 17 00:00:00 2001 From: Joop Date: Thu, 2 Mar 2023 15:31:23 +0100 Subject: [PATCH 1/3] Update HOMEASSISTANT.md Adding a description on how signal-cli-rest-api can trigger automations in Home Assistant. (Sending messages to Signal to trigger events) --- doc/HOMEASSISTANT.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/doc/HOMEASSISTANT.md b/doc/HOMEASSISTANT.md index 3a8bc14..b61cb0e 100644 --- a/doc/HOMEASSISTANT.md +++ b/doc/HOMEASSISTANT.md @@ -6,7 +6,7 @@ This document covers the following topics: * [Installation](#installation) * [Set up a phone number](#set-up-a-phone-number) * [Sending messages to Signal Messenger groups](#sending-messages-to-signal-messenger-groups) - +* [Sending messages to Signal to trigger events](##sending-messages-to-signal-to-trigger-events) See also the [documentation of the Home Assistant integration](https://www.home-assistant.io/integrations/signal_messenger/). ## Installation @@ -174,6 +174,33 @@ In order for groups to show up in the `groups` list, try the following steps: curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/receive/' ``` +## Sending messages to Signal to trigger events +In this example, we will be using signal-cli-rest-api to as a Home Assistant trigger. For example, you would be able to write 'light' to your Signal account linked to signal-cli-rest-api and have Home Assistant adjust the lights for you. To accomplish this, you will need to edit the `rest.yaml` configuration of Home Assistant, add the following resource: +```- resource: "http://127.0.0.1:8080/v1/receive/" + headers: + Content-Type: application/json + sensor: + - name: "Signal message received" + value_template: '{{ value_json[0].envelope.dataMessage.message }}' + ``` +And then you can create an automation as follows: +```alias: "[signal] message received" +trigger: + - platform: state + entity_id: + - sensor.signal_message_received +condition: [] +action: + - if: + - condition: state + entity_id: sensor.signal_message_received + state: + then: + - service: + data: {} +mode: single +``` + ## API details From b65678857324e8c5e2d8eb45977706927785c027 Mon Sep 17 00:00:00 2001 From: Joop Date: Fri, 3 Mar 2023 08:48:07 +0100 Subject: [PATCH 2/3] Update HOMEASSISTANT.md Adding a description on how signal-cli-rest-api can trigger automations in Home Assistant. (Sending messages to Signal to trigger events) --- doc/HOMEASSISTANT.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/HOMEASSISTANT.md b/doc/HOMEASSISTANT.md index b61cb0e..00a2a2d 100644 --- a/doc/HOMEASSISTANT.md +++ b/doc/HOMEASSISTANT.md @@ -6,7 +6,8 @@ This document covers the following topics: * [Installation](#installation) * [Set up a phone number](#set-up-a-phone-number) * [Sending messages to Signal Messenger groups](#sending-messages-to-signal-messenger-groups) -* [Sending messages to Signal to trigger events](##sending-messages-to-signal-to-trigger-events) +* [Sending messages to Signal to trigger events](#sending-messages-to-signal-to-trigger-events) + See also the [documentation of the Home Assistant integration](https://www.home-assistant.io/integrations/signal_messenger/). ## Installation From 5c7bfcd2838b4a2ca9476876b288b32b188f3a98 Mon Sep 17 00:00:00 2001 From: Joop Date: Fri, 3 Mar 2023 13:23:31 +0100 Subject: [PATCH 3/3] Update HOMEASSISTANT.md --- doc/HOMEASSISTANT.md | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/doc/HOMEASSISTANT.md b/doc/HOMEASSISTANT.md index 00a2a2d..7083597 100644 --- a/doc/HOMEASSISTANT.md +++ b/doc/HOMEASSISTANT.md @@ -176,33 +176,42 @@ In order for groups to show up in the `groups` list, try the following steps: ``` ## Sending messages to Signal to trigger events -In this example, we will be using signal-cli-rest-api to as a Home Assistant trigger. For example, you would be able to write 'light' to your Signal account linked to signal-cli-rest-api and have Home Assistant adjust the lights for you. To accomplish this, you will need to edit the `rest.yaml` configuration of Home Assistant, add the following resource: -```- resource: "http://127.0.0.1:8080/v1/receive/" + +You can use Signal Messenger REST API as a Home Assistant trigger. In this example, we will make a simple chatbot. If you write "time" to your Signal account linked to Signal Messenger REST API, the automation gets triggered, with the condition that the number (attribute source) is correct, to take action by sending a Signal notification back with the current time: now(). + +To accomplish this, edit the configuration of Home Assistant, adding a [RESTful resource](https://www.home-assistant.io/integrations/rest/) as follows: + +```yaml +- resource: "http://127.0.0.1:8080/v1/receive/" headers: Content-Type: application/json sensor: - name: "Signal message received" - value_template: '{{ value_json[0].envelope.dataMessage.message }}' + value_template: "{{ value_json[0].envelope.dataMessage.message }}" #this will fetch the message + json_attributes_path: $[0].envelope + json_attributes: + - source #using attributes you can get additional information, in this case the phone number. ``` -And then you can create an automation as follows: -```alias: "[signal] message received" +You can create an automation as follows: + +```yaml +... trigger: - platform: state entity_id: - sensor.signal_message_received -condition: [] + to: time +condition: + - condition: state + entity_id: sensor.signal_message_received + attribute: source + state: "" action: - - if: - - condition: state - entity_id: sensor.signal_message_received - state: - then: - - service: - data: {} -mode: single + - service: notify.signal + data: + message: "{{ now() }}" ``` - ## API details Details regarding API (in example for receiving messages through REST) can be found [here](https://bbernhard.github.io/signal-cli-rest-api/)