I have an mqtt sensor. It shows what my pcb with an esp8266 on it publishes to a state_totpic. On my pcb is a rotary encoder. This encoder decrements or increments the current value with 1. So if the knob is turned right it increments (current value + 1), if its turned left it decrements (current value -1). This works perfectly. Home assistant shows the value.
What I did not figure out is: how can I check if the knob is turned right or left? In other words how can I compare the actual data of my sensor with the value that is stored right before?
If the current value is 2 and the one before is 1 then I know the knob is turned right. If the current value is 2 and the one before is 3 I know the knob is turned left.
I know how to compare the data but I don’t know where this data is! I’m completely lost at the moment…
Thank’s for your valued support and time!
Cheers