You should always be tracking via the slot when using the totem events, and not via the spellID.
I highly doubt classes other than shaman will have a valid spellID, and the tooltips use tooltip:GetTotem(slot) to fill the tooltip information.
With COMBAT_LOG_EVENT_UNFILTERED and SPELL_SUMMON, you should be able to use something like this (untested):
Code:
local summons = {}
function frame:COMBAT_LOG_EVENT_UNFILTERED(timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
if event == 'SPELL_SUMMON' and sourceName == UnitName('player') then
local spellId, spellName, spellSchool = ...
-- increment counter
if not summons[destName] then
summons[destName] = {}
end
summons[destName] = summons[destName][destGUID] = timestamp
-- demons last 12 seconds, remove from table
C.Timer.After(12, function() summons[destName][destGUID] = nil end)
end
end
It's then up to you to have a function that returns the current summons[destName] count, and another function to get the health from the GUID.
Be aware that the above code is untested. I'm also assuming destName/destGUID is used for the summoned demon. You could also store the table as a saved variable, which means you can still get an accurate count after a loading screen.
You could also probably combine them or use some other method to determine how many were summoned.