Rotary encoder plugin - set the internal value
Moderators: grovkillen, Stuntteam, TD-er
Rotary encoder plugin - set the internal value
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?
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?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rotary encoder plugin - set the internal value
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
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rotary encoder plugin - set the internal value
thanks for your reply.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
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?
- budman1758
- Normal user
- Posts: 301
- Joined: 15 Apr 2017, 05:13
- Location: Riverside CA USA
Re: Rotary encoder plugin - set the internal value
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.
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".
Re: Rotary encoder plugin - set the internal value
Maybe he is trying to do something like me! viewtopic.php?f=6&t=3893&p=25985#p25985budman1758 wrote: ↑14 Mar 2018, 23:20 First off... Why are you trying to manually override the rotary encoder?
Re: Rotary encoder plugin - set the internal value
Hi,Osmi wrote: ↑15 Mar 2018, 04:15Maybe he is trying to do something like me! viewtopic.php?f=6&t=3893&p=25985#p25985budman1758 wrote: ↑14 Mar 2018, 23:20 First off... Why are you trying to manually override the rotary encoder?
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?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rotary encoder plugin - set the internal value
No, it will start from zero each time you start rotating.
But why not use a dummy device to store values?
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rotary encoder plugin - set the internal value
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?
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rotary encoder plugin - set the internal value
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Rotary encoder plugin - set the internal value
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
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
Re: Rotary encoder plugin - set the internal value
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
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
Re: Rotary encoder plugin - set the internal value
A few minor remarks:hansi9990 wrote: ↑20 Mar 2022, 17:50Code: Select all
Nextion_Display,page2.t5.txt="%eventvalue%" Nextion_Display,page2.h0.val=[rotary#count]
- 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)
Who is online
Users browsing this forum: Ahrefs [Bot] and 1 guest