Show energy meter devices as a power meter in the Energy tab#75
Open
dohun0310 wants to merge 4 commits into
Open
Show energy meter devices as a power meter in the Energy tab#75dohun0310 wants to merge 4 commits into
dohun0310 wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SmartThings devices that only report power/energy (e.g. whole-home energy monitors) were paired in Homey as a plain sensor with just a
meter_powercapability. They never appeared in Homey's Energy tab as a power meter, and live power readings (W) were missing entirely.Root causes
CapabilityMap2), the SmartThingsenergyMetercapability (accumulated energy, kWh) was mapped to Homey'smeasure_power(instantaneous power, W), andpowerMeter(W) was mapped tometer_power(kWh) — the exact opposite of the data-fetch mappings inCapabilityMap1.getDeviceCapabilityValue()throws on HTTP 422/403 when a SmartThings device does not support the queried capability, andgetDeviceValues()reacted by removing the Homey capability immediately — before the configured fallback source (powerConsumptionReport) ever got a chance to run. Combined with the swapped mapping, this is why devices ended up with onlymeter_power.Changes
energyMeter→meter_power(kWh) andpowerMeter→measure_power(W), matching the data-fetch tables.energy: { "cumulative": true }, so Homey shows them as the home power meter in the Energy tab.Device.setEnergy().meter_powerregain the missingmeasure_powercapability when the SmartThings device actually reportspowerMeter, and a one-time migration (guarded by a store flag) defaults the new toggle to ON for pure meter devices (sensor class, noonoff) and OFF for everything else.Testing
homey app validatepasses at leveldebug.