Signal Binding [4.0.0.0;5.0.0.0)

Hi, no … so far I still run into the same error.

Hello.

Thanks for your test !
I made a new release (BETA 4) with updated signal and signal-cli libraries, I tested it on a clean openhabian, and it seems to work, without installing anything else. I really don’t understand why it works sometimes and sometimes not. Anyway I will make a note with your workaround on the open post.

Two things here :

  • Sorry, I left a bug in the last BETA 3 release, and sms verification was not available anymore (forcing vocal validation)
  • according to signal-cli forum, vocal validation is broken. Error message is “rate limit”, because they forbid to use vocal validation without trying sms validation first. In the discussion linked, a workaround is to try sms first, wait a minute, then vocal. I tried to implement this in the BETA4 release, but I didn’t test. Feedback welcome.

The new BETA4 release change the send action and add a mandatory string argument in last position to put text with image.

Hello,
Strange error. I wrote a rule file and this works for me :

rule "testwithrule"
when
    Item NewItem received command
then
   getActions("signal","signal:signalaccountbridge:bab72f1f7d").sendSignal("+33612345678", "Test signal !")
end

I honnestly don’t know what to do to help you in this case…

Thank you, for your great work.

I am sorry, no good news. Now i got an Communication_error “NonSuccessfulResponseCodeException - [422] Bad response: 422”
How can i check that the phonenummer is or is not registered yet at signal. Maybe one of my several tests was succesful but not noticed be me. And if so, how can i remove my registration?
You wrote that now are two steps necessary. Frist try with SMS which fails and second try with vocal response. Do i need for the second step a new captcha link?

Thanks so far

So, now i got it. Don´t ask why or how.
Maybe it would be an advantage if the registration manual would be a little more specific with more details.
I tried a lot and now registration is completed.
Thank you for creating this binding and the help.

You can always register, even on phone number previously used, without “unregistering”.
The new process simply disables previous registrations.

The BETA4 does this two steps request for you, and it seems that it can use the same captcha, so no action required (except waiting longer for the registration to process, at least a minute). I made a test and it seems to work.

I’m now used to and if it works,I don’t try to understand anymore :sweat_smile:

Hi @dalgwen , When you are doing the captcha, what exactly do you need to paste in? I get a link to open Signal that has a UUID and then a very long generated string. Does the binding want the entire URL pasted including signalcaptcha://signal-hcaptcha ? Or is this not even what it is looking for?

Everything I try gets a 422 Error: NonSuccessfulResponseCodeException - [422] Bad response: 422

Thanks
Jim

Hi All,

i have a question on setting it up with multple rule files.
Do i always have to register the bridge in every rule like this:

rule "Switch Change Notification"
when
    Item NewItem changed
then
    val signalAction = getActions("signal","signal:signalaccountbridge:701746fc6b")
signalAction.sendSignal("+332121212121212", "Alert !")

end

or can this part(val signalAction = getActions(“signal”,“signal:signalaccountbridge:701746fc6b”)

Blockquote

be “outsourced” in a central location like things or item file?
Like

rule "Switch A Change Notification"
when
    Item NewItem changed
then
signalAction.sendSignal("+332121212121212", "Alert in rule 1")
end

rule "Switch B Change Notification"
when
    Item NewItem changed
then
signalAction.sendSignal("+332121212121212", "Alert a in rule 2")
signalAction.sendSignal("+332121212121212", "Alert b in rule 2")
end

rule "Switch C Change Notification"
when
    Item NewItem changed
then
signalAction.sendSignal("+332121212121212", "Temp var in rule 3")
end

I have the feeling that OH3&4 are not intializing the bridge properly on startup and it hangs often. And i think its because i register the bridge in every rule.

Any hint is highly appreciated

Hello,

Sorry for the delay.
You have to copy paste everything, including signalcaptcha://signal-hcaptcha.
It is very long indeed. I just tried to register another number today and it worked.
Mine was something like this :
signalcaptcha://signal-hcaptcha.5fad97ac-7d06-4e44-b18a-b950b20148ff.registration.P1_eyJ0eXAiOiJKV1QiLCJ[......................]F8izmndtjI9C9dCoVUQmlJ_k
(edited in the middle because, as I said, very long)

Did you try again since then ? It could be a temporary issue on the registering server (not the first time)

I outsource mine as a “script” in ECMAScript-2021. It is defined in the UI, but I think it is the same with a file in the script directory :

var { actions } = require('openhab');
actions.Things.getActions("signal", "signal:signalaccountbridge:bab72f1f7d").sendSignal("+33123456789", notificationtext)

notificationtext is a context variable that is setted when I call the script from something else.
For example, to call it, I use it from blockly (“run rule or script with context” in “openHAB” “runProcess” block section).

For information, it transcripts to this jsr javascript code :
ruleManager.runNow('notification', true, convertDictionaryToHashMap({'notificationtext': 'Hello Word'}));

And the convertDictionaryToHashMap function is defined like this :

function convertDictionaryToHashMap (dict) {
  if (!dict || dict.length === 0) return null;
  var map = new java.util.HashMap();
  Object.keys(dict).forEach(function (key) {
    map.put(key, dict[key]);
  });
  return map;
}

(again, it is not my code but the blockly transcription)

I’m not 100% sure, but I don’t think it’s feasible from a rule in the rule DSL.

BUT, you can also check ideas here for a great post by the greatest forum member here. .

For all practical purposes they can be thought of as the same. However, they are actually quite different.in some ways but those don’t matter here.

But this is actually a relatively recent situation. Prior to a change to core that loaded everything from the Script folder and treat it like a rule, the only way to execute a Rules DSL Script was through the callScript Action.

I don’t see anything here that can’t work with Rules DSL.

Maybe, most dedicated?

I keep running into old post /dead end when I search “run script from rule”, and so my claim was about calling a script with argument from a rule (DSL), the same way we can do it from jsr script.
For example Here it is said that you can’t use argument when calling script from rule.
But I think, as I see you saying several time, “script” is a little bit misleading, and you can indeed do everything with pattern like the ones you made.

And humble, too ! :smile:

The term “script” is way overloaded in OH. See Rules | openHAB

Back when that design pattern was written, it only had one meaning and that was a Rules DSL .script file called with the callScript action. You couldn’t have a rule that called another rule. UI rules were not a thing so there were not UI Script rules or Script Actions.

Hi @dalgwen and thanks for you reply.
So what i understand is, that you can use a script and rules to fire up a signal message.
However you cannot pass on own text in terms of a value.
Now my ultimate goal is to call a global function like the below from any rule since i need my own messages and not states of items etc.

sendSignalMessagetoMyPhone(textvariablecomeshere)

I also checked Design Pattern: Separation of Behaviors but it doesnt look like that i can use the signal binding.

Any clues?

Yes you can and @dalgwen demonstrates how to do it. You create a map and pass that map as the third argument in the call to runNow. Each entry in the map will be injected into the called rule as a variable.

That’s what the whole convertDictionaryToHashMap stuff is all about. Though I wonder why that’s strictly necessary. At least in JS Scripting (the replacement for Nashorn JS) it isn’t. Here’s a call from one of my rule tempaltes.

        rules.runRule(ruleID, {'alertItem':        record.name,
                               'alertState':       ''+state,
                               'isAlerting':       isAlerting,
                               'threshItems':      allAlerting,
                               'threshItemLabels': alertingNames,
                               'nullItems':        nullItems,
                               'nullItemLabels':   nullItemNames}, true);

??? There must be something missing from your understanding of either that design pattern or OH itself.

At a high level that design pattern says: Command a String Item with a message to send. That triggers a rule that has the code to call the Signal binding’s Action to send that string as the message.

If you can use the Signal binding in any rule, you can use it with separation of behaviors.

Yes. Everywhere, whatever rule language you use.

You can, from a rule defined in a JSR scripting langage or blockly (as Rich and I shows). But not directly from a rule written in the rule DSL as you seem to want.
I said “directly”, because in fact you also can from a rule in the rule DSL, but you have to add an intermediary trick like those in the post explaining separation of concern.
In the rule written in rule DSL, you send your text as a command to an item, and a rule (still in DSL) monitor this item event and use the receivedCommand.toString to get the text. You can then call the Signal action from this. And so you achieve what you wanted : calling signal from one and only one place.

I’m no expert in Rule, I hope I’m not saying anything erroneous…

Thanks @rlkoshak and @dalgwen. I really believe i need to play around withit to grasp the whole concept and approach.
Because to your question @rlkoshak :

Both is unfortunately to some extend true :joy:

Indeed, that is a limitation of Rules DSL. I used to be the Rules DSL champion but once we got good Blockly support I simply cannot recommend it any more. It was never a great environment for those who already know how to program but Blockly is a far superior environment for those who do not know how to program. So Rules’ DSL niche has been replaced by Blockly.

I cannot recommend Rules DSL except for some old timers who have a bunch of rules written in Rules DSL and they don’t want to rewrite them. I strongly recommend new work and new users choose anything else (except Jython which has different problems). If don’t know programming, Blockly is excellent. If you do, JS Scripting or jRuby are excellent. Groovy and Java are options as well.

1 Like