Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Home Assistant API instead of MQTT #34

Closed
wants to merge 8 commits into from

Conversation

afarago
Copy link

@afarago afarago commented Dec 1, 2023

Based on the already merged PR to joBr99/nspanel-lovelace-ui#1007 I would love to see the use of HA API.
It results in smoother and faster communication through HA events and HA services.

esphome needs small config change, optional new/renamed triggers

nspanel_lovelace:
  use_api: True
  on_message_from_nextion:
    - lambda: |-
        ESP_LOGD("main", "message from nextion: %s", x.c_str());
  on_message_to_nextion:
    - lambda: |-
        ESP_LOGD("main", "message to nextion: %s", x.c_str());

nspanel.cpp automatically adds necessary HA service that the appdaemon backend can call (customrecv, updatetft, gerversion)

======

Afterwards HA ESP device needs explicit permission to use service calls.
image

@sairon
Copy link
Owner

sairon commented Dec 2, 2023

Thanks for the PR! It will unfortunately conflict with changes from #33, so either we can hold it off until that one is merged, or you can rebase it to use that PR's branch as base, so we can move on faster once it's merged (as I'd like to merge that one first, sunce it doesn't introduce any breaking changes like this one).

Also note that the new add-on that @joBr99 is currently working on and is supposed to replace the AppDaemon backend doesn't implement the API support yet, so it's something that should be looked into as well.

@joBr99
Copy link

joBr99 commented Dec 2, 2023

Implemented support for the API yesterday evening :)

@twasilczyk
Copy link

Is this still supposed to work? I did the following:

  • made changes co ESP code
    • switched external_components to this PR
    • added use_api: True to nspanel_lovelace
    • commented out mqtt
  • made changes to apps.yaml
    • use_api: True
    • panelName: "Media room panel" (tried values from esphome.name, esphome.friendly_name, nspanel_lovelace.id)
    • panelDeviceId: "<32-character long hex id from device page URL>"
    • commented out panelRecvTopic and panelSendTopic
  • checked "Allow the device to make Home Assistant service calls."
  • tried power cycling the screen and restarting appdaemon

But I'm still seeing "Waiting for content". ESPHome boots up and I see the logs (also the one about successful connection - see below). Switching use_api to False and restoring commented out mqtt lines makes it work again.

[21:39:11][D][api:102]: Accepted 192.168.1.2
[21:39:12][D][api.connection:1121]: Home Assistant 2024.1.5 (192.168.1.2): Connected successfully

Copy link
Owner

@sairon sairon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging #33 introduced some conflicts. @afarago are you still willing to pursue this? If so, there are more things I'd like to point out.

@afarago
Copy link
Author

afarago commented Aug 9, 2024

Apologies, I will not be able to take this further. Let me know if I should close the PR for simplicity or sy would like to take this over.

@sairon sairon closed this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants