greghesp / ha-bambulab

A Home Assistant Integration for Bambu Lab Printers
1.05k stars 93 forks source link

[Feature] Update static list of errors to be loaded dynamically at runtime from bambu API endpoint. #756

Closed AdrianGarside closed 1 week ago

AdrianGarside commented 1 week ago

Describe the feature

Maybe this list doesn't change often enough for this to be worth it. Would want to keep the error list around as a fallback for machines that don't have internet access

What device is this for?

A1

Other Information

No response

AdrianGarside commented 1 week ago

This will also localize them - which makes it worth it.

WolfwithSword commented 1 week ago

Some resources - https://e.bambulab.com/query.php?lang=en

Localization is good, support for quite a few languages (the list doesn't come to mind right now, but I think it's viewable in bambustudio somewhere), but not all languages are supported.

This endpoint also can have custom queries for specific messages.

device_hms is the list that corresponds to HMS codes

device_error corresponds to the print error related stuff that is single-value and is equivalent to whatever the top-level popup notification is most of the time. Not always an error, like hms codes. But value is much shorter and some unique ones exist between the two.

Do note - I have experienced this endpoint being "cloudflared" up and blocked before, but generally not for more than a couple days and has only happened maybe 2-5 times in the past 2 years that I can count.

AdrianGarside commented 1 week ago

"This endpoint also can have custom queries for specific messages." where can I find the format of that?

WolfwithSword commented 1 week ago

https://github.com/bambulab/BambuStudio/blob/bf59a2836158e936279aff2f636415b71185664f/src/slic3r/GUI/HMS.cpp#L55

Query params is usually just the lang, but here you can see an example when an altered code is added to the query params

https://github.com/bambulab/BambuStudio/blob/bf59a2836158e936279aff2f636415b71185664f/src/slic3r/GUI/HMS.cpp#L380 which should get a specific error message

also just noticed there's an image endpoint not for some errors? Wonder since when this was a thing lol

AdrianGarside commented 1 week ago

Well I have it loading localized strings from the web end point - but only using the overall configured language for the home assistant instance. I cannot work out how to localize content differently for individual viewing users. So as long as all users have the same language as the HA instance itself is configured to have it'll be properly localized.

AdrianGarside commented 1 week ago

also just noticed there's an image endpoint not for some errors? Wonder since when this was a thing lol

Yeah, the apps now show a (sometimes) helpful image along with the error.