sendNotificationsToContacts() FAILING

All my apps that have implemented the sendNotificationToContacts() call as per the on-line documentation have started to fail with errors on that call - this began something in the last 24-48 hours.

Is anyone else having issues this with this? The call us supposedly supported, and was working fine until this started happening.

Followup - the call seems to have been deleted or deprecated, as the error is groovy.lang.MissingMethodException for sendNotificationToContacts()

Can you show some code with context that you are using?

I tested this as Ask Alexa uses this functionality. It works fine for me for push and SMS messages.

1 Like

Sure - actually cut and past from the documentation for sendNotificationToContacts() - no changes, worked Monday, stopped yesterday. Also not working on SMH notifications, either, so it’s not just me…

//notifications to device, pushed if requested
def note(status, message, type){
log.debug “${status}: ${message}“
switches.notify(”${status}”, “${message}”)
if(notify)
{
if (notify.contains(‘Daily’) && type == “d”){
send(message)
}
if (notify.contains(‘Weather’) && type == “f”){
send(message)
}
if (notify.contains(‘Warnings’) && type == “w”){
send(message)
}
if (notify.contains(‘Moisture’) && type == “m”){
send(message)
}
}
}

def send(msg) {
if (location.contactBookEnabled && recipients) {
log.info ( “Sending ‘${msg}’ to selected contacts…” )
sendNotificationToContacts(msg, recipients, [event: true])
}
else {
log.info ( “Sending Push Notification ‘${msg}’…” )
sendPush( msg )
}
}

Here’s the log entry:

6:33:36 AM: error groovy.lang.MissingMethodException: No signature of method: script1471440815430227522555.sendNotificationToContacts() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl, physicalgraph.app.ContactProfileWrapper, java.util.LinkedHashMap) values: [SS2.52 New Odd manually started, watering in 1 minute:
Driveway Top Left: 3 x 5 min
Lower 40 Front Right: 2 x 30 min
Lower 40 Back Right: 2 x 30 min
, ...]
Possible solutions: sendNotificationToContacts(java.lang.String), sendNotificationToContacts(java.lang.String, java.lang.String), sendNotificationToContacts(java.lang.String, java.util.Collection), sendNotificationToContacts(java.lang.String, java.lang.String, java.util.Map), sendNotificationToContacts(java.lang.String, java.util.Collection, java.util.Map) @ line 1344

I wonder if the problem is something to do with [event: true] …

I don’t have the [event: true] in mine…may want to exclude that as that is the only thing different than in my code.

Does your contact input have multiple: false? I think that might be causing the issue. Try removing it and let me know if the error goes away.

I encourage you to open a ticket as well; looks like a bug.

I sent this to support before posting here, but no response from them yet.

The code does not specifically define nultiple:false -

section("Push Notifications") {
        input (name: "notify", type: "enum", title: "Select what push notifications to receive.", required: false, multiple: true,
        metadata: [values: ['Warnings', 'Daily', 'Weekly', 'Weather', 'Moisture']])
        input("recipients", "contact", title: "Send push notifications to", required: false)
} 

The documentation says that the contact list can be either a string or a collection - that said, I do have only 1 contact specified in the SmartApp configuration…:

Signature:
void sendNotificationToContacts(String message, String contact, Map options=[:])

void sendNotificationToContacts(String message, Collection contacts, Map options=[:])

Parameters:
String message - the message to send

String contact - the contact to send the notification to. Typically set through the contact input type.

Collection contacts - the collection of contacts to send the notification to. Typically set through the contact input type.

Map options (optional) - a map of additional parameters. The valid parameter is [event: boolean] to specify if the message should be displayed in the Notifications feed. Defaults to true (message will be displayed in the Notifications feed).

You’re not doing anything wrong, this looks like a bug.

I’ve created a bug in our internal tracking system and forwarded this on to engineers as well.

3 Likes

Adding “, multiple: true” to the settings for recipients solves the problem…was not required before…

FWIW, the documentation example for sendNotificationToContacts() should be updaed to include multiple:true in the settings. The bug is real (not accepting a string, requiring a Collection), but the example doesn’t make it clear that multiple: true needs to be defined.

Thanks, Jim!

2 Likes

Nice to see this bug still exists and the docs haven’t been updated… 15 months later…

Yep, I got burned by that issue a few weeks ago when adding Contacts to my SmartApp.