Skip to content

Commit

Permalink
Fix power status (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekateluv authored Jan 24, 2025
1 parent 84b279b commit 721ae93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
wb-rules-system (1.12.4) stable; urgency=medium

* Fix power status updating at startup

-- Ekaterina Volkova <ekaterina.volkova@wirenboard.com> Tue, 21 Jan 2025 15:28:57 +0300

wb-rules-system (1.12.3) stable; urgency=medium

* Update maintainer. No functional changes
Expand Down
23 changes: 16 additions & 7 deletions rules/power_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ defineVirtualDevice('power_status', {
},
});

function updateData(){
if (dev['power_status']['working on battery']) {
dev['power_status']['Vin'] = 0;
} else {
dev['power_status']['Vin'] = dev['wb-adc']['Vin'];
}
}

defineRule('_system_track_vin', {
whenChanged: ['wb-adc/Vin', 'power_status/working on battery'],
then: function () {
if (dev['power_status']['working on battery']) {
dev['power_status']['Vin'] = 0;
} else {
dev['power_status']['Vin'] = dev['wb-adc']['Vin'];
}
then: updateData,
});

defineRule({
asSoonAs: function() {
return dev['wb-adc']['Vin'] !== null;
},
then: updateData,
});

/* Power status reporting for Wiren Board 5.x is based on
Expand Down Expand Up @@ -60,4 +69,4 @@ spawn(
}
},
}
);
);

0 comments on commit 721ae93

Please sign in to comment.