sendLocationEvent() changes types for Map to String? Why

I have a server App that serves Notifications like this:

Map Notification = [message: "Back Door Open"]

log.debug "type = " + getObjectClassName(Notification) // shows "type = java.util.LinkedHashMap"

sendLocationEvent(name:"NOTIFICATION", value: Notification, data: "Ring", descriptionText: "description you want", isStateChange: true)

I have a client App that subscribes to this and the first line in the event handler I get:

log.debug "type = " + getObjectClassName(evt.value) // shows "type = java.lang.String"

I am expecting to get a Map delivered in the handler just like I sent it.

I must be a bad researcher because I am looking for an explanation and cannot find one. Does someone know what is going on?
Thanks

1 Like

I'm not sure this is documented, but a good guess would be that the location object allows only strings for values on any event. (Groovy makes it easy to convert back and forth, though JSON would be a more conveniential intermediate format.)

Could you provide me a little more detail about "Groovy makes it easy to convert back and forth".
Thanks

Here is an example, this being for the lightEffects attribute that is really a Map converted to/from JSON. It's just a device event/attribute, but doing this for a location event would be similar.

2 Likes

Bert, I really appreciate the help. It wasn't exactly like the example but it was close enough. I ended up with "def NotificationConverted = new groovy.json.JsonBuilder(Notification).toString()" in the Server and "def NotificationBack = new groovy.json.JsonSlurper().parseText(evt.value)" in the Client. You know this is totally straight forward right? NOT! LOL... thks again

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.