Question on how to parse a message with "additionalAttr"

I have a Bosch Temperature, Pressure and Humidity sensor being sent to HE via a Zigbee device.
Each of the three types of data are received in sequential messages all to endpoint 1.

Each message has "additionalAttr" as part of the message. Based on how the additionalAttr is bracketed [ ] I'm guessing if I parse the original message I will get:

Mapped data for the beginning of the message
then the additionalAttr ( in [ ] brackets) I'm guessing will be a map in the above map. and the 2nd map will consist of two maps. I have not been able to find any references on how to parse the 2nd maps (if I'm correct in my assumption).

I think: (based on the bracket pairs):

Map = [dni, endpoint,cluster......clusterInt, attrInt,MAP2]
Map2 consists of [Map2a, Map2b]
Map2a = [value:6D, encoding:18, attrId:006F, consumedBytes:4, attrInt:111]
Map2b = [value: %,76, encoding:42, attrId:001C, consumedBytes:7, attrInt:28]

I would appreciate any pointers in the right direction.

John

04:43:45.683 pm dni:1C97, endpoint:01, cluster:000C, size:26, attrId:0055, encoding:39, command:0A, value:41A1EB85, clusterInt:12, attrInt:85, additionalAttrs:[[value:E8, encoding:18, attrId:006F, consumedBytes:4, attrInt:111], [value: C,76, encoding:42, attrId:001C, consumedBytes:7, attrInt:28]]]

04:43:45.687 pm dni:1C97, endpoint:01, cluster:000C, size:28, attrId:0055, encoding:39, command:0A, value:47C4D180, clusterInt:12, attrInt:85, additionalAttrs:[[value:00, encoding:18, attrId:006F, consumedBytes:4, attrInt:111], [value:Pa,76, encoding:42, attrId:001C, consumedBytes:8, attrInt:28]]]

04:43:45.692 pm dni:1C97, endpoint:01, cluster:000C, size:26, attrId:0055, encoding:39, command:0A, value:42176500, clusterInt:12, attrInt:85, additionalAttrs:[[value:6D, encoding:18, attrId:006F, consumedBytes:4, attrInt:111], [value: %,76, encoding:42, attrId:001C, consumedBytes:7, attrInt:28]]]

additionalAttr is a List of maps, which is itself a member of your Map object

You do:

Map.additionalAttr.each
{
  log.debug "${it}"
  log.debug "${it.value}"
}

or something like:

log.debug "${Map.additionalAttr[0].value}"

1 Like

I don't like to ask this as I should be able to figure it out but even with @tomw 's hint I can't seem to get the additional attributes parsed to a usable form. I've looked as some others code that contained additionalAttr but the code was too complex for me to pull out enough lines to make me understand their approach.

My current code is:

def parse(String description){
	log.debug " Raw Description =$description"

    if (description?.startsWith('read attr -')) {
		Map map = zigbee.getEvent(description)
    	def descMap = zigbee.parseDescriptionAsMap(description)
    	log.debug " Map Description =$descMap"

    	   
                log.debug " in additionalAttrs"
    	    	def additionalAttrs = map.additionalAttrs
    			map.additionalAttr.each
					{
				  		log.debug "it=${it}"
				  		log.debug "itVal=${it.value}"
					}
			
	}
}

What happens when you execute that code?

Do you definitely get into the startsWith('read attr -') block?
I'm not sure what getEvent does since it isn't documented.
But it looks like you actually want to access into descMap, not map. So, try this:

def parse(String description)
{
	log.debug " Raw Description = $description"

    if (description?.startsWith('read attr -')) 
    {
    	def descMap = zigbee.parseDescriptionAsMap(description)
    	log.debug "descMap = $descMap"

        log.debug " in additionalAttrs"
        def additionalAttrs = descMap?.additionalAttrs
        additionalAttrs.each
        {
            log.debug "it=${it}"
            log.debug "itVal=${it.value}"
        }
    }
}
1 Like

That did it :slight_smile: Thanks for the quick answer. I'm not a programmer but I do ok with old "C". I still struggle with VBA but groovy takes the mind set and moves WAY to the other side.
So you help is definitely appreciated.
John

1 Like