tjntomas / HADashboard-widgets

Widgets for HADashboard / Appdaemon
MIT License
52 stars 26 forks source link

widget fails to authenticate #14

Open swdwi2 opened 4 years ago

swdwi2 commented 4 years ago

Thanks for the effort to produce the custom widgets.

I'm experiencing connection issues with the hagraph widget. Getting multiple errors I'm assuming related to CORS.

Appreciate if you have any ideas of where I should start looking to resolve this.

I'm using Home Assistant 0.105.4.

: Origin http://192.168.1.8:5050 is not allowed by Access-Control-Allow-Origin.

Please let me know which files I should provide to assist you in resolving this issue. Safari Snapshot.txt

Attached is a sample of the messages I see in my java console.

Regards Dave

tjntomas commented 4 years ago

I think you should try adding your appdaemon ip and port to your Home Assistant configuration.yaml file, in the http: section. Here is an example:

http:
  cors_allowed_origins:
    - http://192.168.1.8:5050  # Your Appdaemon ip and port

This should take care of the CORS issue. Also, a few things that would be good to know if the above does not help:

You also have some unrelated errors in your log, but let's start with the above.

swdwi2 commented 4 years ago

Tomas,

Thank you for your reply.

I already had that included. I scanned all the posts I could find before bothering you.

I've included some extracts form the various configuration files.

Everything else works fine. I can get access to all my home Assistant data. Toggle lights and switches and read sensors.

Its only the hagraph that is giving me a problem.

Appreciate it if you could have a look at the attached and maybe give me a few ideas of where I should look next.

On 18 Feb 2020, at 21:52, Tomas Jansson notifications@github.com wrote:

I think you should try adding your appdaemon ip and port to your Home Assistant configuration.yaml file, in the http: section. Here is an example:

http: cors_allowed_origins:

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS45Z5TUMRYYP7OXKETRDRKBLA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMFN6MI#issuecomment-587915057, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4IS2GDL4HTGHQWUMFGCTRDRKBLANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

Hi, nothing attached or maybe you were not allowed to attach anything here. Please post your appdaemon.yaml file to start with. You are getting some errors I havn't seen before so seems like a network issue. Also, the widgete was written for Appdaemon 3 and a few minor changes are need if you are ussing Appdaemon 4.

swdwi2 commented 4 years ago

Tomas,

I am using V4.

Do you have the details of the changes required>

Here is my appdaemon.yaml

appdaemon: threads: 10 time_zone: Europe/London latitude: 53.2787 longitude: -2.9013 elevation: 0 app_dir: /conf/apps plugins: HASS: type: hass ha_url: http://192.168.1.8:8123 token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJkZjYyOTI3NzgxZDc0ZWU0OTMzNDRhODRmY2U1NmVmYiIsImlhdCI6MTU4MTg0ODUxNSwiZXhwIjoxODk3MjA4NTE1fQ.pAt4HpeVO_99BWfLbwIxmyPHkAyVPg2WAoGBzbCdgnU http: url: http://192.168.1.8:5050 headers: Access-Control-Allow-Origin: "*" admin: api: hadashboard:

On 19 Feb 2020, at 10:48, Tomas Jansson notifications@github.com wrote:

Hi, nothing attached or maybe you were not allowed to attach anything here. Please post your appdaemon.yaml file to start with. You are getting some errors I havn't seen before so seems like a network issue. Also, the widgete was written for Appdaemon 3 and a few minor changes are need if you are ussing Appdaemon 4.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4ISZDTMEETP65SITAU2LRDUE63A5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMHJIGA#issuecomment-588157976, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4IS2OOZWEVVQH5QULZL3RDUE63ANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

Ok, looks like I already made the changes in the repo, I forgot that.

This should not be needed in appdaemon.yaml so remove it for now:

  headers:
    Access-Control-Allow-Origin: "*"

Please post your http: section from your configuration.yaml file. It is strange that you are still receiving CORS errors if the http: section in HA is correct.

tjntomas commented 4 years ago

I also made some changes to the widget since I posted it, so when I get home I'll upload all changes. This has mostly to do with increased drawing speed and fetching data from HA.

swdwi2 commented 4 years ago

Tomas,

Thank you. Appreciate if you could let me know when its done.

Could you also let me have the expect file permissions?

I’m running in a docker container under ubuntu 18.04lts server.

Does this create any unique problems?

On 19 Feb 2020, at 11:06, Tomas Jansson notifications@github.com wrote:

Ok, looks like I already made the changes in the repo, I forgot that.

This should not be needed in appdaemon.yaml so remove it for now:

headers: Access-Control-Allow-Origin: "*" Please post your http: section from your configuration.yaml file. It is strange that you are still receiving CORS errors if the http: section in HA is correct.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4ISZC5FWXKQHVXHZPVFTRDUHBXA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMHK75Y#issuecomment-588165111, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4IS3LUXDHTEFRRJW5Z63RDUHBXANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

The V4 changes were made and uploaded to the repo some weeks ago so you should already have the correct files. I am also running both Appdaemon and HA in docker on Ubuntu 18.04 so this should not be an issue. For file permissions I use 755 but 644 should be enough.

tjntomas commented 4 years ago

I'll post here when I have uploaded the changed code.

tjntomas commented 4 years ago

ok, so replace your existing basehagraphfolder and hagraph.yaml file with the files in this repo https://github.com/tjntomas/hagraph_debug

Then make a .dash file with only one hagraph widget (no other widgets at all in the file), empty the browser cache and see what the browser console log says. I had some errors also and I have updated the code and got rid of all errors.

swdwi2 commented 4 years ago

Tomas,

Sorry for the delay. I wasn't home last night.

I’ve loaded your code.

Sadly I still the same sort of errors.

Here is the first few lines from the java console.

[Log] time zone: – "Europe/Stockholm" (application.js, line 4028) [Log] Local time is – Thu Feb 20 2020 10:49:21 GMT+0000 (GMT) (application.js, line 4030) [Log] {widget_type: "basehagraph", fields: [], enable: 0, static_css: {widget_style: "border-bottom-left-radius: 10px;border-bottom-righ…-left-radius: 10px;border-top-right-radius: 10px;", graph_style: "border-radius: 0px;background-color: rgba(30,30,30,0.45 );"}, css: Object, …} (dashboard.js, line 259) [Log] /api/appdaemon/state/default/sensor.power_from_mains (dashboard.js, line 269) [Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery.gridster.css.map, line 0) [Error] Failed to load resource: the server responded with a status of 404 (Not Found) (materialdesignicons.css.map, line 0) [Error] Failed to load resource: the server responded with a status of 404 (Not Found) (socket.io.js.map, line 0) [Log] 2020-02-20 – "09:49:21" (application.js, line 4418) [Log] Scheme – "http" (application.js, line 4336) [Log] Connected to Home Assistant (application.js, line 4388) [Error] Failed to load resource: Origin http://192.168.1.8:5050 is not allowed by Access-Control-Allow-Origin. (2020-02-20T09:49:21, line 0) [Error] Origin http://192.168.1.8:5050 is not allowed by Access-Control-Allow-Origin. (anonymous function) (application.js:4376) [Error] XMLHttpRequest cannot load http://192.168.1.8:8123/api/history/period/2020-02-20T09:49:21?authSig=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJkZjYyOTI3NzgxZDc0ZWU0OTMzNDRhODRmY2U1NmVmYiIsInBhdGgiOiIvYXBpL2hpc3RvcnkvcGVyaW9kLzIwMjAtMDItMjBUMDk6NDk6MjEiLCJpYXQiOjE1ODIxOTU3NjEsImV4cCI6MTU4MjE5NTc4MX0.tC0vSSW4dxN1qccvTtk2mPJnRNq-0O2lZ8EaCM20dQ4&filter_entity_id=sensor.power_from_mains due to access control checks. (anonymous function) (application.js:4376) [Error] NetworkError: A network error occurred. send (application.js:4376) (anonymous function) (application.js:4376) [Log] 2020-02-20 – "09:49:23" (application.js, line 4418) [Log] Scheme – "http" (application.js, line 4336)

I notice that you have a different timzone to my system. Is this used in anyway by CORS?

On 19 Feb 2020, at 16:55, Tomas Jansson notifications@github.com wrote:

ok, so replace your existing basehagraph folder and hagraph.yaml file with the files in this repo https://github.com/tjntomas/hagraph_debug https://github.com/tjntomas/hagraph_debug Then make a .dash file with only one hagraph widget (no other widgets at all in the file), empty the the browser cache and see what the browser console log says. I had some errors also and I have updated the code and got rid of all errors.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS5O45U2DU5366ZWUMDRDVQBBA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMIR7BA#issuecomment-588324740, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4ISYQC532SXIESBZZ7TLRDVQBBANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

Ok, access the page again and then quickly click on link in the log following the words [Error] XMLHttpRequest cannot load (it will gererante a new link each time so you need to click on the link within 20 seconds. ``` or copy the link to your browser. Also, please post thehttp: section from yourconfiguration.yaml `file. This is likely a simple problem, just something we are missing.

Please also post your .dash file. What url are you using to access Appdaemon?

swdwi2 commented 4 years ago

Tomas,

Attempting to open link gives a display with looks like all the date points. Sample below :- [[{"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "b92994627486415aaf02ec6b8a8419dd", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:17:49+00:00", "last_updated": "2020-02-20T12:17:49+00:00", "state": "1451"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "64ea13258e124b1dad57093673b01423", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:17:53.277724+00:00", "last_updated": "2020-02-20T12:17:53.277724+00:00", "state": "1447"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "6bd023932b0c4fb69280739f64e786ff", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:18:03.056703+00:00", "last_updated": "2020-02-20T12:18:03.056703+00:00", "state": "1472"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "7e4b714950a94f288c86fe5de05b6477", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:18:13.350036+00:00", "last_updated": "2020-02-20T12:18:13.350036+00:00", "state": "1459"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "fea0253b7c544d4e98c8351a5511889b", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:18:22.895206+00:00", "last_updated": "2020-02-20T12:18:22.895206+00:00", "state": "1430"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "0b605408536a485694f74491a26a31a9", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:18:32.721336+00:00", "last_updated": "2020-02-20T12:18:32.721336+00:00", "state": "1622"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "37de9fbd896c4cffac75239ca5c017e2", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:18:43.265193+00:00", "last_updated": "2020-02-20T12:18:43.265193+00:00", "state": "1427"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "c8655720c70e4e3baa1d281102cc48ae", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:18:52.622880+00:00", "last_updated": "2020-02-20T12:18:52.622880+00:00", "state": "1447"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "ec53880f83284cea93a7be2e72b7e7de", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:19:02.444366+00:00", "last_updated": "2020-02-20T12:19:02.444366+00:00", "state": "1463"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "c3405a2dd8ac4f0596f9e46b7ff5589f", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:19:12.816537+00:00", "last_updated": "2020-02-20T12:19:12.816537+00:00", "state": "1454"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "e9628aff7b7d44c8aab3ec2da642cf79", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:19:22.313219+00:00", "last_updated": "2020-02-20T12:19:22.313219+00:00", "state": "1443"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "f557c7411e7b4a429914c88eacf8a50a", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:19:32.185713+00:00", "last_updated": "2020-02-20T12:19:32.185713+00:00", "state": "1429"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "66203fc44a5141b886de7073cab4336f", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:19:42.112809+00:00", "last_updated": "2020-02-20T12:19:42.112809+00:00", "state": "1578"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "94336fb8d8d74dc186f3010d84d12a14", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:19:52.004747+00:00", "last_updated": "2020-02-20T12:19:52.004747+00:00", "state": "1076"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "ab4a40e094a24739b896c2f9b0ce09e6", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:20:01.873167+00:00", "last_updated": "2020-02-20T12:20:01.873167+00:00", "state": "1222"}, {"attributes": {"friendly_name": "Power from Mains", "unit_of_measurement": "W"}, "context": {"id": "adbb0caaa8584ba2986930ebc2849251", "parent_id": null, "user_id": null}, "entity_id": "sensor.power_from_mains", "last_changed": "2020-02-20T12:20:11.822598+00:00", "last_updated": configuration.yaml http: cors_allowed_origins:

dashboard:-

title: GraphTest widget_dimensions: [170, 170] widget_size: [2,1] widget_margins: [5, 5] columns: 20

mvp: widget_type: hagraph entities:

layout:

I’ve user both the admin window to access dashboards and also http://192.168.1.8:5050/graphtest http://192.168.1.8:5050/graphtest

On 20 Feb 2020, at 11:08, Tomas Jansson notifications@github.com wrote:

Ok, access the page again and then quickly click on link in the log following the words [Error] XMLHttpRequest cannot load (it will gererante a new link each time so you need to click on the link within 20 seconds. ``` or copy the link to your browser. Also, please post the http: section from yourconfiguration.yaml `file. This is likely a simple problem, just something we are missing.

Please also post your .dash file. What url are you using to access Appdaemon?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS4XOBK5V552BS2DRTLRDZQB5A5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMNOPMQ#issuecomment-588965810, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4ISYCV4VOE6YXN7QUQKDRDZQB5ANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

Ok, great, the call to retrieve the history from HA is working fine. In the widget, units: °W" should be units: "W" but I don't think this makes any different, but adjust it anyway. I have a few ideas I will post later regarding the CORS error.

swdwi2 commented 4 years ago

Tomas,

Thank you. Your efforts are much appreciated.

On 20 Feb 2020, at 13:57, Tomas Jansson notifications@github.com wrote:

Ok, great, the call to retrieve the history from HA is working fine. In the widget, units: °W" should be units: "W" but I don't think this makes any different, but adjust it anyway. I have a few ideas I will post later regarding the CORS error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS42BBWT3BR443DEEJDRD2D4RA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMOB2YI#issuecomment-589045089, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4ISYASPXOKHIWKD5XPS3RD2D4RANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago
http:
  cors_allowed_origins:
    - http://192.168.1.8:5050 <http://192.168.1.8:5050/>

Just checking to make sure its not a cut and paste issue, but the <http://192.168.1.8:5050/> should not be there, it should only be

http:
  cors_allowed_origins:
    - http://192.168.1.8:5050
swdwi2 commented 4 years ago

Yes its a formatting issue with the email  Actual entry is as your example at the bottom of the emalRegards, DaveMailto:swdwi2@gmail.com -------- Original message --------From: Tomas Jansson notifications@github.com Date: 20/02/2020 15:55 (GMT+00:00) To: tjntomas/HADashboard-widgets HADashboard-widgets@noreply.github.com Cc: swdwi2 swdwi2@gmail.com, Author author@noreply.github.com Subject: Re: [tjntomas/HADashboard-widgets] widget fails to authenticate (#14) http: cors_allowed_origins:

Just checking to make sure its not a cut and paste issue, but the http://192.168.1.8:5050/ should not be there, it should only be http: cors_allowed_origins:

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications\u0026email_token=ALY4IS2HRZBYY7GXEC5FMY3RD2RYTA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMO32MA#issuecomment-589151536", "url": "https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications\u0026email_token=ALY4IS2HRZBYY7GXEC5FMY3RD2RYTA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMO32MA#issuecomment-589151536", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

swdwi2 commented 4 years ago

Tomas,

If I run Safari with ‘disable local file restrictions’ or chrome with ‘disable-web-security’ flag. Everything works as expected.

Hope this helps you narrow things down a bit.

On 20 Feb 2020, at 13:57, Tomas Jansson notifications@github.com wrote:

Ok, great, the call to retrieve the history from HA is working fine. In the widget, units: °W" should be units: "W" but I don't think this makes any different, but adjust it anyway. I have a few ideas I will post later regarding the CORS error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS42BBWT3BR443DEEJDRD2D4RA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMOB2YI#issuecomment-589045089, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4ISYASPXOKHIWKD5XPS3RD2D4RANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

swdwi2 commented 4 years ago

Tomas,

Did you have any further thoughts?

I’m running Home Assistant 0.105.5.

Is this different to your version?

On 20 Feb 2020, at 15:55, Tomas Jansson notifications@github.com wrote:

http: cors_allowed_origins:

http: cors_allowed_origins:

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

I am also on 0.105.5, with the same CORS settings working which is the strange thing. I'm starting to suspect that the CORS configuration in HA is not working as expected. Any access errors in the HA logs?

tjntomas commented 4 years ago

Please check the following: Open the url to the dashboard in Chrome. Open the console and click on network and then select XHR and click on the line with a date. Then click on Headers and copy the content of the headers window. Start copying from the bottom is easier. Then same with the initiator section and copy the content in the Request initiator chain section and post it here. This will show the exact request and response of the XHTMLRequest used to access the history from HA.

swdwi2 commented 4 years ago

Tomas,

Here is the Headers window.

I cant copy the initiator window.

Request URL: http://192.168.1.8:8123/api/history/period/2020-02-21T19:08:40?authSig=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJkZjYyOTI3NzgxZDc0ZWU0OTMzNDRhODRmY2U1NmVmYiIsInBhdGgiOiIvYXBpL2hpc3RvcnkvcGVyaW9kLzIwMjAtMDItMjFUMTk6MDg6NDAiLCJpYXQiOjE1ODIzMTU3MjAsImV4cCI6MTU4MjMxNTc0MH0.jSrolShHWC9FVj6F7oCDt78-cgDnLaAPe--NOGKeJu8&filter_entity_id=sensor.power_from_mains Referrer Policy: no-referrer-when-downgrade Response Headers view source Content-Encoding: deflate Content-Length: 13106 Content-Type: application/json Date: Fri, 21 Feb 2020 20:08:52 GMT Server: Python/3.7 aiohttp/3.6.1 Request Headers view source Accept: / Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9 Connection: keep-alive Host: 192.168.1.8:8123 Origin: http://192.168.1.8:5050 Referer: http://192.168.1.8:5050/graphtest2 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36 Query String Parameters view source view URL encoded authSig: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJkZjYyOTI3NzgxZDc0ZWU0OTMzNDRhODRmY2U1NmVmYiIsInBhdGgiOiIvYXBpL2hpc3RvcnkvcGVyaW9kLzIwMjAtMDItMjFUMTk6MDg6NDAiLCJpYXQiOjE1ODIzMTU3MjAsImV4cCI6MTU4MjMxNTc0MH0.jSrolShHWC9FVj6F7oCDt78-cgDnLaAPe--NOGKeJu8 filter_entity_id: sensor.power_from_mains

On 21 Feb 2020, at 19:26, Tomas Jansson notifications@github.com wrote:

Please check the following: Open the url to the dashboard in Chrome. Open the console and click on network and then select XHR and click on the line with the name of your entity, ie. sensor.mysensor. Then click on Headers and copy the content of the headers widow. Start copying from the bottom is easier. Then same with the initiator section and copy the content in the Request initiator chain section and post it here. This will show the exact request and response of the XHTMLRequest used to access the history from HA.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS2SVXCLJZSKCNGXV6DREATF5A5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTZ5GY#issuecomment-589799067, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4IS7Q7JIGDSXBAWJJE7LREATF5ANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

swdwi2 commented 4 years ago

Tomas,

Thanks for all your efforts.

Looks like this was a combination of things.

I deleted HomeAssistant from docker and did a purge. Then rebuilt HomeAssistant docker image.

The new graph that was added for the test works and updates correctly.

However once I add anything else to the dashboard the cors errors return.

So this works fine:-

title: GraphTest widget_dimensions: [170, 170] widget_size: [2,1] widget_margins: [5, 5] columns: 20

mvp: widget_type: hagraph entities:

layout:

But this creates the cors errors again.

title: GraphTest widget_dimensions: [170, 170] widget_size: [2,1] widget_margins: [5, 5] columns: 20

mvp: widget_type: hagraph entities:

home1: widget_type: navigate dashboard: "proshop" title: ProShop icon_active: mdi-arrow-collapse
icon_inactive: mdi-arrow-collapse

layout:

On 21 Feb 2020, at 19:26, Tomas Jansson notifications@github.com wrote:

Please check the following: Open the url to the dashboard in Chrome. Open the console and click on network and then select XHR and click on the line with the name of your entity, ie. sensor.mysensor. Then click on Headers and copy the content of the headers widow. Start copying from the bottom is easier. Then same with the initiator section and copy the content in the Request initiator chain section and post it here. This will show the exact request and response of the XHTMLRequest used to access the history from HA.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications&email_token=ALY4IS2SVXCLJZSKCNGXV6DREATF5A5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTZ5GY#issuecomment-589799067, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY4IS7Q7JIGDSXBAWJJE7LREATF5ANCNFSM4KWODLOA.

Williams Dave mailto: swdwi2@gmail.com Mobile 07767237637

tjntomas commented 4 years ago

Might be a namespace issue, one widget overwriting parameters for another widget, possibly the url parameter, causing a call to an unexpected url. I will have a look at using a separate namespace for the widget to see if the issue goes away.

swdwi2 commented 4 years ago

Tomas,Thank you. Regards, DaveMailto:swdwi2@gmail.com -------- Original message --------From: Tomas Jansson notifications@github.com Date: 26/02/2020 17:44 (GMT-05:00) To: tjntomas/HADashboard-widgets HADashboard-widgets@noreply.github.com Cc: swdwi2 swdwi2@gmail.com, Author author@noreply.github.com Subject: Re: [tjntomas/HADashboard-widgets] widget fails to authenticate (#14) Might be a namespace issue, one widget overwriting parameters for another widget, possibly the url parameter, causing a call to an unexpected url. I will have a look at using a separate namespace for the widget to see if the issue goes away.

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or unsubscribe. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications\u0026email_token=ALY4ISZ2JFOTEODF4NILMKTRE3WEHA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENCF3VQ#issuecomment-591683030", "url": "https://github.com/tjntomas/HADashboard-widgets/issues/14?email_source=notifications\u0026email_token=ALY4ISZ2JFOTEODF4NILMKTRE3WEHA5CNFSM4KWODLOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENCF3VQ#issuecomment-591683030", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

stibbzy commented 2 years ago

I am also on 0.105.5, with the same CORS settings working which is the strange thing. I'm starting to suspect that the CORS configuration in HA is not working as expected. Any access errors in the HA logs?

Hi @tjntomas , @swdwi2

I am having a very similar issue with CORS authentication. Here is what the javascript console shows whenever I attempt to use the widget. I also get an authentication error in the HA log, despite using the correct token:

Screen Shot

The start of my configuration.yaml looks like this:

default_config: api: http: cors_allowed_origins:

I'm running Appdaemon 4, with Home Assistant in a VirtualBox VM. All other widgets can pull data fine. The relevant sections of my dashboard config, using the default skin, are:

title: Test Panel widget_dimensions: [120, 120] widget_margins: [5, 5] columns: 8 use_hass_icon: 1

mvp: widget_type: hagraph entities:

layout:

Per your instructions, I've copied the default skin variables and dashboard files to the custom_css folder and made the relevant changes. I then access it using http://192.168.0.40:5050/Test?skin=default

I thought @tjunussov had found the issue here (see the bottom of page): https://github.com/home-assistant/core/issues/40513 but when I used his http folder as a custom component override, it still didn't fix the issue.

Do you have any other ideas? It's been driving me nuts for days now, I'd really love to have this graph functionality!

Many thanks :)

tjntomas commented 2 years ago

I'm currently travelling, so no access to my code, but try removing the trailing slash in http://192.168.0.40:5050/

stibbzy commented 2 years ago

Hi @tjntomas Thanks for the reply! I just tried your suggestion now, but unfortunately, the same authentication problem occurs.

LouPaloma commented 1 year ago

Was there ever a fix for the auth problem seen here? If not, are there any alternative graphing solutions?