Real time rotary encoder mqtt publish!

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Osmi
New user
Posts: 4
Joined: 20 Dec 2017, 02:36

Real time rotary encoder mqtt publish!

#1 Post by Osmi » 20 Dec 2017, 04:07

Hello everybody!
I have Wemos D1 with latest test build connected to rotary encoder. I am controlling my receiver volume trough OpenHab mqtt binding. It is working well.
I have two questions:
1. Is it possible to set Espeasy to publish encoder status in real time(fast)?
2. Can I set Espeasy not to publish initial 0 state of encoder on boot, and set it to receive volume topic(in case of IR remote)?

Lets say that after boot, Wemos subscribe to a volume topic, then receive volume status from broker(retained flag), then update the rotary value(from 0 to a new value).

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

Re: Real time rotary encoder mqtt publish!

#2 Post by grovkillen » 20 Dec 2017, 06:12

Yes you can do both using rules. Please study the wiki and get back here if you need further assistance.
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:

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

Re: Real time rotary encoder mqtt publish!

#3 Post by Osmi » 15 Mar 2018, 03:37

OK!
I am not very good at programing. let me start with, do not publish initial state 0 with mqtt...

On System#Boot
if volume#set=0
"do not publish 0"/dont know what to put here
endon

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

Re: Real time rotary encoder mqtt publish!

#4 Post by leel1967l » 15 Mar 2018, 09:49

Osmi wrote: 15 Mar 2018, 03:37 OK!
I am not very good at programing. let me start with, do not publish initial state 0 with mqtt...

On System#Boot
if volume#set=0
"do not publish 0"/dont know what to put here
endon
Hi,
how did you solve this problem?
I haven't been able to set the initial value of a rotary encoder.

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

Re: Real time rotary encoder mqtt publish!

#5 Post by grovkillen » 15 Mar 2018, 09:55

I think you should store the value using a dummy device and only let the rotary encoder do the addition / subtraction from that value.
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:

gtgt
New user
Posts: 1
Joined: 14 Sep 2019, 01:31

Re: Real time rotary encoder mqtt publish!

#6 Post by gtgt » 14 Sep 2019, 03:04

Dummy device may not be a solution, if he wants to allow set volume to 0, but later...

To not set 0 value, it's easier to not send the device value automatically (uncheck "Send to controller" at device edit) and create a rule to publish (but with condition):

Code: Select all

on volume#set>0 do
  Publish %sysname%/volume/set,[volume#set]
endon
However it will not solve much, because when you rotate, then the volume will send value from 1, even the volume on the other side is higher.
You have to receive value from the topic, not just send. To do this, you need MQTT Import device. Name it to "import" for example, set topic and value to "volume", then rewrite the rules:

Code: Select all

on import#volume do
  // assuming the first device/task is the rotary encoder
  TaskValueSet 1,1,[import#volume]
emdon

on volume#set do
  Publish %sysname%/import/volume,[volume#set]
  // assuming the second device/task is the MQTT import. This update may not be necessary, since the value will "come back" via mqtt anyway.
  TaskValueSet 2,1,[volume#set]
endon
You will need modify the topic on the other side from volume/set -> import/volume.

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

Re: Real time rotary encoder mqtt publish!

#7 Post by Osmi » 03 Jan 2024, 10:32

Hello. Thanks to the encwrite function and everyone who contributed to this, I managed to program it. Happy New Year 2024 to everyone.

Code: Select all

on mqtt#volume do
    encwrite,[mqtt#volume]
endon

on volume#value do
    Publish %sysname%/volume,[volume#value]
    TaskValueSet 4,1,[volume#value]
endon

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 28 guests