aderusha / HASwitchPlate

LCD touchscreen for Home Automation
MIT License
732 stars 128 forks source link

Reduce number of MQTT command #4

Closed daemonic79 closed 7 years ago

daemonic79 commented 7 years ago

Hi, As per my screenshots on the HASS forum, i have modified my code to have the 3 page buttons change their action based on what button you are on at the time, ie; by default button 1 goes on to "lights 1/2" button 2 is "home" and button 3 is "other". when button 1 is selected, button 1 then becomes "lights 2/2", and button 3 becomes "dimmers", button 2 stays as "home" when button 2 is pressed the button text and actions revert to default.

I found that due to 33 MQTT commands (200 odd lines of config) every time i changed a "PageButton Page" the panel was a bit sluggish to update and since most of these were updates to pages that werent being displayed, i optimised the code automation to only update the page we are currently looking at. It is now condensed to only 6 MQTT commands.

Since mine is an edge case of changing PageButton Pages on the fly, ill leave it up to you as to if you want to add this patch or not, as it means that the button states are updated every time a page is loaded as apposed to every time a "PageButton Page" is changed, so it will mean multiple groups of 6 MQTT commands as apposed to occasional groups of 33 MQTT commands

aderusha commented 7 years ago

Fantastic work! I was trying to make something like this happen at the time I put this together and just couldn't figure it out. Thanks for the PR!