bambu

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudMQTTBroker

func CloudMQTTBroker() string

CloudMQTTBroker returns the cloud MQTT broker address for the given region.

Types

type CloudClient

type CloudClient struct {
	// contains filtered or unexported fields
}

CloudClient handles communication with the Bambu Cloud API.

func NewCloudClient

func NewCloudClient() *CloudClient

NewCloudClient creates a new Bambu Cloud API client.

func (*CloudClient) GetDevices

func (c *CloudClient) GetDevices(token string) ([]CloudDevice, error)

GetDevices fetches the list of printers bound to the account.

func (*CloudClient) GetUsername

func (c *CloudClient) GetUsername(token string) (string, error)

GetUsername fetches the MQTT username (uid) from user preferences. Returns the username in format "u_{uid}".

func (*CloudClient) Login

func (c *CloudClient) Login(email, password string) (*LoginResponse, error)

Login authenticates with Bambu Cloud using email and password. Returns the login response. If LoginType is "verifyCode", the caller must request a verification code and call LoginWithCode.

func (*CloudClient) LoginWithCode

func (c *CloudClient) LoginWithCode(email, code string) (*LoginResponse, error)

LoginWithCode completes login using email and verification code.

func (*CloudClient) RefreshToken

func (c *CloudClient) RefreshToken(refreshToken string) (*LoginResponse, error)

RefreshToken uses the refresh token to get a new access token.

func (*CloudClient) RequestVerifyCode

func (c *CloudClient) RequestVerifyCode(email string) error

RequestVerifyCode requests a verification code to be sent via email.

type CloudDevice

type CloudDevice struct {
	DevID          string  `json:"dev_id"`
	Name           string  `json:"name"`
	Online         bool    `json:"online"`
	PrintStatus    string  `json:"print_status"`
	DevModelName   string  `json:"dev_model_name"`
	DevProductName string  `json:"dev_product_name"`
	DevAccessCode  string  `json:"dev_access_code"`
	NozzleDiameter float64 `json:"nozzle_diameter"`
}

CloudDevice represents a printer from the Bambu cloud device list.

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
	ExpiresIn    int    `json:"expiresIn"`
	LoginType    string `json:"loginType"` // "", "verifyCode", "tfa"
}

LoginResponse represents the response from the Bambu login API.

type UserPreference

type UserPreference struct {
	UID json.Number `json:"uid"`
}

UserPreference holds user info including the UID needed for MQTT. The uid field comes back as a JSON number from the Bambu API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL