diff --git a/src/components/PiComponent.vue b/src/components/PiComponent.vue index 01d878f..34485c1 100644 --- a/src/components/PiComponent.vue +++ b/src/components/PiComponent.vue @@ -148,7 +148,15 @@ Available variables
{{ ticks }} - The number of ticks the dial was - rotated + rotated (negative value for left turn, positive value for right turn). +
+
+ {{ rotationPercent }} - A number between 0 and 100 + that represents the rotation percentage value of the dial. +
+
+ {{ rotationAbsolute }} - A number between 0 and 255 + that represents the absolute rotation value of the dial.
diff --git a/src/components/PluginComponent.vue b/src/components/PluginComponent.vue index 3f6fc6f..e7ae11c 100644 --- a/src/components/PluginComponent.vue +++ b/src/components/PluginComponent.vue @@ -24,6 +24,7 @@ const buttonLongpressTimeouts = ref(new Map()) //context, timeout let rotationTimeout = []; let rotationAmount = []; +let rotationPercent = []; onMounted(() => { window.connectElgatoStreamDeckSocket = (inPort, inPluginUUID, inRegisterEvent, inInfo) => { @@ -74,6 +75,7 @@ onMounted(() => { $SD.value.on("willAppear", (message) => { let context = message.context; rotationAmount[context] = 0; + rotationPercent[context] = 0; actionSettings.value[context] = Settings.parse(message.payload.settings) if ($HA.value) { $HA.value.getStates(entitiyStatesChanged) @@ -90,12 +92,18 @@ onMounted(() => { let settings = actionSettings.value[context]; rotationAmount[context] += message.payload.ticks; + rotationPercent[context] += (message.payload.ticks * 2); + if (rotationPercent[context] < 0) { + rotationPercent[context] = 0; + } else if (rotationPercent[context] > 100) { + rotationPercent[context] = 100; + } if (rotationTimeout[context]) return; rotationTimeout[context] = setTimeout(() => { - callService(context, settings.button.serviceRotation, {ticks: rotationAmount[context]}); + callService(context, settings.button.serviceRotation, {ticks: rotationAmount[context], rotationPercent: rotationPercent[context], rotationAbsolute: 2.55 * rotationPercent[context]}); rotationAmount[context] = 0; rotationTimeout[context] = null; }, 300); diff --git a/src/components/ServiceCallConfiguration.vue b/src/components/ServiceCallConfiguration.vue index a81c2aa..9fde751 100644 --- a/src/components/ServiceCallConfiguration.vue +++ b/src/components/ServiceCallConfiguration.vue @@ -173,7 +173,7 @@ const serviceDataInvalidFeedback = computed(() => { return ""; } try { - const renderedServiceData = nunjucks.renderString(serviceDataString, {ticks: 5}); + const renderedServiceData = nunjucks.renderString(serviceDataString, {ticks: 5, rotationPercent: 100, rotationAbsolute: 100}); const json = JSON.parse(renderedServiceData); return (typeof json === "object") ? "" : "Service data must be an JSON object."