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

[FEATURE]: Two stromers under the same id #81

Open
aq18507 opened this issue Feb 2, 2024 · 24 comments
Open

[FEATURE]: Two stromers under the same id #81

aq18507 opened this issue Feb 2, 2024 · 24 comments
Labels
enhancement New feature or request

Comments

@aq18507
Copy link

aq18507 commented Feb 2, 2024

Describe the bug.

Thanks for developing this fantastic integration. We have both of our stromers on the same ID. I am wondering first of all, whether it is possible to add them both using the integration. If not, this might be an additional useful feature to add to this already great app.
Thanks very much already.

What version of Home Assistant Core has the issue?

2024.1.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

How did you install the stromer integration

HACS

Logging

No response

Diagnostics information

No response

Additional information

No response

@aq18507 aq18507 added the bug Something isn't working label Feb 2, 2024
@CoMPaTech
Copy link
Owner

Seems to make sense, I would assume just 'multiple bike id's present but never looked for them. I'll get back to you on it.

@aq18507
Copy link
Author

aq18507 commented Feb 2, 2024

Fantastic, thanks so much. It must clearly broadcast both of them since I previously used a script running on AppDeamon with the same login credentials, and I was pulling the data from the other bike.

@CoMPaTech CoMPaTech added enhancement New feature or request and removed bug Something isn't working labels Feb 3, 2024
@CoMPaTech
Copy link
Owner

Trying a very preliminary in #82 just to test the waters (i.e. not breaking existing setups) as it's a bit more of a hassle than just iterating multiple times + not sure if the config_flow still works properly. It will probably take some time/iterations before it's in a usable form :)

@CoMPaTech
Copy link
Owner

I see I just use data[0] for the bike(s) retrieval, so that is/was probably the culprit and ensuring only the first bike's data is there.

@aq18507
Copy link
Author

aq18507 commented Feb 3, 2024

Amazing! I am not really using the integration at the moment so if you like I can test and give you some feedback (you might have to instruct me how to do this though as I have never done it before)

@CoMPaTech
Copy link
Owner

CoMPaTech commented Feb 3, 2024

Sure, highly appreciated - I'll keep you posted. If you already have (it installed through) HACS it's only a matter of enabling beta downloads - but don't install any of the v0.4.xx yet, not sure how broken it is. (Yes, have done multi-device before but trying to cut some corners preventing a lot of additional work - that might bite)

ps I do have a separate instance for testing which makes it easier to make FUs which I'd rather not have on other peoples systems/data :)

@aq18507
Copy link
Author

aq18507 commented Feb 3, 2024

You are more than welcome. It is a good idea to start my own test instance to play around. I shall do that tomorrow and will report back in due course.

@CoMPaTech
Copy link
Owner

Adjusted the approach, basic idea I'm trying to cook up now is 'add integration Stromer' => ask for credentials (mail/password/client-id) => show available bikes and select one. A little more work for multi-stromer users, but I would guess do-able :) (You'll have to add it twice but this should ensure not too much changes for existing users).

The below would become a list (or just single bike in my case) displaying your bike id number and the nickname you gave it
Scherm­afbeelding 2024-02-04 om 15 19 48
Not sure if I can make it neater, but if I recall correctly lists in config_flow used to be tricky. I'll try from here to make it workable, but wanted to share progress.

@aq18507
Copy link
Author

aq18507 commented Feb 4, 2024

Sorry for the belated reply I was caught up with doing something else. I have now spun up a test instance and enrolled to the beta testing on your github repo. When I looked at your code (I am very much a Matlab coder and not at all proficient with python) I was thinking whether this would potentially be a solution to reduce the complexity. I guess that extra work might only apply to those weirdoes few (like myeslef and my partner) who share an account anyway.

Let me know when you want me to give it a try.

@CoMPaTech
Copy link
Owner

No worries, it's all life that gets in the way, I had some time to spare so tinkered something, it might be that v0.4.0a2 is do-able in the approach I outlined above. Just waiting for code checks to kick in and report back and re-install this on my dev machine (I was actually just tinkering there to get it done and shuffling it back into git now).

@aq18507
Copy link
Author

aq18507 commented Feb 4, 2024

Fantastic. I shall watch out for any version change and will give it a go.

@CoMPaTech
Copy link
Owner

v0.4.0a2 seems to function (at least on a single bike) when adding it as a new integration - didn't tinker with it on existing bike implementation, guessing it takes some additional work. #note2self, probably detect single bike or existing unique-id and work from there

If you HACS -> Integrations -> Stromer and right top click the dots to 'Re-download' (or something likewise) you can toggle 'beta' on, that should show you said version.

What it will do is ask for mail/password/clientv4-id and when clicking next should show you bike or bikes, ticking a bike should add that bike. Note that adding the bike takes some time before it asks you 'which room' to put it in - the API is not the fastest in the world as you probably already experienced with the dashboard.
You would have to redo that for the other bike - hopefully it tinkers the whole way through and fetch accordingly.

@aq18507
Copy link
Author

aq18507 commented Feb 4, 2024

It worked perfectly for both of them. It is indeed not very fast, which is also reflected in the Stromer App performance. All the information it fetched seems correct to me as far as I can tell. Overall the installation process isn't that much more complicated apart from the selection menu during the installation process.

The only obvious difference between the non-beta version is that the device info and connected device tab of the UI is now listed as an unnamed device, whereas before, it was listed as the Stromer bike name. That said it has pulled through the bike name correctly in the devices list.
Screenshot 2024-02-04 at 19 18 11
Screenshot 2024-02-04 at 19 22 29

@CoMPaTech
Copy link
Owner

Will look into that (not today though) - thanks for the feedback and confirming it primarily functions :-) I think I have to tinker something for existing as well though, the unique name used to be stromerbike - it should now be stromerbike-{bike_id} - not sure if I write some if statements for single bikes or properly do a migration yet. I'll report back on progress!

@aq18507
Copy link
Author

aq18507 commented Feb 4, 2024

I see; I was wondering what that was referring to. Reading other people's code is a very good learning exercise. Let me know about the progress, and I will, of course, give you as much feedback as possible - and in the meantime, I shall enjoy the beta version.

@CoMPaTech
Copy link
Owner

Just reporting no intermediate progress; not sure why it would do the naming differently (if you look through the PR code changes, I thought it was the title= lines, but I should have accommodated for that. I'll try and seek for some time this week.

@GoodbyeHarmony
Copy link

Hi very much a beginner here with Home Assistant, but I got my ID tonight and I'd just like to add my voice to the folks asking you to enable solutions for two stromers. This is a fantastic thing with great potential.

Thanks so much, really appreciate your work. If I can help with testing, happy to do so!

@CoMPaTech
Copy link
Owner

Hi @GoodbyeHarmony - it's not fully ready as per @aq18507's comment above, I've not (yet) found out why it suddenly doesn't connect to itself as a Device, probably destroyed something with looping over it, but if you aren't (too) scared to run beta you could already install it and give it a whirl

I.e. the unnamed device thingy:
stromer-ha

@CoMPaTech
Copy link
Owner

For some reason the PR doesn't set "name_by_user" correctly - which would make sense to display the bikes nickname and ask how one would like to call it. Should still look into this, but I can confirm the device registry for that key is at null unfortunately.

@GoodbyeHarmony
Copy link

GoodbyeHarmony commented Mar 5, 2024

It works really well. Been playing a few days now and just watching my fully charged ST5 (switched on) lose charge naturally whilst my ST3 is on charge.

One thing that would be useful but I doubt Stromer provide is an indication that the bike is charging, or on charge. But this is top class work and deeply impressive I must say.

Thank you so much!

@CoMPaTech
Copy link
Owner

Glad it works for both of you, still that annoying device thing to get rid of ... I'll have a look if I can find charging, but I do believe it shuts down communication or anything when charging, the way I do it; I have a smart plug that I can hit locally in the shed to start charging and actually when not using the bike I sort of (by measuring/timing) shut it off at a certain Wattage to not 100% charge ... the same happens when I do want to charge 100% but than differently, if Wattage falls below a value, shutdown the charger.

@jaydubdub54
Copy link

Me Three? - Thank you for your work on this. I thought I was losing my mind when I added a second Stromer last month (so did my wife but that’s a different story). Is it possible for me to join the beta testing as well?

@CoMPaTech
Copy link
Owner

Yeah sure. Still need todo some work to clean it up with us poor single bike owners 😀
And the trip reset issue

But feel free to join, it's not closed. If you go to HACS inside your HA and tick Stromer. Next use the three dots and select download it will present a modal (pop up) with a select for beta. Once you toggle that you can select v0.4.0a2, download and restart and you should be good to go

@jaydubdub54
Copy link

Hey thanks, the beta (v 0.4.0a2) did the trick and now allows my two bikes to be integrated through the API. I now see both bikes in HA. The only caveat is that while the device name displays properly during the device selection process and all the entities are properly name with the first selected device’s name. After that, when adding the second bike or additional bikes (devices) , despite selecting the correct device name, the entities come through named as “none” for the entity name.
Ie
When adding the first device (the bike named Blackhawk) I see
BATTERY
sensor.blackhawk_battery
When adding the second bike I see
BATTERY
sensor.none_battery
And adding the next device I see
BATTERY
sensor.none_battery_2

With only two bikes and knowing which bike is none_battery and which is none_battery_2 I was able to easily edit the entities on my dashboard cards to reflect the correct entity (none or none_2) and use the name field on the card to properly display correct name of the device/entity.

One additional test I did was to delete all the devices and re add them, which is how I discovered additional entities for each newly added device gets the numeric extension at the end of the entity name.

My last observation is that one entity appears to behave differently and actually retains the device name correctly each time the device is added
Ie
BLACKHAWK Location
device_tracker.blackhawk_location

Thanks again for your great work. I love being able to keep an eye on my bikes in HA. I’m also using a Scheduler Card in conjunction with a smart plug on my chargers to evaluate my bikes’ charge each night and keep them automatically charged between 30-70%.

I hope my long winded note makes sense, feel free to reach out if you need any additional clarifications.

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

No branches or pull requests

4 participants