diff --git a/src/components/PiComponent.vue b/src/components/PiComponent.vue
index 34485c1..12d21d8 100644
--- a/src/components/PiComponent.vue
+++ b/src/components/PiComponent.vue
@@ -144,6 +144,7 @@
+
Available variables
@@ -159,6 +160,25 @@
that represents the absolute rotation value of the dial.
+
+ Dial rotation tick multiplier
+ (x{{ rotationTickMultiplier }})
+
+
+ Each tick of the dial will be multiplied with this value. This results in faster or slower value changes.
+
+
+ Dial rotation tick bucket size
+ ({{ rotationTickBucketSizeMs }} ms)
+
+
+ If greater than zero, ticks are aggregated for the given amount of milliseconds and then passed to your
+ service call. This results in less service calls. A value of zero will result in a service call for each
+ tick, which may cause trouble with home assistant.
+
+
@@ -199,6 +219,9 @@ const serviceLongPress = ref({})
const serviceTap = ref({})
const serviceRotation = ref({})
+const rotationTickMultiplier = ref(1)
+const rotationTickBucketSizeMs = ref(300)
+
const useCustomTitle = ref(false)
const buttonTitle = ref("{{friendly_name}}")
const useStateImagesForOnOffStates = ref(false) // determined by action ID (manifest)
@@ -255,6 +278,8 @@ onMounted(() => {
serviceLongPress.value = settings["button"]["serviceLongPress"]
serviceTap.value = settings["button"]["serviceTap"]
serviceRotation.value = settings["button"]["serviceRotation"]
+ rotationTickMultiplier.value = settings["rotationTickMultiplier"] || 1
+ rotationTickBucketSizeMs.value = settings["rotationTickBucketSizeMs"] || 300
})
}
})
@@ -367,7 +392,10 @@ function saveSettings() {
serviceLongPress: serviceLongPress.value,
serviceTap: serviceTap.value,
serviceRotation: serviceRotation.value
- }
+ },
+
+ rotationTickMultiplier: rotationTickMultiplier.value,
+ rotationTickBucketSizeMs: rotationTickBucketSizeMs.value
}
diff --git a/src/components/PluginComponent.vue b/src/components/PluginComponent.vue
index e7ae11c..de502f6 100644
--- a/src/components/PluginComponent.vue
+++ b/src/components/PluginComponent.vue
@@ -90,9 +90,11 @@ onMounted(() => {
$SD.value.on("dialRotate", (message) => {
let context = message.context;
let settings = actionSettings.value[context];
+ let scaledTicks = message.payload.ticks * (settings.rotationTickMultiplier || 1);
+ let tickBucketSizeMs = settings.rotationTickBucketSizeMs || 300;
- rotationAmount[context] += message.payload.ticks;
- rotationPercent[context] += (message.payload.ticks * 2);
+ rotationAmount[context] += scaledTicks;
+ rotationPercent[context] += scaledTicks;
if (rotationPercent[context] < 0) {
rotationPercent[context] = 0;
} else if (rotationPercent[context] > 100) {
@@ -102,11 +104,21 @@ onMounted(() => {
if (rotationTimeout[context])
return;
- rotationTimeout[context] = setTimeout(() => {
- callService(context, settings.button.serviceRotation, {ticks: rotationAmount[context], rotationPercent: rotationPercent[context], rotationAbsolute: 2.55 * rotationPercent[context]});
+ let serviceCall = () => {
+ callService(context, settings.button.serviceRotation, {
+ ticks: rotationAmount[context],
+ rotationPercent: rotationPercent[context],
+ rotationAbsolute: 2.55 * rotationPercent[context]
+ });
rotationAmount[context] = 0;
rotationTimeout[context] = null;
- }, 300);
+ };
+
+ if (tickBucketSizeMs > 0) {
+ rotationTimeout[context] = setTimeout(serviceCall, tickBucketSizeMs);
+ } else {
+ serviceCall();
+ }
})
diff --git a/src/modules/common/settings.js b/src/modules/common/settings.js
index b45ab4b..9902b67 100644
--- a/src/modules/common/settings.js
+++ b/src/modules/common/settings.js
@@ -101,6 +101,8 @@ export class Settings {
serviceData: "",
}
settingsV4.controllerType = "Keypad"
+ settingsV4.rotationTickMultiplier = 1
+ settingsV4.rotationTickBucketSizeMs = 300
return this.parse(settingsV4)
}