GithubHelp home page GithubHelp logo

cnorick / ha-auto-guest-login Goto Github PK

View Code? Open in Web Editor NEW
39.0 39.0 5.0 121 KB

Home Page: https://nathanorick.com/ha-automatic-guest-login

License: MIT License

JavaScript 65.19% Dockerfile 1.22% Shell 0.47% EJS 33.12%

ha-auto-guest-login's Introduction

Hi there ๐Ÿ‘‹

I'm Nathan. I'm a Web Developer. Check me out at nathanorick.com.

Nathan's github stats

Top Langs

ha-auto-guest-login's People

Contributors

cnorick avatar muddro1 avatar promofaux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ha-auto-guest-login's Issues

Problem with another dashboard

Hi , i am a new home assistant user and I have integrated a guest dashboard (made with https://github.com/resoai/TileBoard) in the "www" folder, and it is accessed with "http://HASS_IP:8123/local/tileboard/index.html". My question is: Is there any way to redirect the guest to that dashboard or is it only compatible with lovelace?

(Pd: thanks for your dedication c: )

can't start auto-guest-login

Hey, I need your help please.
after I have installed your script and want to run it, I see the "Start Page" for a short moment, but it's terminated again.
I get the following message.

Can you help me?

Bildschirmfoto 2022-04-20 um 19 47 24

Bildschirmfoto 2022-04-20 um 19 49 45

redirect not working

Chrome console:
GET http://ha.1156rbr.ca:8675/api/getRedirectUri net::ERR_CONNECTION_REFUSED
(anonymous) @ (index):50
Uncaught (in promise) TypeError: Failed to fetch
(anonymous) @ (index):50
Promise.then (async)
(anonymous) @ (index):52
GET http://ha.1156rbr.ca:8675/favicon.ico net::ERR_CONNECTION_REFUSED
:8675/favicon.ico:1

Safari:
[Error] Unhandled Promise Rejection: Not implemented on this platform
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'i.generateKey')
promiseEmptyOnRejected (content-script.js:75:780)
promiseReactionJob
[Error] Failed to load resource: Could not connect to the server. (getRedirectUri, line 0)
[Error] Unhandled Promise Rejection: TypeError: Load failed
promiseEmptyOnRejected
promiseReactionJob

let me know if you need any other information

Fails after redirect when using Cloudflared addon

Hi,

First - many thanks for publishing this addon! Certainly makes life easier getting guests to use my install.

Unfortunately, I'm running into an interesting issue when attempting to connect via Cloudflare tunnel. Hope you can help!

Configuration:

  • Home Assistant OS running on Raspberry Pi 4
  • using cloudflared addon for external access
  • install ha-auto-guest-login addon as per instructions
  • addon config:
guest_username: guest
guest_password: guest-password
guest_dashboard_path: dashboard-test
welcome_screen_delay_ms: 3000
welcome_screen_main_text: Thanks for Visiting
welcome_screen_secondary_text: Redirecting to Home Assistant...
advanced_internal_base_ha_url_and_port: http://my-homeassistant.local:8123
advanced_redirect_base_ha_url_and_port: https://my-hass.redacted.url:443
  • https://my-hass.redacted.url is the external URL which maps through to the internal http://my-homeassistant.local:8123
    • connecting to this gives proper full access to HASS UI
  • http://my-homeassistant.local:8123 is the correct internal URL,
    • HASS UI can be reached on this when on internal network without issue
  • https://my-guest.redacted.url is the external URL which is mapped through to http://my-homeassistant.local:8675
    • connecting to this correctly gives the addon initial welcome page
  • Once connected to https://my-guest.redacted.url we see the initial welcome page & are then redirected (as per log below)
  • Redirected page gives HA icon & "Unable to connect to Home Assistant. Retrying in xx seconds..." error
    • looking at browser console I can see that the browser is correctly starting to load the HASS UI, however I see Uncaught (in promise) exception
Promise.then (async)
(anonymous) @ core.ts (112)
(anonymous) @ core-iXwZTYzGWuY.js
  • Interestingly, if I just use the base URL provided in the redirect (ie, just remove the ?auth_callback... etc part), then I am presented with HASS normal login & subsequently provided the appropriate dashboard

Addon log:

posted ha_auto_login_guest_logged_in event
recieved request from: http://my-guest.redacted.url
using internal url: http://my-homeassistant.local:8123
using redirect baseUrl: https://my-hass.redacted.url:443
using clientId: https://my-hass.redacted.url:443/
fetching flowId
	url: http://my-homeassistant.local:8123/auth/login_flow
	redirectUri: https://my-hass.redacted.url:443?auth_callback=1
flowId: f60b8cba717d3c9a4b737b4c9f64b724
fetching code
	url: http://my-homeassistant.local:8123/auth/login_flow/f60b8cba717d3c9a4b737b4c9f64b724
code: 54d5ae8d99c9461783cd25c150be6cce
sending redirect uri to client
	redirectUri: https://my-hass.redacted.url:443/dashboard-test?auth_callback=1&code=54d5ae8d99c9461783cd25c150be6cce&state=eyJoYXNzVXJsIjoiaHR0cHM6Ly9jYnItaGFzcy5ib3JnLWN1LmJlOjQ0MyIsImNsaWVudElkIjoiaHR0cHM6Ly9jYnItaGFzcy5ib3JnLWN1LmJlOjQ0My8ifQ%3D%3D&storeToken=true

Any hints as to where I might be going wrong?

Thanks!!

It works like a charm! Had to remove one single comma

In the package.json file there is a comma that throws an error on my Debian 11 host when running npm install

{
  "name": "homeassistant_login",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1", <<<< This last comma has to be removed to get it to run properly
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.2",
    "node-fetch": "^3.1.0"
  }
}

SyntaxError in logs when opening URL

When running the docker compose all is fine, when starting the container too.

When I go to the correct URL I see the redirecting screen but nothing happens. When I check the log afterwards it gives me this error

SyntaxError: Unexpected token : in JSON at position 3
    at JSON.parse (<anonymous>)
    at Response.json (file:///app/node_modules/node-fetch/src/body.js:147:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getFlowId (file:///app/server.js:31:11)
    at async getCode (file:///app/server.js:35:18)
    at async getRedirectUri (file:///app/server.js:61:14)
    at async file:///app/server.js:73:12
Example app listening at http://localhost:80

Config:

version: "3"
services:
  ha-auto-guest-login:
    image: norick/ha-auto-guest-login:main
    container_name: ha-auto-guest-login
    environment:
      - CLIENTID=http://192.168.2.160:8123/
      - URL=http://192.168.2.160:8123/
      - DASH=lovelace-guest/lights (have also tried without the '/lights')
      - USER=guest-user
      - PASS=(password contains lowercase, uppercase, numbers and punctuation marks, might that be a problem?)
    ports:
      - 80:80
    restart: unless-stopped

Nabu Casa

Works perfectly in local network.
Is it possible somehow to configure Nabu Casa URL so HA is available from outside of local network?

PR Multiple users

Hello,

It's amazing how it work well!!

Do you ting it can be possible to add more users?

Thanks in advance

exec /usr/local/bin/docker-entrypoint.sh: exec format error

Trying to install via Portainer on the same RPi4 that runs HA (via Portainer stack), I'm getting

exec /usr/local/bin/docker-entrypoint.sh: exec format error
This is my docker compose file:

---
version: "3"
services:
  ha-auto-guest-login:
    image: norick/ha-auto-guest-login:main
    container_name: ha-auto-guest-login
    environment:
      - CLIENTID=http://192.168.0.181:8123/
      - URL=http://192.168.0.181:8123/
      - DASH=lovelace-mushroom
      - USER=host
      - PASS=aaaa
    ports:
      - 4077:80
    restart: unless-stopped

I tried to install the plain, dockerless version on a different RPi3 only to get this:

/home/pi/ha-auto-guest-login/server.js:1
import fetch from "node-fetch"
^^^^^

SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Please help.

Create Docker Container

I think I figured out how to created a docker image, and this will be my first PR, so apologies if its clunky.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.