Signal Messenger using received message

the signal instructions seem to be wrong according to this thread: Unable to receive messages using Signal Messenger integration - #4 by Lewis

same here: Signal Messanger - can't recieve messages Websockets support needed. · Issue #117555 · home-assistant/core · GitHub

this might be a way around: GitHub - kalbasit/signal-api-receiver

this solution worked for me:

  1. install signal - make sure sending works, I changed the port to 9123
  2. change signal configuration to “json-rpc” and start addon
  3. test in terminal / ssh with :
curl http://192.168.1.77:9123/v1/about

should return:

{"versions":["v1","v2"],"build":2,"mode":"json-rpc","version":"0.92","capabilities":{"v2/send":["quotes","mentions"]}}#   

  1. in the following this fixed homeassistant IP is assumed: 192.168.1.66
  2. install : GitHub - hassio-addons/addon-appdaemon: AppDaemon4 - Home Assistant Community Add-ons
  3. in appdaemon configuration: grey box “python packages” write “websockets” and press “save”
  4. goto appdaemon folder: addon_configs/a0d7b954_appdaemon/apps
  5. change file : apps.yaml to (keep “—”)
 ---
hello_world:
  module: hello
  class: HelloWorld
signal_receiver:
  module: signal_listener
  class: SignalReceiver
  signal_ws_uri: "ws://192.168.1.66:YOUR_SIGNALPORT/v1/receive/+49YOURPHONENUMBERHERE"   

in my case it looks like this: :wink:

---
hello_world:
  module: hello
  class: HelloWorld
signal_receiver:
  module: signal_listener
  class: SignalReceiver
  signal_ws_uri: "ws://192.168.1.66:9123/v1/receive/+49190666666"   
  1. in appdaemon folder: addon_configs/a0d7b954_appdaemon/apps create new file " signal_listener.py" with content:
#!/usr/bin/python3 
import appdaemon.plugins.hass.hassapi as hass
import websockets
import asyncio
import json

class SignalReceiver(hass.Hass):
    async def initialize(self):
        self.uri = self.args.get("signal_ws_uri", "ws://localhost:8080/ws")
        self.log(f"Starting Signal WebSocket listener to {self.uri}")
        asyncio.create_task(self.listen_to_signal())

    async def listen_to_signal(self):
        while True:
            try:
                async with websockets.connect(self.uri) as websocket:
                    self.log("Connected to Signal WebSocket")
                    while True:
                        message = await websocket.recv()
                        self.log(f"Received Signal message: {message}")
                        
                        try:
                            data = json.loads(message)
                        except json.JSONDecodeError:
                            self.log("Warning: Received non-JSON message", level="WARNING")
                            data = {"raw_message": message}

                        # Fire event with parsed data
                        self.fire_event("signal_message_received", **data)
            except (websockets.exceptions.ConnectionClosedError, ConnectionRefusedError) as e:
                self.log(f"WebSocket connection error: {e}", level="ERROR")
                self.log("Retrying connection in 5 seconds...")
                await asyncio.sleep(5)
            except Exception as e:
                self.log(f"Unexpected error: {e}", level="ERROR")
                self.log("Retrying connection in 5 seconds...")
                await asyncio.sleep(5)
  1. create new automation:
alias: receive Signal Messages
description: "solution via app deamon and addon_configs/a0d7b954_appdaemon/apps"
triggers:
  - event_type: signal_message_received
    trigger: event
actions:

  - action: notify.signal
    data:
      message: "Home assistant received Signal message from {{ trigger.event.data.envelope.source }}:{{ trigger.event.data.envelope.dataMessage.message }}"
  1. restart HA!
    send signal message from your phone and enjoy!
2 Likes