Calculating per-area power consumption, excluding nested sensors (upstream device)

I have about 50 energy-monitoring smartplugs. Many of them are nested - for example, smartplugs for devices that are connected to a UPS, with the UPS itself being on such a smartplug.

I have enabled the “upstream device” relationship for those power sensors on nested smartplugs, so that the total consumption for all devices is accurate.

However, I’m trying to create per-area template sensors, that add up the power consumption for all sensors in that area. The problem is that I can’t figure out how to exclude the nested sensors from the calculation. This causes them to be double-counted, making the value of the sensor overinflated, and not useful.

It appears there is no device attribute that can be used to check for the upstream device relationship.

Edit: actually, the “upstream device” relationship is only for energy sensors, not power sensors. I feel that there should be a way to set this relationship for both the energy and power sensors. Many devices only have one of each. This is the case for all my KP125 smart-plugs. Setting the parent/child relationship at the device level would make sense for such devices. But I understand some devices have more than one consumption & power sensor.

Is there any workaround for this ?

If you are getting double counting happening consistently, why not just just halve that value?
Have you tried grouping them?