feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Change in Nextion integration to make more efficient use of the ESP-Home flash memory

Open Hellis81 opened this issue 2 years ago • 0 comments

Describe the problem you have/What new integration you would like I would like a change in the Nextion integration. The reason is that many of us can't squeeze enough in the ESP to get what we want from our displays/NS panels. Currently adding "buttons" means you add this kind of code:

binary_sensor:
  - platform: nextion
    name: Light1
    page_id: 2
    component_id: 23
    on_click:
      - homeassistant.service:
          service: light.toggle
          data:
            entity_id: light.light1

I noticed however even without this yaml the Nextion display sends a message to ESP-Home saying:

Got touch page=2 component=23 type=PRESS
Got touch page=2 component=23 type=RELEASE

What if we don't include page and component_id in the yaml and just have a "Nextion sensor" that is exposed to Home Assistant. Perhaps a sensor with state page=2, component=23, type=press then release. That way we can do all the automations in HA instead of loading the ESP full of yaml that is only button clicks.

With the above we would have one sensor that captures any "clicks". What we have today is perhaps 20 sensors just to get the buttons to work.

Another change I would love to see is a sensor with the current page number. The reason is again to get fewer sensors in ESP-Home.

Imaging a sensor saying page0. In Home Assistant we add a template sensor with an array like this:

array = ["page0.component0": "light.light1", "page1.component0": "sun.sun", "page3.component0": "person.someone_geocoded_location"]
{{ states(array[states('sensor.page') ~ "component0"]) }} 

and then we add another with componenet1 for all pages.

So the above sensor will change between several states depending on the page, and I think that can be used to push the correct states to each Nextion field.

Please describe your use case for this integration and alternatives you've tried: I tried using the logger and send that to Home Assistant but I could not get it to work. I posted my test on the community page: https://community.home-assistant.io/t/sonoff-nspanel-smart-scene-wall-switch-by-itead-coming-soon-on-kickstarter/332962/623

Additional context

Whoever does this change will probably be a hero to all NS panel owners who is currently dreading the 68.4% limit.

Hellis81 avatar Apr 07 '22 05:04 Hellis81