So I’ve been re-working my Zanzito GPS script (I’ve since learned more than I did when I first wrote it) and I’m running into a problem combining attributes, for example:
# triggered Entity trigName = data.get('entity_id') trigState = hass.states.get(trigName) # newState trigAttr = trigState.attributes.copy() # newstateAttributes trigStatus = trigState.state # newStatus # metatracker Entity metaName = "device_tracker." + data.get('meta_entity') metaState = hass.states.get(metaName) # currentState metaAttr = metaState.attributes.copy() metaStatus = metaState.state
This works fine - the problem is when I’m trying to load my metaTracker with attributes from both:
hass.states.set(metaName, trigStatus, trigAttr) hass.states.set(metaName, trigStatus, metaAttr)
I suspect there’s some clobbering going on here (which to some extent is fine if metaAttr clobbers values from trigAttr) but is there a better way to combine them into one set of attributes and then set the states?
Edit: example data. In my case, device_tracker.vals is an iCloud device_tracker and device_tracker.val is my metaTracker - I’d like to combine the values from both with the metatracker having priority with regards to gps coords. As you can see, source_type doesn’t merge in (for example.)