jaroschek / home-assistant-myuplink

Custom Home Assistant integration for devices and sensors in myUplink account.
39 stars 8 forks source link

No systems found #111

Open OnlyRobin opened 4 weeks ago

OnlyRobin commented 4 weeks ago

This is not due to the integration, but maybe someone here knows what I am doing wrong or what is wrong.

I have a myuplink account, Dev application and everything has worked well, a week ago the entities were suddenly gone.

I went to Swagger UI to test this and GET /v2/systems/me gives me no errors but only this (Response body Download { "page": 1, "itemsPerPage": 10, "numItems": 0, "systems": [] } ).

But when I go to https://myuplink.com/ everything works.

I deleted the old application and created a new application. Deleted and recreated my Myuplink account but it doesn't work.

I asked Myuplink itself, but they couldn't help me.

Anyone have any idea what could be wrong?

drwatson75 commented 4 weeks ago

Same here for me, output swagger (get user systems) Thanks, Rogier

{ "page": 0, "itemsPerPage": 0, "numItems": 0, "systems": [ { "systemId": "xxxxxxxxxxxxxxxxxxxxxxx", "name": "string", "securityLevel": "admin", "hasAlarm": true, "country": "string", "devices": [ { "id": "string", "connectionState": "Disconnected", "currentFwVersion": "string", "product": { "serialNumber": "string", "name": "string"

a-mavrides commented 3 weeks ago

Hello All,

same here:

{ "page": 1, "itemsPerPage": 10, "numItems": 0, "systems": [] }

Crossmotion commented 3 weeks ago

Same problem here, since +/- 4 days

marsav commented 2 weeks ago

Same issue, the systems endpoint is returning empty list, looks like an API issue. Slightly irrelevant but noticed that myuplink.com itself uses v3/groups/me endpoint to get systems info. If I take the id from v3/groups/me response, I can successfully query my device info via /v2/devices/{deviceId} endpoint.

Reported issue to myUplink.

a-mavrides commented 2 weeks ago

@marsav Indeed it seems that the only "problematic " api endpoint is /v2/systems/me. As you mentioned from internalapi you can get the systems . So as a temporary solution i am combining the response from internalapi -> v3/groups/me in a json file in the following format : { "page": 1, "itemsPerPage": 99, "numItems": 1, "systems": [ { "systemId": "xxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxx", "name": "Name", "securityLevel": "admin", "has_alaram": false, "country": "Country", "devices": [ { "id": "xxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxx-xxxxxxxxx", "connectionState": "Connected", "currentFwVersion": "9696R3", "product": { "serialNumber": "00000000000000000", "name": "XXXXXXXXX" } } ] }, { "systemId": "xxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxxxx", "name": "Name", "securityLevel": "admin", "has_alaram": false, "country": "Country", "devices": [ { "id": "xxxx-xxxxxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxxxx", "connectionState": "Connected", "currentFwVersion": "9696R3", "product": { "serialNumber": "00000000000", "name": "XXXXXX" } } ] } ] }

Save this as a json file in the same directory as myuplink /config/custom_components/myuplink/

Then in api.py after line """Return all systems.""" _LOGGER.debug("Fetch systems") async with self.lock, self.throttle: resp = await self.auth.request("get", "systems/me?page=1&itemsPerPage=99") resp.raise_for_status() data = await resp.json()

i have added the following :

` # File path to be opened path = '/config/custom_components/myuplink/my.json'

Mode to be set

    mode = 0o666
    # flags
    flags = os.O_RDONLY
    fd = os.open(path, flags, mode)
    os.lseek(fd, 0, 0)
    str = os.read(fd, os.path.getsize(path))
    data1 = str.decode()
    os.close(fd)
    data = json.loads(data1)`

This will load the systems from json file instead from the api and since all the other api calls are successful the integration is working just fine for me .

Remember this is a temporary workaround and once the api is fully functional again the above code should be removed

olivebadger14 commented 2 weeks ago

for anyone who needs it

the code formatted correctly is

File path to be opened

    path = '/config/custom_components/myuplink/workaround_payload.json' 
    # Mode to be set  
    mode = 0o666 
    # flags 
    flags = os.O_RDONLY 
    fd = os.open(path, flags, mode) 
    os.lseek(fd, 0, 0) 
    str = os.read(fd, os.path.getsize(path)) 
    data1 = str.decode() 
    os.close(fd) 
    data = json.loads(data1)

also at the very beginning of the file where all the import statements are you also need to add :

import os

olivebadger14 commented 2 weeks ago

only problem im facing is that this temp fix creates over 500 entities for the device, i assume this isnt right?

a-mavrides commented 2 weeks ago

hello @olivebadger14 it shouldn't be any different from the api calling the normal flow since we are just injecting the response from the /v2/systems/me api call

OnlyRobin commented 2 weeks ago

I dont know how do i get the systemid and the id to enter here,

{ "page": 1, "itemsPerPage": 99, "numItems": 1, "systems": [ { "systemId": "xxxxxxx-xxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxx", "name": "Name", "securityLevel": "admin", "has_alaram": false, "country": "Country", "devices": [ { "id": "xxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxx-xxxxxxxxx", "connectionState": "Connected", "currentFwVersion": "9696R3", "product": { "serialNumber": "00000000000000000", "name": "XXXXXXXXX" } } ] }, { "systemId": "xxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxxxx", "name": "Name", "securityLevel": "admin", "has_alaram": false, "country": "Country", "devices": [ { "id": "xxxx-xxxxxxxxxxxx-xxxxxxxxxxx-xxxxxxxxxxxx", "connectionState": "Connected", "currentFwVersion": "9696R3", "product": { "serialNumber": "00000000000", "name": "XXXXXX" } } ] } ] }

olivebadger14 commented 2 weeks ago

@OnlyRobin the way do do it is inspect the network traffic in chrome while you load the main my uplink page (right click, inspect page, click the network tab) then filter for internalapi and check the resoposes of the GET requests, refresh the page if you still cant find your id

a-mavrides commented 2 weeks ago

@OnlyRobin you could use postman to generate the internalapi flow , but the easiest way as @olivebadger14 suggests is to login into myuplink.com as usual and then open your browser's developer console from there go to network tab and search for "me" one of those responses will be from v3/groups/me open the response from that and all the information are there.

OnlyRobin commented 2 weeks ago

Thank you, found it. But is the Systemid and the id the same because i get a 404 error

a-mavrides commented 2 weeks ago

@OnlyRobin No systemid and id are not the same . Please check the response from v3/groups/me .

OnlyRobin commented 1 week ago

Thank you all for helping, i got it to work. Nice job.

OnlyRobin commented 5 days ago

? What is wrong with the API. It sucks realy bad. Now i get:

https://api.myuplink.com/v2/systems/XXXXXXXXXXXXXXXXXXXXXXXX/notifications/active?page=1&itemsPerPage=10 403 Error: Forbidden

Response body The subject does not have access to the system "------------------------------"

SentiHassio1979 commented 5 days ago

What am I doing incorrectly when I get this response

image