Open mherwege opened 2 years ago
I'm not having any trouble with my hardware so I guess I have the old firmware. I don't think anyone else using this project has actually encountered the firmware incompatibility considering there are no issues for it. Were you able to find the firmware version check in the source code of the official app (#12) or do you have any more information on how you know or can differentiate different firmware versions?
The firmware version is visible in the official app (About -> Connector Version). Mine is at 2.0.3.30. The check in the offical app source code looks for the last part and checks if it is above 14 for different logic. When looking at the source of the official app, I have the impression it gets the version from the cloud, and not from local communication. But I have difficulty following it through completely. If it is cloud only to get the version, it obviously is a bummer. I don't want to also implement a cloud communication. There is some other attempt to include Elro in a python library here. It is very incomplete. Notice the 2 different version of the api, but also no check on how to know.
For anyone working on this I've found an example of the check in the code of the app: https://github.com/Siterwell/familywell-lidl-android/blob/40cc44ce13d479af6e774365fde58ae72440b385/branch/lidl/app/src/main/java/me/hekr/sthome/tools/SendCommand.java#L77
So for the new firmware the device id and command id need to be transformed.
I was able to follow the getBinVersion and setBinVersion which gets the version from a database: https://github.com/Siterwell/familywell-lidl-android/blob/40cc44ce13d479af6e774365fde58ae72440b385/branch/lidl/app/src/main/java/me/hekr/sthome/model/modeldb/DeviceDAO.java#L56
Which led me to https://github.com/Siterwell/familywell-lidl-android/blob/40cc44ce13d479af6e774365fde58ae72440b385/branch/lidl/app/src/main/java/me/hekr/sthome/configuration/activity/EsptouchAnimationActivity.java#L269 where it finally does a call to https://user-openapi.hekr.me/device. I wasn't able to successfully call that api but as far as I've found the firmware version is retrieved from the cloud. Maybe you could determine the firmware version from the received messages? Like try and change a device name using the default call and if that fails try the v14+ call? The name of the device could then be set back to the original if one or the other worked.
That is a familiar rabbithole :P, it got me to the point i could interact with the api
$Login = @"
{
"pid" : "01288154146",
"username" : "yourelroregisteredemail",
"password" : "password",
"clientType" : "ANDROID"
}
"@
$LoginURL = 'https://uaa-openapi.hekreu.me/login
$LoginRepsonse = Invoke-RestMethod -Method post -Uri $LoginURL -Body $Login -ContentType "application/json"
Bear in mind that this is some powershell code i used to check if it worked. Also note that i had to use hekreu.me instead of hekr.me.
The firmwarebean file is also interesting because it points somewhat to the firmware of the gateway (the url noted cannot be used though) https://github.com/Siterwell/familywell-lidl-android/blob/6218fdd314a031c4745e71f101061065cc27bbfc/branch/lidl/app/src/main/java/me/hekr/sthome/http/bean/FirmwareBean.java
Upon rereading the EsptouchAnimationActivity.java file it looks like the firmware version will only be reported on the moment it is doing the bind action 🤔
Here you go, this allows you to get the gateway and the binver through the public api
$Login = @"
{
"pid" : "01288154146",
"username" : "mail@mail.com",
"password" : "password",
"clientType" : "ANDROID"
}
"@
$LoginURL = 'https://uaa-openapi.hekreu.me/login'
$LoginRepsonse = Invoke-RestMethod -Method post -Uri $LoginURL -Body $Login -ContentType "application/json"
$Headers = @{
"Authorization" = "Bearer $($LoginRepsonse.access_token)"
"Accept" = "application/json"
}
$x = Invoke-RestMethod -uri "https://user-openapi.hekreu.me/folder/device?page=0&size=10" -method get -Headers $Headers
$x.devicelist
Thank you for figuring this out.
https://user-openapi.hekreu.me/folder/device?page=0&size=10
To directly get the devicelist, you can use the following simpler URI: https://user-openapi.hekreu.me/device
in the last get call.
https://user-openapi.hekreu.me/device
is not returning a list I wonder what happens if you have two K1 connectors.
Here is some indication: https://docs.hekr.me/v4/%E4%BA%91%E7%AB%AFAPI/%E8%AE%BE%E5%A4%87%E7%AE%A1%E7%90%86/#%E8%8E%B7%E5%8F%96%E5%B5%8C%E5%A5%97%E6%A8%A1%E5%BC%8F%E7%9A%84%E8%AE%BE%E5%A4%87%E5%88%97%E8%A1%A8
curl -v -X GET \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Accept: application/json" \
"https://user-openapi.hekr.me/device?devTid=tid1234,tid22,tid55&folderId=fid1234&groupId=gid1234&page=0&size=10"
I've tested this by only providing devTid and not folderId, and it worked
I have been following your code with a lot of interest, as I started a similar exercise to make ElroConnects available to the openHAB world. My most up-to-date code is available on Github here. This is a question and not directly related to your code.
I have noticed there are multiple firmware version of the K1 connector. Many command use a different code for that (100 higher than the basic command). In the app, there is a check for firmware version > 14, but I can't figure out how to get that version. With the hub I am using, I have that higher firmware version, and need these different commands. The commands are then also using another coding. The list of command codes that work for me can be found here: https://github.com/mherwege/openhab-addons/blob/elroconnects_extension/bundles/org.openhab.binding.elroconnects/src/main/java/org/openhab/binding/elroconnects/internal/ElroConnectsBindingConstants.java I would like to make my code more firmware version resilient (and do a firmware version check). Did anyone of you figure out a way to get hold of the firmware version?