From 12b8d40299740edbfb8f2d41acdba804cfb4a1ac Mon Sep 17 00:00:00 2001 From: Timo Schilling Date: Fri, 20 Jan 2023 23:50:22 +0000 Subject: [PATCH] tmp --- src/shelly_switch.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/shelly_switch.cpp b/src/shelly_switch.cpp index 13a5191c..05afc38e 100644 --- a/src/shelly_switch.cpp +++ b/src/shelly_switch.cpp @@ -368,10 +368,10 @@ void ShellySwitch::AddPowerMeter(uint16_t *iid) { if (out_pm_ == nullptr) return; // Power - power_char_ = new mgos::hap::UFloatCharacteristic( - (*iid)++, &kHAPCharacteristic_EveConsumption, 0, 65535, 1, + power_char_ = new mgos::hap::FloatCharacteristic( + (*iid)++, &kHAPCharacteristic_EveConsumption, 0.0f, 65535.0f, 0.1f, [this](HAPAccessoryServerRef *, - const HAPUFloatCharacteristicReadRequest *, float *value) { + const HAPFloatCharacteristicReadRequest *, float *value) { auto power = out_pm_->GetPowerW(); if (!power.ok()) return kHAPError_Busy; *value = power.ValueOrDie(); @@ -380,13 +380,13 @@ void ShellySwitch::AddPowerMeter(uint16_t *iid) { true /* supports_notification */, nullptr, "eve-power-consumption"); AddChar(power_char_); // Energy - total_power_char_ = new mgos::hap::UFloatCharacteristic( - (*iid)++, &kHAPCharacteristic_EveTotalConsumption, 0, 65535, 1, + total_power_char_ = new mgos::hap::FloatCharacteristic( + (*iid)++, &kHAPCharacteristic_EveTotalConsumption, 0.0f, 65535.0f, 0.1f, [this](HAPAccessoryServerRef *, - const HAPUFloatCharacteristicReadRequest *, float *value) { + const HAPFloatCharacteristicReadRequest *, float *value) { auto energy = out_pm_->GetEnergyWH(); if (!energy.ok()) return kHAPError_Busy; - *value = energy.ValueOrDie() / 1000.0f; + *value = energy.ValueOrDie(); return kHAPError_None; }, true /* supports_notification */, nullptr, "eve-total-power-consumption");