ha: only send level change when it changes

pull/3375/head
Rob Pilling 2024-04-21 18:44:23 +01:00
parent 0dc61519a7
commit 10f248ac10
1 changed files with 14 additions and 7 deletions

View File

@ -45,12 +45,7 @@ function draw() {
y2: R.h,
},
});
const onDrag = e => {
slider.f.dragSlider(e);
if(e.b === 0)
ha.sendValue(trigger.trigger, slider.v.level);
};
Bangle.prependListener('drag', onDrag);
Bangle.prependListener('drag', slider.f.dragSlider);
}
const r = slider.c.borderRect;
@ -84,7 +79,19 @@ function draw() {
}
}
function onSlide(mode, feedback) {
var lastLevel;
function onSlide(mode, level, e) {
if (e.b !== 0) {
if (lastLevel == null)
lastLevel = level;
} else {
if (lastLevel != null && lastLevel !== level) {
// we've had a drag and level has changed
ha.sendValue(triggers[position].trigger, level);
lastLevel = null;
}
}
}
function toLeft() {