Skip to content

Phoscon login issues #3

Closed
Closed

Description

@mattreim

Hello @manup, after many more tests, I haven't found a solution to get rid of this error message in Home Assistant. Perhaps it should be fixed in Phoscon, since it's also present in the browser.

Browser error (Chrome):

Image

Home Assistant Addon (Protocol):

172.30.32.2 - delight [15/Aug/2025:15:38:35 +0200] "POST /api/ HTTP/1.1" 403 94 "http://192.168.178.76:8123/api/hassio_ingress/3wJOtcgLRnlue-aRwWxkWR61rYqQ2MW3HhXlA_cLSFs/pwa/login2.html?1755265114162" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"

Home Assistant issue.

Image

Maybe you have an idea. Thanks.

Activity

  1. manup commented on Aug 12, 2025

    @manup
    Member

    Out of interest I put it into git diff. To be honest I have no clue what the changes are doing since the files were completely reformatted and modified by GPT.

    Image
  2. mattreim commented on Aug 12, 2025

    @mattreim
    Author

    Sorry, I was a bit hasty there, and the changes GPT suggested wouldn't have made much sense. Now I'm pretty sure it's Home Assistant. So, have a nice day.

  3. mattreim commented on Aug 22, 2025

    @mattreim
    Author

    @manup, I think the cause of the POST /api/ HTTP/1.1 403 error is pollGateways() in pwa/js/login/helper-functions.js. It contains the following expression:

    sendLogin(gw,"delight").then(()=>{
        gw.unset("apikey")
    }).catch(err=>{})

    According to GPT, a login attempt is made every 5 seconds with the username "delight" which then causes this error. Removing these lines should fix it.

    Image
    Image

    I saw that this bug will be fixed with the Phoscon App v2.0.6 so just wait and see.

  4. manup commented on Aug 26, 2025

    @manup
    Member

    Hi, I'm trying to wrap my head around this. The login JS code isn't pretty, from what I remember the prope from above is to detect if the gateway still has the legacy defaut password "delight" in use and move the user to the UI to set a unique password.

    However this shouldn't be done infinito. I'll try to figure out a fix, hopefully this can be done with my small VM HA test setup for debugging.

  5. mattreim commented on Aug 26, 2025

    @mattreim
    Author

    Thank you, it would be great if this error was fixed and maybe Phoscon also has an icon.

  6. manup commented on Aug 26, 2025

    @manup
    Member

    Uff that was a deep dive. I think to have found what was going wrong and added a small fix in scanner.js.

    const Gateway = Backbone.Model.extend({
        url: function() {
            const ip = this.get('ip');
            const port = ':' + this.get('port') || '';
    
            let url = '//' + ip + port + '/api';
    
            // handle HA ingress extra path here
            let path = location.pathname; // /api/hassio_ingress/IlTGHq7BYxfxXQDMf9F_r9ADSQaZuysfh3nr-SAyNFQ/pwa/login2.html?1756241884538"
            path = path.slice(0, path.indexOf('/pwa')); // /api/hassio_ingress/IlTGHq7BYxfxXQDMf9F_r9ADSQaZuysfh3nr-SAyNFQ
    
            if (path.length !== 0 && location.hostname === ip && location.port === this.get('port')) {
                url = '//' + ip + port + path + '/api';
            }
    
            if (this.has('apikey'))
                url += '/' + this.get('apikey');
            else
                url += '/config';
            return url;
        },
        sync: function(method, model, options) {
            return Backbone.sync(method, model, options);
        }
    });

    The problem was that ingress does add a small path to the URL like /api/hassio_ingress/IlTGHq7BYxfxXQDMf9F_r9ADSQaZuysfh3nr-SAyNFQ and the code on the login page only used the normal host:port combo and then appended the deCONZ API path.

    The changes above will the extra path in the URL in cases like Ingress. I could only verify this in a live system for now within the browser debugger by setting a breakpoint on the url method and hard rewrite the variable. In the test the call then returns proper 200 instead 401 error code.

  7. mattreim commented on Aug 27, 2025

    @mattreim
    Author

    You've made deCONZ/Phoscon a whole lot better and fixed a pretty old bug in HA. You're great, thank you very much.

  8. bcutter commented on Sep 29, 2025

    @bcutter

    And now it finally is available in a stable release. Curios to see how long it will take until the HA deCONZ addon will receive the 2.31.2 update.

  9. mattreim commented on Sep 30, 2025

    @mattreim
    Author

    Hi @manup, I made two more changes here.

    • Add the favicon folder from version 2.0.11
    • In the devices-plug.html the unit of consumption changed from wH to Wh

    phoscon_app_2025-09-30.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions