diff options
| author | diogo464 <[email protected]> | 2025-12-07 15:57:17 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-12-07 15:57:17 +0000 |
| commit | 28d9961141a38ebde8bd6144636c3021eb2755a5 (patch) | |
| tree | f33f300157b50f1ebfe7af7d8630d8fcc7537a04 /examples | |
| parent | 42c899931074fc1a8adcf30e4bd103163ee84b1a (diff) | |
code style change
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/binary_sensor.rs | 7 | ||||
| -rw-r--r-- | examples/button.rs | 6 | ||||
| -rw-r--r-- | examples/number.rs | 7 | ||||
| -rw-r--r-- | examples/sensor.rs | 10 | ||||
| -rw-r--r-- | examples/switch.rs | 7 |
5 files changed, 21 insertions, 16 deletions
diff --git a/examples/binary_sensor.rs b/examples/binary_sensor.rs index 27cfdb5..a52a5fb 100644 --- a/examples/binary_sensor.rs +++ b/examples/binary_sensor.rs | |||
| @@ -11,7 +11,7 @@ static RESOURCES: StaticCell<embassy_ha::DeviceResources> = StaticCell::new(); | |||
| 11 | async fn main_task(spawner: Spawner) { | 11 | async fn main_task(spawner: Spawner) { |
| 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); | 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); |
| 13 | 13 | ||
| 14 | let mut device = embassy_ha::Device::new( | 14 | let mut device = embassy_ha::new( |
| 15 | RESOURCES.init(Default::default()), | 15 | RESOURCES.init(Default::default()), |
| 16 | embassy_ha::DeviceConfig { | 16 | embassy_ha::DeviceConfig { |
| 17 | device_id: "example-device-id", | 17 | device_id: "example-device-id", |
| @@ -21,7 +21,8 @@ async fn main_task(spawner: Spawner) { | |||
| 21 | }, | 21 | }, |
| 22 | ); | 22 | ); |
| 23 | 23 | ||
| 24 | let sensor = device.create_binary_sensor( | 24 | let sensor = embassy_ha::create_binary_sensor( |
| 25 | &device, | ||
| 25 | "binary-sensor-id", | 26 | "binary-sensor-id", |
| 26 | embassy_ha::BinarySensorConfig { | 27 | embassy_ha::BinarySensorConfig { |
| 27 | common: embassy_ha::EntityCommonConfig { | 28 | common: embassy_ha::EntityCommonConfig { |
| @@ -34,7 +35,7 @@ async fn main_task(spawner: Spawner) { | |||
| 34 | 35 | ||
| 35 | spawner.must_spawn(binary_sensor_class(sensor)); | 36 | spawner.must_spawn(binary_sensor_class(sensor)); |
| 36 | 37 | ||
| 37 | device.run(&mut stream).await.unwrap(); | 38 | embassy_ha::run(&mut device, &mut stream).await.unwrap(); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | #[embassy_executor::task] | 41 | #[embassy_executor::task] |
diff --git a/examples/button.rs b/examples/button.rs index e3d7086..4a2a228 100644 --- a/examples/button.rs +++ b/examples/button.rs | |||
| @@ -10,7 +10,7 @@ static RESOURCES: StaticCell<embassy_ha::DeviceResources> = StaticCell::new(); | |||
| 10 | async fn main_task(spawner: Spawner) { | 10 | async fn main_task(spawner: Spawner) { |
| 11 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); | 11 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); |
| 12 | 12 | ||
| 13 | let mut device = embassy_ha::Device::new( | 13 | let mut device = embassy_ha::new( |
| 14 | RESOURCES.init(Default::default()), | 14 | RESOURCES.init(Default::default()), |
| 15 | embassy_ha::DeviceConfig { | 15 | embassy_ha::DeviceConfig { |
| 16 | device_id: "example-device-id", | 16 | device_id: "example-device-id", |
| @@ -20,11 +20,11 @@ async fn main_task(spawner: Spawner) { | |||
| 20 | }, | 20 | }, |
| 21 | ); | 21 | ); |
| 22 | 22 | ||
| 23 | let button = device.create_button("button-sensor-id", embassy_ha::ButtonConfig::default()); | 23 | let button = embassy_ha::create_button(&device, "button-sensor-id", embassy_ha::ButtonConfig::default()); |
| 24 | 24 | ||
| 25 | spawner.must_spawn(button_task(button)); | 25 | spawner.must_spawn(button_task(button)); |
| 26 | 26 | ||
| 27 | device.run(&mut stream).await.unwrap(); | 27 | embassy_ha::run(&mut device, &mut stream).await.unwrap(); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | #[embassy_executor::task] | 30 | #[embassy_executor::task] |
diff --git a/examples/number.rs b/examples/number.rs index 2231be1..8ef6656 100644 --- a/examples/number.rs +++ b/examples/number.rs | |||
| @@ -11,7 +11,7 @@ static RESOURCES: StaticCell<embassy_ha::DeviceResources> = StaticCell::new(); | |||
| 11 | async fn main_task(spawner: Spawner) { | 11 | async fn main_task(spawner: Spawner) { |
| 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); | 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); |
| 13 | 13 | ||
| 14 | let mut device = embassy_ha::Device::new( | 14 | let mut device = embassy_ha::new( |
| 15 | RESOURCES.init(Default::default()), | 15 | RESOURCES.init(Default::default()), |
| 16 | embassy_ha::DeviceConfig { | 16 | embassy_ha::DeviceConfig { |
| 17 | device_id: "example-device-id", | 17 | device_id: "example-device-id", |
| @@ -21,7 +21,8 @@ async fn main_task(spawner: Spawner) { | |||
| 21 | }, | 21 | }, |
| 22 | ); | 22 | ); |
| 23 | 23 | ||
| 24 | let number = device.create_number( | 24 | let number = embassy_ha::create_number( |
| 25 | &device, | ||
| 25 | "number-id", | 26 | "number-id", |
| 26 | embassy_ha::NumberConfig { | 27 | embassy_ha::NumberConfig { |
| 27 | common: embassy_ha::EntityCommonConfig { | 28 | common: embassy_ha::EntityCommonConfig { |
| @@ -40,7 +41,7 @@ async fn main_task(spawner: Spawner) { | |||
| 40 | 41 | ||
| 41 | spawner.must_spawn(number_task(number)); | 42 | spawner.must_spawn(number_task(number)); |
| 42 | 43 | ||
| 43 | device.run(&mut stream).await.unwrap(); | 44 | embassy_ha::run(&mut device, &mut stream).await.unwrap(); |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | #[embassy_executor::task] | 47 | #[embassy_executor::task] |
diff --git a/examples/sensor.rs b/examples/sensor.rs index 69bd87a..2fd2d1f 100644 --- a/examples/sensor.rs +++ b/examples/sensor.rs | |||
| @@ -11,7 +11,7 @@ static RESOURCES: StaticCell<embassy_ha::DeviceResources> = StaticCell::new(); | |||
| 11 | async fn main_task(spawner: Spawner) { | 11 | async fn main_task(spawner: Spawner) { |
| 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); | 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); |
| 13 | 13 | ||
| 14 | let mut device = embassy_ha::Device::new( | 14 | let mut device = embassy_ha::new( |
| 15 | RESOURCES.init(Default::default()), | 15 | RESOURCES.init(Default::default()), |
| 16 | embassy_ha::DeviceConfig { | 16 | embassy_ha::DeviceConfig { |
| 17 | device_id: "example-device-id", | 17 | device_id: "example-device-id", |
| @@ -21,7 +21,8 @@ async fn main_task(spawner: Spawner) { | |||
| 21 | }, | 21 | }, |
| 22 | ); | 22 | ); |
| 23 | 23 | ||
| 24 | let temperature_sensor = device.create_sensor( | 24 | let temperature_sensor = embassy_ha::create_sensor( |
| 25 | &device, | ||
| 25 | "random-temperature-sensor-id", | 26 | "random-temperature-sensor-id", |
| 26 | embassy_ha::SensorConfig { | 27 | embassy_ha::SensorConfig { |
| 27 | common: embassy_ha::EntityCommonConfig { | 28 | common: embassy_ha::EntityCommonConfig { |
| @@ -35,7 +36,8 @@ async fn main_task(spawner: Spawner) { | |||
| 35 | }, | 36 | }, |
| 36 | ); | 37 | ); |
| 37 | 38 | ||
| 38 | let humidity_sensor = device.create_sensor( | 39 | let humidity_sensor = embassy_ha::create_sensor( |
| 40 | &device, | ||
| 39 | "random-humidity-sensor-id", | 41 | "random-humidity-sensor-id", |
| 40 | embassy_ha::SensorConfig { | 42 | embassy_ha::SensorConfig { |
| 41 | common: embassy_ha::EntityCommonConfig { | 43 | common: embassy_ha::EntityCommonConfig { |
| @@ -52,7 +54,7 @@ async fn main_task(spawner: Spawner) { | |||
| 52 | spawner.must_spawn(random_temperature_task(temperature_sensor)); | 54 | spawner.must_spawn(random_temperature_task(temperature_sensor)); |
| 53 | spawner.must_spawn(random_humidity_task(humidity_sensor)); | 55 | spawner.must_spawn(random_humidity_task(humidity_sensor)); |
| 54 | 56 | ||
| 55 | device.run(&mut stream).await.unwrap(); | 57 | embassy_ha::run(&mut device, &mut stream).await.unwrap(); |
| 56 | } | 58 | } |
| 57 | 59 | ||
| 58 | #[embassy_executor::task] | 60 | #[embassy_executor::task] |
diff --git a/examples/switch.rs b/examples/switch.rs index 67767d7..0158ede 100644 --- a/examples/switch.rs +++ b/examples/switch.rs | |||
| @@ -11,7 +11,7 @@ static RESOURCES: StaticCell<embassy_ha::DeviceResources> = StaticCell::new(); | |||
| 11 | async fn main_task(spawner: Spawner) { | 11 | async fn main_task(spawner: Spawner) { |
| 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); | 12 | let mut stream = AsyncTcp::connect(std::env!("MQTT_ADDRESS")); |
| 13 | 13 | ||
| 14 | let mut device = embassy_ha::Device::new( | 14 | let mut device = embassy_ha::new( |
| 15 | RESOURCES.init(Default::default()), | 15 | RESOURCES.init(Default::default()), |
| 16 | embassy_ha::DeviceConfig { | 16 | embassy_ha::DeviceConfig { |
| 17 | device_id: "example-device-id", | 17 | device_id: "example-device-id", |
| @@ -21,7 +21,8 @@ async fn main_task(spawner: Spawner) { | |||
| 21 | }, | 21 | }, |
| 22 | ); | 22 | ); |
| 23 | 23 | ||
| 24 | let switch = device.create_switch( | 24 | let switch = embassy_ha::create_switch( |
| 25 | &device, | ||
| 25 | "switch-id", | 26 | "switch-id", |
| 26 | embassy_ha::SwitchConfig { | 27 | embassy_ha::SwitchConfig { |
| 27 | common: embassy_ha::EntityCommonConfig { | 28 | common: embassy_ha::EntityCommonConfig { |
| @@ -34,7 +35,7 @@ async fn main_task(spawner: Spawner) { | |||
| 34 | 35 | ||
| 35 | spawner.must_spawn(switch_task(switch)); | 36 | spawner.must_spawn(switch_task(switch)); |
| 36 | 37 | ||
| 37 | device.run(&mut stream).await.unwrap(); | 38 | embassy_ha::run(&mut device, &mut stream).await.unwrap(); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | #[embassy_executor::task] | 41 | #[embassy_executor::task] |
