Use Signal Messenger for Notifications

That’s something I’d like to do too, I don’t know how much time I have on this though :wink:

In the meantime you can: Install signal-cli on your machine, read the documentation and launch the registration process.
Once it’s done, simply copy the .signal folder inside your home assistant configuration folder and it’ll work

2 Likes

Great! I’m excited :stuck_out_tongue: Will create my config locally and transfer it to report back if it works.

Building was successful on my hassio machine, just got these two warnings in the log:

This should be fixed in version 7, the schema was missing. Just curious, how do you got these logs?

1 Like

On your hassio system navigate to the hassio menu (left) and choose the tap far right (system) down the page you have your System log (needs manual refreshing with the button on the end to update).

Direct link would be hostname:8123/hassio/system

1 Like

Wow, I’ve never been there before :slight_smile: thanks!

1 Like

Ok I got it working with the associated custom_component \o/.

"""
Signal Messenger for notify component.
Place this in `<confdir>/custom_components/signalmessenger/notify.py`
"""
from urllib import request
import json
import logging
import voluptuous as vol
from homeassistant.components.notify import (
    ATTR_DATA, ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA,
    BaseNotificationService)
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = []

_LOGGER = logging.getLogger("signalmessenger")

CONF_RECEIVER_NUMBER = 'receiver'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_RECEIVER_NUMBER): cv.string,
})


def get_service(hass, config, discovery_info=None):
    """Get the Join notification service."""
    receiver_number = config.get(CONF_RECEIVER_NUMBER)

    if receiver_number is None:
        _LOGGER.error("receiver_number is required")
        return False

    _LOGGER.info("Service initialized")
    return SignalNotificationService(receiver_number)


class SignalNotificationService(BaseNotificationService):
    """Implement the notification service for Join."""

    def __init__(self, receiver_number):
        """Initialize the service."""
        self.receiver_number = receiver_number

    def send_message(self, message="", **kwargs):
        _LOGGER.info("Calling with message")
        """Send a message to a user."""
        params = json.dumps({"number": self.receiver_number, "content": message}).encode('utf8')
        req = request.Request("http://4a36bbd1-signal:5000/message",
                              data=params,
                              headers={'content-type': 'application/json'})
        resp = request.urlopen(req)
        _LOGGER.info(resp)

2 Likes

I saw Version 9 is released and I’m curios about the change log :wink:

You mean version 8 :wink:
I’m trying to make signal faster. Apparently there is a problem with /dev/randow exhaustion, and I tried using /dev/urandom

What I’m working on is using dbus to let a signal daemon always running, and sending/receiving messages via dbus, it’ll be much faster that way, and use a lot less resources

2 Likes

Please make HACS version (or official component) for easy install.

BTW, Actionable notifications are available here?

1 Like

It’s available as hassio addon. See here (and add the custom repo): https://github.com/agileek/hassio-addons

2 Likes

I reworked on it a little, and I was able to speed messages sending by a lot.

I took 3-5 minutes on my machine to send a message, now it takes only 5-10 seconds.

I played with /dev/urandom a little and dbus instead of launching a new JVM for each message.

Added bonus, by using dbus i’ll be able to receive messages as well, and forward them to home assistant to query an intent_script for example, and retrieve the temperatures, or switch lights…

3 Likes

Wow! Thank’s a lot, this is great news!

1 Like

I added a README to help for the setup process, I hope it helps.
I also added the signalmessenger custom_component code in this repo, it’ll be much easier to update all at once.

3 Likes

In signal-cli’s current iteration, dbus is the way to go. I am curious though, what you are running that it was taking 3-5 minutes and now 5-10 seconds?

I am running on a Pi 3b+ and when I was testing it was around 8-10 seconds when I was not running in daemon/dbus mode and it had to fire up each JVM (using havged). Now that I am running in dbus it is near instant in testing (I have a script dumping dbus to a mqtt topic, and a node-red mqtt input flow just echoing the message back with a dbus-send wrapper script for testing).

-pd

I don’t really know, it’s super slow on my rpi 3b, I did not investigate further :wink:

I assumed it had something to do with the randomness exhaustion stuff.

Right now it’s still not instantaneous, it takes a couple of seconds before reaching my phone, whereas when I use signal-cli on my laptop the messages are blazing fast. Anyway I don’t think it needs to be blazing fast for the home automation system, right?

2 Likes

No worries, as I said I was just curious is all.

When I saw your post about dbus investigation I started looking at it for node-red stuff I am playing with and I am happy with the increased speeds. But yeah you are right - blazing speeds may not be needed, but it is always nice to see increased performance!

-pd

I want it blazing fast please :rocket: :star_struck:

1 Like

It’s slow on your machine too?

No, couldn’t test it yet … But faster is always better :stuck_out_tongue: Anyhow couple of seconds is already fast - but as you proofed it could be somehow even faster

Hope I can test it soon on a x86 or raspi 3 machine with hassio. I will report back!

2 Likes

Question (as I couldn’t find the answer in this thread):

Is it (already) possible to attach pictures and videos to the signal message? I’m thinking of a notification of my $5 esp 32 camera when motion is detected and get a message with some pictures or a short video clip :upside_down_face: