Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loosing device #18

Open
adr1200c opened this issue Jan 7, 2022 · 5 comments
Open

loosing device #18

adr1200c opened this issue Jan 7, 2022 · 5 comments

Comments

@adr1200c
Copy link

adr1200c commented Jan 7, 2022

my elro devices ( # 3 in total) are not always shown in the elro program publishing to MQTT broker.

Most of the time 2 only are seen.

When the connection on the fire alarm is reestablished ( push 3 times) to the elro connection hub the device is visible in the elro hub to MQTT again.

is it a known issue?
is the elro_connects program capable of resetting device list . does it have a cache of devices?

@depuits
Copy link
Collaborator

depuits commented Jan 7, 2022

Currently this app does not support the management of the elro network. There is an issue to implement the management of device names using the cli but currently there has no work been done to implement that. I remember reading some reviews of other users using the official app with the same issue so I guess it's an issue in the system/protocol.

@Skons
Copy link
Collaborator

Skons commented Jan 16, 2022

The devices are now requested on connect with

msg = self.construct_message('{"cmdId":' + str(Command.SYN_DEVICE_STATUS.value) + ',"device_status":""}')

The app itself does this with (https://github.com/Siterwell/familywell-lidl-android/blob/6218fdd314a031c4745e71f101061065cc27bbfc/branch/lidl/app/src/main/java/me/hekr/sthome/service/SiterService.java#L811)

String crc = CoderUtils.getEqCRC(this, ConnectionPojo.getInstance().deviceTid);
sed.synGetDeviceStatus(crc);

The getEqCRC eventually does some magic on the State of the device, see https://github.com/Siterwell/familywell-lidl-android/blob/6218fdd314a031c4745e71f101061065cc27bbfc/branch/lidl/app/src/main/java/me/hekr/sthome/crc/CoderUtils.java#L186

This results in a json like this

{"msgId":1,"action":"appSend","params":{"devTid":"ST_xxxx","ctrlKey":"xxxx","data":{"cmdId":29,"device_status":"000e00000000xxxx00000000xxxx"}}}
000e 0000 0000 xxxx 0000 0000 xxxx
listlengthcalculated nonexistingdevice nonexistingdevice CRCMakerChar(devicestate) nonexistingdevice nonexistingdevice CRCMakerChar(devicestate)

It is not difficult to create the device status crc string (CRCMakerChar), the difficulty is; what is the data that should be there. It seems that the state is used because of this command allEquipmentInformation.get(eqid.indexOf(String.valueOf(i))).getState() but the state itself seems not to be device specific. If it is being used, i think that the last state should be remembered and used to get all device upon restart of the script. This could be done though through mqtt and the retain message flag. With this, no database should have to be created.

listlengthcalculated is Integer.toHexString(listLength*2+2). In this case the list is 6 and e == 14.

I already got a python implementation of CRCMakerChar (it looks a lot like the one i already reverse engineerd in #20).

I also dumped the database from my android app, the allEquipmentInformation eventually is constructed from information from the database, and the state database field (which i believe is used in the getState() function) is present as the device state in the database (0464AAXX).

@Skons
Copy link
Collaborator

Skons commented Jan 16, 2022

To add to this, i do not understand how the listlength is 6, in my case there are only 2 devices

@Skons
Copy link
Collaborator

Skons commented Jan 18, 2022

The 6 is the id of the device. The app does not use the number of devices as length, but the id of the last device. With this i can now hopefully implement the device discovery the same way the app does this and thus having all devices upon restart

@Skons
Copy link
Collaborator

Skons commented Jan 25, 2022

PR #23 should have solved this issue, @adr1200c can you verify this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants