Rotary encoder plugin - set the internal value

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Rotary encoder plugin - set the internal value

#1 Post by leel1967l » 14 Mar 2018, 21:59

Hi all,
i am trying to set value of the rotary encoder.

I have created a task "Switch -Rotary Encoder" witn name=rotary and value=counter.
In the rules I want to set the value of the task, so I write: taskvalueset,1,1,[mqtt#set]
and the value in the devices page changes to [mqtt#set].

But when I rotate the encoder switch, the value is set to 0 or to the orginal value it was set last time I moved the switch.

In other words, it seems that using taskvalueset,1,1,[mqtt#set] it just set the external value of the task but does not change the internal value of the task.

Is there any way to set the internal value of the rotary encoder?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rotary encoder plugin - set the internal value

#2 Post by grovkillen » 14 Mar 2018, 22:03

You can set it to remember the current value or start from zero. Look in the device setting. Third GPIO.

https://www.letscontrolit.com/wiki/inde ... ry_Encoder
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Re: Rotary encoder plugin - set the internal value

#3 Post by leel1967l » 14 Mar 2018, 22:18

grovkillen wrote: 14 Mar 2018, 22:03 You can set it to remember the current value or start from zero. Look in the device setting. Third GPIO.

https://www.letscontrolit.com/wiki/inde ... ry_Encoder
thanks for your reply.
But I think haven't been clear enough.

Let me explain better:
if I use the rotary encoder the internal value (counter) changes during the rotation of the switch.
And the value is shown in the devices page in the appropriate task.

But I want to set MANUALLY the value of the encoder to a certain value. And if I do so (using taskvalueset) the new value is displayed in the devices page but as soon as I rotate the switch the value restarts from the previuos value.

Example:
Initial value = 0
I rotate the switch to a value of 10.
then I set taskvalueset,1,1,30 (setting the task value to 30).
BUT as soon as I rotate again the switch it restart counting from 10

How can I force to set the value of the switch (not of the task) to a certain value?

User avatar
budman1758
Normal user
Posts: 301
Joined: 15 Apr 2017, 05:13
Location: Riverside CA USA

Re: Rotary encoder plugin - set the internal value

#4 Post by budman1758 » 14 Mar 2018, 23:20

First off... Why are you trying to manually override the rotary encoder?

It sounds like you are trying to do the impossible. How can software change something mechanical?
You may be able to fool the software into thinking the switch has changed but the mechanical switch has not been fooled.
If the rotary encoder has a certain amount of "tics" per revolution then the next movement will start from wherever it is now.
Only thing you can do is tell the software that "x" is now the new "0".

Having said that tho I think your only option is what @grovkillen said about the 3rd GPIO setting. Sounds to me like it will do what you are trying to do.
"The glass is twice as big as it needs to be".

Osmi
New user
Posts: 4
Joined: 20 Dec 2017, 02:36

Re: Rotary encoder plugin - set the internal value

#5 Post by Osmi » 15 Mar 2018, 04:15

budman1758 wrote: 14 Mar 2018, 23:20 First off... Why are you trying to manually override the rotary encoder?
Maybe he is trying to do something like me! viewtopic.php?f=6&t=3893&p=25985#p25985

leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Re: Rotary encoder plugin - set the internal value

#6 Post by leel1967l » 15 Mar 2018, 09:42

Osmi wrote: 15 Mar 2018, 04:15
budman1758 wrote: 14 Mar 2018, 23:20 First off... Why are you trying to manually override the rotary encoder?
Maybe he is trying to do something like me! viewtopic.php?f=6&t=3893&p=25985#p25985
Hi,
That's more or less what I am trying to do...

In particular, I need to:
In a thermostat, when I turn the knob, the Setpoint changes on a LCD display. If I press the knob, the new setpoint is set. If I don't press the knob (after 5 seconds) the setpoint returns to the previuos value, so I need to store in the encoder the previous value.

One thing that I don't understand: 3rd GPIO: my understandng is that if you turn the knob with the GPIO pressed, the encoder will go into a loop and restart from 0 after reaching the max value. Am I wrong?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rotary encoder plugin - set the internal value

#7 Post by grovkillen » 15 Mar 2018, 09:47

No, it will start from zero each time you start rotating.

But why not use a dummy device to store values?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

leel1967l
Normal user
Posts: 73
Joined: 30 Nov 2017, 18:29

Re: Rotary encoder plugin - set the internal value

#8 Post by leel1967l » 15 Mar 2018, 10:03

grovkillen wrote: 15 Mar 2018, 09:47 But why not use a dummy device to store values?
It could be done, but will increase rule complexity also because the setpoint could be set from outside (from MQTT openhab).
So the rule to display the setpoint changes in realtime could slow down.

Anyway, there should be a way to override the internal value of the encoder, as the plugin does it to limit the min, max values and to reset to 0 using 3rd GPIO.
So it's just a matter of exporting this function from the plugin.

Any other idea, or shall I open a request on github?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Rotary encoder plugin - set the internal value

#9 Post by grovkillen » 15 Mar 2018, 12:17

Yes open a request/issue on GitHub. Thanks.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

masgar
New user
Posts: 1
Joined: 19 Oct 2018, 10:55

Re: Rotary encoder plugin - set the internal value

#10 Post by masgar » 29 Oct 2018, 16:31

Hi,

I have same issue. I can set the PWM value using a rotary encoder, i.e to 300. I can change pwm value using a MQTT publish from my application (HA, iOS home app, Alexa, whatever) i.e. to 1000. PWM changes fine but if I move the encoder the PWM go to 300 and increase/decrease depending on the direction I move the encoder.
I would need to change encoder value when I change PWM using MQTT.

@LEEL1967L have found a solution?

Thanks,
Max

hansi9990
New user
Posts: 7
Joined: 10 Mar 2022, 13:59

Re: Rotary encoder plugin - set the internal value

#11 Post by hansi9990 » 20 Mar 2022, 17:50

This question is a bit old, but I'll answer it anyway ;)
The answer to this question is the "encwrite,xx" command, e.g. in my my case it was this commando:

on Nextion_Display#idx=602 do
encwrite,[Nextion_Display#value]
Let,2,[Nextion_Display#value]*10
pwm,0,[VAR#2],0,10000
endon

This way the value of the rotary encoder is set to the value of the slider on my display.

And this was the reverse way in my case:

on rotary#count do
Nextion_Display,page2.t5.txt="%eventvalue%"
Nextion_Display,page2.h0.val=[rotary#count]
Let,1,[rotary#count]*10
pwm,0,[VAR#1],0,10000
endon

User avatar
Ath
Normal user
Posts: 3488
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Rotary encoder plugin - set the internal value

#12 Post by Ath » 20 Mar 2022, 18:04

hansi9990 wrote: 20 Mar 2022, 17:50

Code: Select all

Nextion_Display,page2.t5.txt="%eventvalue%"
Nextion_Display,page2.h0.val=[rotary#count]
A few minor remarks:
- These 2 lines should both use %eventvalue% to ensure they both use the same value (during processing of the rules, the value could have been updated already, the next update will be queued for processing)
- When you add a set of [ code ] [ /code ] tags (i've added some spaces to show them in this post, you can select them from the </> button in the form-editor toolbar) your rules are much better readable :)
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 38 guests