Skip to content

Commit 16b865f

Browse files
committed
rebase onto current master
1 parent 48ce964 commit 16b865f

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

fs_src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ <h1 id="head">Switch</h1>
454454
<label for="power_stats_total">Total:</label>
455455
<span id="power_stats_total"></span>
456456
</div>
457+
</div>
457458
<div>
458459
<div class="form-control">
459460
<label for="name">Name:</label>

fs_src/script.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ function updateComponent(cd) {
691691
setValueIfNotModified(el(c, "name"), cd.name);
692692
el(c, "state").checked = cd.state;
693693
updatePowerStats(c, cd);
694+
if (cd.type == Component_Type.kSwitch ||
695+
cd.type == Component_Type.kOutlet) {
696+
el(c, "hk_state_inverted_container").style.display = "block";
697+
checkIfNotModified(el(c, "hk_state_inverted"), cd.hk_state_inverted);
698+
}
694699
if (cd.type == Component_Type.kLightBulb) {
695700
checkIfNotModified(el(c, "svc_hidden"), cd.svc_hidden);
696701
if (cd.hap_optional !== undefined && cd.hap_optional == 0) {

src/shelly_switch.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ void ShellySwitch::AddPowerMeter(uint16_t *iid) {
384384
// Power
385385
power_char_ = new mgos::hap::FloatCharacteristic(
386386
(*iid)++, &kHAPCharacteristic_EveConsumption, 0.0f, 65535.0f, 0.1f,
387-
[this](HAPAccessoryServerRef *,
388-
const HAPFloatCharacteristicReadRequest *, float *value) {
387+
[this](HAPAccessoryServerRef *, const HAPFloatCharacteristicReadRequest *,
388+
float *value) {
389389
auto power = out_pm_->GetPowerW();
390390
if (!power.ok()) return kHAPError_Busy;
391391
*value = power.ValueOrDie();
@@ -396,8 +396,8 @@ void ShellySwitch::AddPowerMeter(uint16_t *iid) {
396396
// Energy
397397
total_power_char_ = new mgos::hap::FloatCharacteristic(
398398
(*iid)++, &kHAPCharacteristic_EveTotalConsumption, 0.0f, 65535.0f, 0.1f,
399-
[this](HAPAccessoryServerRef *,
400-
const HAPFloatCharacteristicReadRequest *, float *value) {
399+
[this](HAPAccessoryServerRef *, const HAPFloatCharacteristicReadRequest *,
400+
float *value) {
401401
auto energy = out_pm_->GetEnergyWH();
402402
if (!energy.ok()) return kHAPError_Busy;
403403
*value = energy.ValueOrDie() / 1000.0f;
@@ -414,15 +414,15 @@ void ShellySwitch::PowerMeterTimerCB() {
414414
auto current_power = out_pm_->GetPowerW();
415415
auto current_total_power = out_pm_->GetEnergyWH();
416416

417-
// if (current_power.ok() && current_power.ValueOrDie() != last_power_) {
418-
// last_power_ = current_power.ValueOrDie();
417+
if (current_power.ok() && current_power.ValueOrDie() != last_power_) {
418+
last_power_ = current_power.ValueOrDie();
419419
power_char_->RaiseEvent();
420-
// }
421-
// if (current_total_power.ok() &&
422-
// current_total_power.ValueOrDie() != last_total_power_) {
423-
// last_total_power_ = current_total_power.ValueOrDie();
420+
}
421+
if (current_total_power.ok() &&
422+
current_total_power.ValueOrDie() != last_total_power_) {
423+
last_total_power_ = current_total_power.ValueOrDie();
424424
total_power_char_->RaiseEvent();
425-
// }
425+
}
426426
}
427427

428428
} // namespace shelly

0 commit comments

Comments
 (0)