# Control Knob suitable for Volume control or similar

**URL:** <https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464>\
**Category:** General\
**Created:** [20 October 2021 13:37 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464 "2021-10-20T13:37:32Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [23 October 2021 18:56 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/41 "2021-10-23T18:56:34Z")

</div>

The output and the reaction on input will come later. That is all about the coding youäll need to do to make the knob an actual interactive element inside the ui\_template. step by step ..

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [23 October 2021 18:59 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/42 "2021-10-23T18:59:15Z")

</div>

Thanks stax for the help... I REALLY appreciate it!!

Consider a beer bought and emailed to you!!

I have a starting point now... At least from here I (might) be able to formulate the right questions!!

E

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [23 October 2021 19:01 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/43 "2021-10-23T19:01:50Z")

</div>

An e-mailed beer 🙂 I hope it will be lager and not over 5.5 vol. And the delivery not later than 15 minutes from now and please - chilled 😃 🍻

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [23 October 2021 19:06 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/44 "2021-10-23T19:06:05Z")

</div>

... ... ... Time delay initiated ... ... ... ...

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [23 October 2021 19:06 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/45 "2021-10-23T19:06:47Z")

</div>

Lager lite sent...

Ice cube Appended!

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [23 October 2021 19:30 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/46 "2021-10-23T19:30:21Z")

</div>

Ill respond if you have any news about the main topic even today if I'm still online or tomorrow with arbitrary delays due the limited computer-time for Sundays.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [23 October 2021 19:36 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/47 "2021-10-23T19:36:38Z")

</div>

I'm sort of starting to understand how this works... Enough to parrot it... I have managed to change size etc and get it deployed as a visual switch only... I have been reading up on the site as to "adding the values" for the output... tried them, no errors, but also no debug output from the node either.... Parroted this:

```auto
<input type="range" class="input-knob" min="-10" max="10" step="0.1"
   oninput="inputEventHandler(this)" onchange="changeEventHandler(this)"/>

```

I'm gonna keep going as late as I can tonight, while this is fresh in my mind...our utility power is off tomorrow and we had a cloudy day today... solar batteries are tired!!

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [23 October 2021 19:45 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/48 "2021-10-23T19:45:20Z")

</div>

Lets walk through about the creation of ui widget with `ui_template` tomorrow or some next day with all necessary explanations about why and how, So we leave behind the guide for any other, willing to learn how to achieve.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [23 October 2021 19:46 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/49 "2021-10-23T19:46:51Z")

</div>

Sure thing.... I'm going to plod on for a couple of hours to try and get an output from it... Thanks heaps again for the help!!

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [23 October 2021 19:50 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/50 "2021-10-23T19:50:29Z")

</div>

Doing so, do not go in blind.

See the help section of the ui\_template node about the interactivity and the uniqueness.  
It is mandatory to do it that way.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad27ef75d37feecdfd788e90f48f0b7b57a99e9d.png)

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [23 October 2021 19:52 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/51 "2021-10-23T19:52:48Z")

</div>

Thank you.... Didn't even think of looking at the help....Duhhh....

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [24 October 2021 11:47 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/52 "2021-10-24T11:47:33Z")

</div>

Hey @hotNipi ,

Spent a good few hours puzzling over the help examples and trying to see if I could adapt them to the .js for the knobs... Not much progress I'm sorry to say, but I did pick up a bit more understanding on the way...

What I have picked up is that from:

> [@hotNipi](#):
>
> See the help section of the ui\_template node about the interactivity and the uniqueness.  
> It is mandatory to do it that way.

is that we have to ?assign? a new and unique id for each instance of the calling template that is deployed, particularly in this case, where there will be multiple "similar" occurrences ... Not doing so would have possibly ?variables? etc overwritten on one instance when another is accessed... The actual code to do it is the bit that says: `<div id="{{'my_'+$id}}"`

I see a reference to this in the line that says ` "#my_"+scope.$id` ... That being said, while I understand its purpose, I don't follow the structure of it... But that will come..(hopefully)...

The script in the help concerning sending a message on a button click:

```auto
var value = "hello world";
// or overwrite value in your callback function ...
this.scope.action = function() { return value; }
</script>
<md-button ng-click="send({payload:action()})">
    Click me to send a hello world
</md-button>

```

is pretty straight forward and I can certainly get to grips with it... As to actually generating this script without a cheat-sheet later, I doubt whether I will be able to, but at least I grasp the concept and method involved (and might remember where to parrot it from...LOL)...

As to how to author the "calling template" to have access to the information generated by the .js script and send it to the outside .... Dark magic!! (But immensely interested in getting to grips with it!)

Regds  
Ed

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [24 October 2021 17:02 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/53 "2021-10-24T17:02:24Z")

</div>

Have you visited the gallery and downloaded image stripe of your favoriite knob?  
[https://www.g200kg.com/en/webknobman/gallery.php](https://www.g200kg.com/en/webknobman/gallery.php)

Or you want to go with standard knob which does not need any additional things.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [24 October 2021 17:16 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/54 "2021-10-24T17:16:44Z")

</div>

Hiya H!!

Yep - got the image stripe, got it scaled and the right number of sprites set, it's twisting and turning, looking like a real one!! (A bit small, but this I can sort out later...)

Also managed to get the toggle switch in and looking good too!!

E

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [24 October 2021 17:24 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/55 "2021-10-24T17:24:03Z")

</div>

OK.  
Now as the ui\_template has some CSS rules by default, we need to do some tweaks and also we need a container to adjust the position of knob.

```auto
<div ng-init="init()" class="knobwrapper">
    <input id="{{'knob_'+$id}}" type="range" ng-model="knobvalue" class="input-knob" data-diameter="100" data-src="/images/led-knob-30fr.png" data-sprites="30"/>
</div>

```

We most probably have different images and different sprite count and size but all other things should be arranged like this.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [24 October 2021 17:29 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/56 "2021-10-24T17:29:11Z")

</div>

Done! - I now see a blue lined frame around it when selected...

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [24 October 2021 17:48 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/57 "2021-10-24T17:48:49Z")

</div>

Yes, lets's fix it.  
In the JavaScript file, find this

```auto
  input[type=range].input-knob{
    width:${op.knobWidth}px; height:${op.knobHeight}px;
  }

```

For this rule add declaration:  
`outline:none;`

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [24 October 2021 18:10 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/58 "2021-10-24T18:10:29Z")

</div>

Now as the created wrapper declares that the class "knobwrapper" is required `<div ng-init="init()" class="knobwrapper">`  
The rule looks like this.

```auto

    .knobwrapper{
        width:100%;
        height:100%;
        display:flex;
        justify-content: center;
        align-items: center;
    }

```

It is good practice to have common CSS in one ui\_template so if you have one already, add this rule in that. If not, I'd suggest to create one.

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [24 October 2021 18:20 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/59 "2021-10-24T18:20:59Z")

</div>

Done - I now see a blue lined frame around it...

This is the content as I have it now:

```auto
<div ng-init="init()" class="knobwrapper">
    
<input type="range" 
    class="input-knob" 
    data-diameter = "24" 
    min="0" 
    max="255" 
    step="1" 
    data-src = "/png/knob70.png" 
    data-sprites = "100"
    oninput="inputEventHandler(this)" 
    onchange="changeEventHandler(this)"
/>
</div>

```

(My Internet connection is really crappy at the mo - the power outages are taking their toll by the looks of it) Apologies if I duplicate post in error...

---

<div class="post-metadata">

**Author:** ![eddee54455](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/eddee54455/32/43350_2.png) [@eddee54455](https://discourse.nodered.org/u/eddee54455)\
**Post date:** [24 October 2021 18:25 UTC](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464/60 "2021-10-24T18:25:14Z")

</div>

> [@hotNipi](#):
>
> Yes, lets's fix it.  
> In the JavaScript file, find this

Done... Outline gone!

[Previous page](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464.md?page=2)

[Next page](https://discourse.nodered.org/t/control-knob-suitable-for-volume-control-or-similar/52464.md?page=4)
