Struct govee_api::GoveeClient
source · pub struct GoveeClient { /* private fields */ }Expand description
A client for interacting with Govee devices through their API.
This struct provides methods to control Govee devices using the Govee API. It requires a valid Govee API key and root URL to initialize.
Implementations§
source§impl GoveeClient
impl GoveeClient
Control a Govee device using the provided payload.
This method sends a PUT request to the Govee API’s control endpoint in order to control a Govee device.
Arguments
payload- The payload containing control instructions for the device.
Returns
Returns Ok(()) if the request is successful. Otherwise, returns a ReqwestError indicating the failure
pub async fn control_device( &self, payload: PayloadBody ) -> Result<(), ReqwestError>
source§impl GoveeClient
impl GoveeClient
Controls a Govee appliance using the provided payload.
This method sends a PUT request to the Govee API to control an appliance with the specified payload. The payload should be in the form of a PayloadBody struct.
Arguments
payload- The payload containing the control instructions for the appliance.
Returns
Returns Ok(()) if the request is successful. Otherwise, returns a ReqwestError indicating the failure
pub async fn control_appliance( &self, payload: PayloadBody ) -> Result<(), ReqwestError>
source§impl GoveeClient
impl GoveeClient
Retrieves a list of Govee devices.
This method sends a GET request to the Govee API to retrieve a list of devices associated with the Govee account.
Returns
An ApiResponseGoveeDevices containing information about the devices.
Returns
Returns Ok(()) if the request is successful. Otherwise, returns a ReqwestError indicating the failure
pub async fn get_devices(&self) -> Result<ApiResponseGoveeDevices, ReqwestError>
source§impl GoveeClient
impl GoveeClient
Retrieves a list of Govee appliances.
This method sends a GET request to the Govee API to retrieve a list of appliances associated with the Govee account.
Returns
An ApiResponseGoveeAppliances containing information about the appliances.
Returns
Returns Ok(()) if the request is successful. Otherwise, returns a ReqwestError indicating the failure
pub async fn get_appliances( &self ) -> Result<ApiResponseGoveeAppliances, ReqwestError>
source§impl GoveeClient
impl GoveeClient
Retrieves the state of a Govee device.
This method sends a GET request to the Govee API to retrieve the state of a specific device.
Arguments
device- The device ID or name.model- The model of the device.
Returns
An ApiResponseGoveeDeviceState containing the current state of the device.
Returns
Returns Ok(()) if the request is successful. Otherwise, returns a ReqwestError indicating the failure