node-red-contrib-home-assistant-llat icon indicating copy to clipboard operation
node-red-contrib-home-assistant-llat copied to clipboard

Take into account httpRoot.

Open kevinduong opened this issue 6 years ago • 14 comments

The NodeRed contrib plugin doesn't take into account httpRoot. This breaks routing if you're trying to view some of the endpoints.

Steps to reproduce the behavior:

  1. Configure httpRoot in NodeRed settings.js
  2. Try to enter in an entity in NodeRed
  3. You'll get a 404.

Expected behavior Shouldn't receive a 404.

  • Node Red Version: Latest
  • NR Home Assistant Plugin Version: Latest
  • Is Node Red running in Docker: Yes

Other (please complete the following information): https://github.com/AYapejian/node-red-contrib-home-assistant/issues/86

kevinduong avatar Jul 26 '18 14:07 kevinduong

Thanks - following!

schford avatar Jul 26 '18 14:07 schford

What does the httpRoot function do? I'll try to look into this this afternoon

Spartan-II-117 avatar Jul 26 '18 16:07 Spartan-II-117

I don't think it's a function, it's a variable that gets stored in nodered's settings.js. This is an issue for users that have custom routing (ex: nginx reverse proxy). The plugin doesn't handle these routes correctly.

The URLs would also need to be updated in the .html files. The httpRoot setting should be taken into account here.

Example: If you look in server-events-state-changed.html: Line47: $.get('/homeassistant/entities').done((entities)

Maybe the httpRoot setting needs to be concatenated to that?

kevinduong avatar Jul 26 '18 16:07 kevinduong

This may be a bug in AYapejian/node-home-assistant. I'll look into it further

Spartan-II-117 avatar Jul 26 '18 17:07 Spartan-II-117

Going off the .html stuff I mentioned in my previous comment, a good temporary workaround is to go through all of the .html files under each folder under the nodes directory and add your directory to the URL.

So I basically just did a CTRL + F on "homeassistant" and concatenated my route to the URL it's trying to get.

Restart nodered, then you'll see your entity IDs populating.

Let me know if you'd like any help or a test environment. I could probably throw one up.

kevinduong avatar Jul 26 '18 19:07 kevinduong

Here's another workaround for those using an nginx reverse proxy like I am

https://github.com/AYapejian/node-red-contrib-home-assistant/issues/41

kevinduong avatar Jul 26 '18 19:07 kevinduong

I think i understand it, I'll check if i can just add a variable to the beginning, I just need to figure out how to access it properly.

Spartan-II-117 avatar Jul 26 '18 20:07 Spartan-II-117

https://github.com/AYapejian/node-red-contrib-home-assistant/issues/76#issuecomment-408111524 This comment has more details about the issue.

fanthos avatar Sep 20 '18 09:09 fanthos

@kevinduong is there a variable (I presume httproot) that could/should be aded to the beginning of the html strings? if so could you submit a PR with an example?

Spartan-II-117 avatar Sep 20 '18 15:09 Spartan-II-117

I have a fix for this on my WebSocket fork feel free to cherry-pick it if you would like.

These are the two commits: https://github.com/zachowj/node-red-contrib-home-assistant-websocket/commit/04ad3984b326ea239de26eb4ffa8a168ad5b8d02 https://github.com/zachowj/node-red-contrib-home-assistant-websocket/commit/cf2a4ad5df8772a0fb508debe946ce39bccd9141

There is also fixes for #26, #34 and #36 but they're probably not as easily cherry-picked.

zachowj avatar Oct 07 '18 01:10 zachowj

Has this arrived in an actual release? I am currently postponing all my HA-nodered stuff until this is fixed.

simonszu avatar Oct 17 '18 21:10 simonszu

I think it's fixed in this fork

https://github.com/zachowj/node-red-contrib-home-assistant-websocket

On Wed, Oct 17, 2018, 4:06 PM Simon Szustkowski [email protected] wrote:

Has this arrived in an actual release? I am currently postponing all my HA-nodered stuff until this is fixed.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Spartan-II-117/node-red-contrib-home-assistant-llat/issues/25#issuecomment-430789080, or mute the thread https://github.com/notifications/unsubscribe-auth/ACqSwM-RqpuG1vP6NqlIUok2vIN_uNnvks5ul5vQgaJpZM4Vh53p .

kevinduong avatar Oct 17 '18 21:10 kevinduong

I pushed the changes to NPM, so it should be fixed

Spartan-II-117 avatar Oct 17 '18 22:10 Spartan-II-117

I'm sorry, but it doesn't work for me. Maybe i've configured it the wrong way? Here's what i did:

  1. Deploy HA and node-red via docker
  2. Making sure that this module is installed in version 3.10
  3. Configured a reverse proxy, so that node-red is reachable via node-red.mydomain.tld and HA via assistant.mydomain.tld
  4. Both containers are in the same docker network, HA is reachable via internal hostname homeassistant_app_1
  5. Did not configure a legacy API password in HA, created a LLAT
  6. Configured node-red's httpRoot to "/"
  7. Added a HA element to the flow, configured it with the server "http://homeassistant_app_1:8123" and the LLAT. API password field is empty.

Result: Error "Cannot get /homeassistant/entities", however, when i deploy the flow, the node says "Connected". The element list stays empty.

simonszu avatar Oct 18 '18 09:10 simonszu