marcosav / fermax-blue-intercom

Fermax Blue script to open the door
19 stars 4 forks source link

Error on python 3.10 #2

Closed soloam closed 1 year ago

soloam commented 1 year ago

hello when I run this script in I get the error:

Traceback (most recent call last):
  File "/config/sheel_scripts/fermax_opendoor/open_door.py", line 176, in <module>
    access_token = auth(cache, username, password)
  File "/config/sheel_scripts/fermax_opendoor/open_door.py", line 113, in auth
    access_token = parsed_json['access_token']
KeyError: 'access_token'

But if I have the "portal_cache.json" all works ok...

marcosav commented 1 year ago

Hi @soloam, maybe credentials are wrong, try again with the latest version of the script, I made some changes to raise an error when authentication didn't success showing a description. I think the reason why it works when you have the "portal_cache.json" file, is because it skips the authentication step, where I suppose it's failing due to credentials.

soloam commented 1 year ago

This worked and I was able to find the problem, a "." out of place. Tks for the help and sorry for the confusion.

Also, I'll take this chance to make 2 questions:

Tks

marcosav commented 1 year ago

Hi, back when I was developing this script I tried to capture the traffic when connecting the video stream. I captured a POST https://blue.fermax.com/deviceaction/api/v2/device/{deviceId}/autoon

{
  "directedToBluestream": "somerandom:anotherlongerrandom",
  "deviceID": "adeviceid"
}

With this response:

{
  "reason": "call_starting",
  "divertService": "blueStream",
  "code": 1,
  "additional_info": {
    "technology": "duox",
    "remote": {
      "number": 0,
      "address": "00 00 00",
      "block": 0,
      "type": "panel",
      "subblock": 0
    },
    "local": {
      "number": 2,
      "address": "FF FF FF",
      "subtype": "monitor",
      "block": 0,
      "type": "terminal",
      "subblock": 0
    }
  },
  "description": "Auto on is starting",
  "directedTo": "samerandom:again the same anotherlongerrandom"
}

Then some HTTP requests to https://calldivertsignserver02-pro-west-europe.blue.fermax.com in order to get some credentials to connect to a Turn server, but I did not investigate further.

The value used on the /autoon request body (directedToBluestream) is the same as the one in the response (directedTo), this value is also used when listing call history in GET https://blue.fermax.com/callManager/api/v1/callregistry/participant?appToken={value}&callRegistryType=all, seems to be some kind of app token.

I hope this is useful, I am using Proxyman for iPad to capture the traffic, feel free to ask anything else.

BorjaJajas commented 1 year ago

Do you think there is any possibility to change the speech of the door when it opens? I mean tell any text you want with tts. And by the way the post you are getting doesnt say anything interesting no? I could try to help. Do you need me to capture traffic too or something specific?

marcosav commented 1 year ago

Hi @BorjaJajas, I would say it's not possible to change the door opening message (nor audio), at least using their API. Mainly because I think that it depends on the master board. I'm using the Fermax 9449 in a building with more apartments, (previously I had the 9448 which has no Wifi, and I think it is the one that other neighbors have), and it wouldn't make much sense that each neighbor could open the door with a different sound. Speaking of the POST /autoon request, I didn't manage to see how to get the "directedToBluestream", maybe it's an app token, I don't know. I also couldn't replicate the requests that take place when starting the video stream, you could try to capture the traffic when ringing and also when requesting the video stream, it would be so nice to check how it works 😃.

BorjaJajas commented 1 year ago

Hi @BorjaJajas, I would say it's not possible to change the door opening message (nor audio), at least using their API. Mainly because I think that it depends on the master board. I'm using the Fermax 9449 in a building with more apartments, (previously I had the 9448 which has no Wifi, and I think it is the one that other neighbors have), and it wouldn't make much sense that each neighbor could open the door with a different sound. Speaking of the POST /autoon request, I didn't manage to see how to get the "directedToBluestream", maybe it's an app token, I don't know. I also couldn't replicate the requests that take place when starting the video stream, you could try to capture the traffic when ringing and also when requesting the video stream, it would be so nice to check how it works 😃.

Here you have what I captured with openning and then asking for video and calling: https://drive.google.com/file/d/1-I0SwqOJk_2mxwUiTFasP9K8xrTcddFa/view?usp=drivesdk

BorjaJajas commented 1 year ago

Any idea of this error?

`C:\Users\Borja\Desktop\fermax-blue-intercom-master>python open_door.py --username xxxxxxx --password xxxxxxxx Traceback (most recent call last): File "C:\Users\Borja\Desktop\fermax-blue-intercom-master\open_door.py", line 182, in access_token = auth(cache, username, password) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Borja\Desktop\fermax-blue-intercom-master\open_door.py", line 117, in auth raise RuntimeError(parsed_json['error_description']) RuntimeError: Authentication failed for xxxxxxx@gmail.com

C:\Users\Borja\Desktop\fermax-blue-intercom-master>cmd /k C:\Users\Borja\Desktop\fermax-blue-intercom-master>`

soloam commented 1 year ago

It looks like a authentication error. I had to change my password to remove some special characters, don't recall the ones that I had to remove, but you can try to change your password to something without special characters, and see if it works!

BorjaJajas commented 1 year ago

It looks like a authentication error. I had to change my password to remove some special characters, don't recall the ones that I had to remove, but you can try to change your password to something without special characters, and see if it works!

I was just going to answer this, the program doesn't accept some special caracters like @ or )

Now it is working good as before