def get_count(whid, alarm_data):
	device_count = {}
	provider = "[%s_SCADA_TAG_PROVIDER]" % (whid)
	int_to_priority ={"5":"Critical", "4":"High", "3":"Medium",
	"2":"Low", "1":"Diagnostic"}
	for k,v in alarm_data.items():
		source_id = k
		device_id = source_id.split("/")[0]
		alarm_data = v
		priority = str(v["priority"])
		priority_string = int_to_priority.get(priority, "Unknown")
		check = device_count.get(device_id)
		if check == None:
			device_count[device_id] = {"Critical":0, "High":0, "Medium":0, "Low":0, "Diagnostic":0, "Unknown":0}
			device_count[device_id][priority_string]+=1
		else:
			device_count[device_id][priority_string]+=1
	counts_encoded = system.util.jsonEncode(device_count)
	system.tag.writeAsync([provider+"System/device_count"],[counts_encoded])
			  
		
		
	
	
