sairon / esphome-nspanel-lovelace-ui

ESPHome component for NSPanel Lovelace UI
Other
125 stars 31 forks source link

Use Physical Buttons for custom actions #12

Closed sascha005 closed 1 year ago

sascha005 commented 1 year ago

Hi, is there a way to use the Physical Button to show a specific Card on NSPanel ? And use the second physical Button to fire an homeassistant Automation ? I cannot feagure out how this works exactly.

Cheers Sascha

randybb commented 1 year ago

I am using this - basically once I press a button it will popup the right page where I can do some more controls, like dimm this light,...

esp config

binary_sensor:
  - platform: gpio
    name: ${name} Left Button
    pin:
      number: 14
      inverted: true
    on_click:
      - homeassistant.service:
          service: light.toggle
          data:
            entity_id: light.office_r_desk_strip
      - mqtt.publish_json:
          topic: $panel_recv_topic
          payload: |-
            root["CustomRecv"] = "event,buttonPress2,navigate.cardGrid_lights,button";

and then to related card just add key::

    cards:
      - type: cardGrid
        title: Lights
        key: lights
        entities: ...
sascha005 commented 1 year ago

Hi, thank you !

Yes, with the MQTT Command it works. With the Lamda Command it does not. Where do you get the Information about the Command : „event,buttonPress2,navigate.cardGrid_lights,button" ? I didn’t find this Information on the net…

Cheers Sascha

Gesendet von Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 für Windows

Von: Roman @.> Gesendet: Dienstag, 27. September 2022 16:24 An: @.> Cc: @.>; @.> Betreff: Re: [sairon/esphome-nspanel-lovelace-ui] Use Physical Buttons for custom actions (Issue #12)

I am using this - basically once I press a button it will popup the right page where I can do some more controls, like dimm this light,...

esp config

binary_sensor:

I am doing it through mqtt (no idea why), but you can send that command directly like this:

    - lambda: 'id(nspanel_id).send_custom_command("event,buttonPress2,navigate.cardGrid_lights,button");'

and then to related card just add key::

cards:

  - type: cardGrid

    title: Lights

    key: lights

    entities: ...

— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsairon%2Fesphome-nspanel-lovelace-ui%2Fissues%2F12%23issuecomment-1259586552&data=05%7C01%7C%7Caee2c18f112f4582008508daa0940040%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637998854765056152%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wZHfB08qjpgHEY3HjU8v8EVwD6CFBS5Lk1nts2AA9XU%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FALN2HEFRZTTBERYU5RXRTPLWAL7SDANCNFSM6AAAAAAQW2GJBA&data=05%7C01%7C%7Caee2c18f112f4582008508daa0940040%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637998854765056152%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=FZmv7m2DJHc68lN2BjNrjcaW6VS4rehe9E%2BNlJvYn6I%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

randybb commented 1 year ago

It is based on the example config https://github.com/sairon/esphome-nspanel-lovelace-ui/blob/dev/example-nspanel-config.yml "Service to navigate to screen". And yes, I thought that calling command directly will work, then I tested it and needed to remove it from my comment because it doesn't.

sairon commented 1 year ago

I believe this can be closed, as it's been already answered. I'll just explain why this lambda doesn't work as expected:

- lambda: 'id(nspanel_id).send_custom_command("event,buttonPress2,navigate.cardGrid_lights,button");'

The event,buttonPress2 is in fact event that is passed from the panel to MQTT, which is then handled by the AppDaemon which sends the content to be shown on the panel. So to trigger showing a specific page on the panel, you have to notify AppDaemon, that means sending an MQTT message simulating screen touch event is the correct way to do so.