marcfager / nspanel-mf

Custom HMI controlled by ESPHome for the Sonoff NSPanel. Includes media player card and home screen with weather data and clock. More to come.
215 stars 60 forks source link

How to support toggling input_booleans as light switches #15

Closed bbostock closed 2 years ago

bbostock commented 2 years ago

I love this implementation, but when I tried to convert a 2nd page of light switches to handle my heating zones defined as input_booleans the panel would no longer boot.

After re-flashing a working binary using my serial adapter I managed to recover the panel.

Is there a recommended way I could support virtual switches using my input_booleans or sensor templates or by some other means?

Hellis81 commented 2 years ago

I suppose that is where you set up the entities:

  - platform: nextion
    name: $device_name Light 1 button
    page_id: 2
    component_id: 18
    on_click:
      - homeassistant.service:
          service: light.toggle # this probably needs to be changed to input_boolean.toggle
          data:
            entity_id: light.sonoff_1000cb7905 # and here

But how did you "enable" the second screen?

marcfager commented 2 years ago

The ESP seems to be rather overwhelmed by all entities that are added. A serious improvement would be to re-design the setup with a HA blueprint. The blueprint would then push values on change (such as a light state changing) to the ESP instead of the ESP subscribing to HA events. Especially the text entities seem to be resource consuming. The current setup is not ideal, as items such as light labels tend to be rather static and better changed through HA.

The above setup also has the benefit that all config could be done from HA. I.e. the ESPHome part would be rather set-and-forget.

marcfager commented 2 years ago

To enable a second light screen, change the number in the very end of the ESPHome code:

    # Enable 1 light page (up to 4 available)
    - lambda: id(disp1).send_command_printf("Lights.pages.val=1");