rbroadlink
A rust port of the python-broadlink library.
Devices Tested
The following devices have been tested and found to work with this library:
| Model Code | Device Name | Manufacturer | Type |
|---|---|---|---|
| 0x649B | RM4 Pro | Broadlink | Remote |
| 0x4E2A | Ande Jupiter+ | ANG Klimatyzacja Sp. z o.o. | Hvac |
Setup
Before a device can be used, it must be connected to a network. Refer to this link on how to get the device into AP mode, connect to its network (e.g. Broadlink_Device_Wifi), and then run the following code:
use Device;
use WirelessConnection;
// Construct the network information
let network_info = WPA2;
// Connect the device to the specified network
connect_to_network
.expect;
You can also use the included cli to do so:
# Pass the password directly
# Prompt for the password safely
Usage
Devices can either be constructed from a known IP or by local discovery:
use Ipv4Addr;
use Device;
// Create a device by IP
// Note: Devices only support Ipv4 addresses
let known_ip = new;
let device = from_ip
.expect;
// You can also specify the local IP of the machine in the case of the device being
// on a different subnet.
let local_ip = new;
let device_with_local_ip = from_ip
.expect;
// You can also just enumerate all of the discovered devices, with an optional
// local ip as well.
let devices = list
.expect;
Once you have a valid device, you probably want to differentiate the kind of device
that you have. Device is a structured enum that contains different types of devices with
more specialized methods.
use Device;
// Assuming that you have a valid device in `device`...
let remote_device = match device ;
// Use a remote-specific method to echo a learned IR code.
let code = remote_device.learn_ir
.expect;
remote_device.send_code
.expect;
HVAC
Starting from version 0.4.0 of this library the HVAC/Air Conditioners support was added.
Supported devices are broadlink device type 0x4E2A.
Although it was tested on one specific unit, it is very likely that it should work with more similar devices. Those air conditioners are usually controlled with AC Freedom application.
If you have such device connected to the AC Freedom application, then it is surely in a "locked" state (cannot be controlled using this library).
You can control it either from AC Freedom or this library (not both). If you decide to use rbroadlink, then you need to delete the device from AC Freedom cloud, then reset the WiFi dongle and re-configure WiFi parameters again.
You can also head to this post for details: https://github.com/liaan/broadlink_ac_mqtt/issues/76#issuecomment-884763601
Probably configuring the WiFi parameters using this library/rbroadlink-cli should also work (refer to the Setup section above).
A sample snippet for setting target temperature setpoint:
use Device;
// Assuming that you have a valid device in `device`...
let hvac_device = match device ;
// First obtain current state/parameters of the device:
let mut state = hvac_device.get_state.expect;
println!;
// Print current temperature and try to set a new setpoint (degree Celsius)
println!;
if let Err = state.set_target_temp
// Request to set a new state (with new temperature)
hvac_device.set_state;
Examples
There are a few examples of this library present in the examples folder. Refer to
the examples folder README for more info.