Add voltage and current monitoring to smart Devices (#1281)

This commit is contained in:
Ryan Nitcher
2024-11-20 11:18:30 -07:00
committed by GitHub
parent 59b047f485
commit dab64e5d48
3 changed files with 36 additions and 5 deletions

View File

@@ -138,6 +138,19 @@ class FakeSmartTransport(BaseTransport):
),
"get_device_usage": ("device", {}),
"get_connect_cloud_state": ("cloud_connect", {"status": 0}),
"get_emeter_data": (
"energy_monitoring",
{
"current_ma": 33,
"energy_wh": 971,
"power_mw": 1003,
"voltage_mv": 121215,
},
),
"get_emeter_vgain_igain": (
"energy_monitoring",
{"igain": 10861, "vgain": 118657},
),
}
async def send(self, request: str):

View File

@@ -211,5 +211,8 @@ async def test_supported(dev: Device):
assert energy_module.supports(Energy.ModuleFeature.PERIODIC_STATS) is True
else:
assert energy_module.supports(Energy.ModuleFeature.CONSUMPTION_TOTAL) is False
assert energy_module.supports(Energy.ModuleFeature.VOLTAGE_CURRENT) is False
assert energy_module.supports(Energy.ModuleFeature.PERIODIC_STATS) is False
if energy_module.supported_version < 2:
assert energy_module.supports(Energy.ModuleFeature.VOLTAGE_CURRENT) is False
else:
assert energy_module.supports(Energy.ModuleFeature.VOLTAGE_CURRENT) is True