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).
Real time rotary encoder mqtt publish!
Moderators: grovkillen, Stuntteam, TD-er
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Real time rotary encoder mqtt publish!
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
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: Real time rotary encoder mqtt publish!
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
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
Re: Real time rotary encoder mqtt publish!
Hi,
how did you solve this problem?
I haven't been able to set the initial value of a rotary encoder.
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Real time rotary encoder mqtt publish!
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
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: Real time rotary encoder mqtt publish!
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):
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:
You will need modify the topic on the other side from volume/set -> import/volume.
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
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
Re: Real time rotary encoder mqtt publish!
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
Who is online
Users browsing this forum: No registered users and 2 guests