Fixed formatting
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Dreaded_X 2023-11-17 01:10:45 +01:00
parent db17b68e90
commit 5333d8042f
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
3 changed files with 88 additions and 83 deletions

View File

@ -88,7 +88,9 @@ impl GoogleHome {
.map(|device| device.id)
.map(|id| async move {
// NOTE: Requires let_chains feature
let device = if let Some(device) = devices.get(id.as_str()) && let Some(device) = device.read().await.as_ref().cast() {
let device = if let Some(device) = devices.get(id.as_str())
&& let Some(device) = device.read().await.as_ref().cast()
{
device.query().await
} else {
let mut device = query::Device::new();
@ -135,7 +137,9 @@ impl GoogleHome {
.map(|id| {
let execution = command.execution.clone();
async move {
if let Some(device) = devices.get(id.as_str()) && let Some(device) = device.write().await.as_mut().cast_mut() {
if let Some(device) = devices.get(id.as_str())
&& let Some(device) = device.write().await.as_mut().cast_mut()
{
if !device.is_online() {
return (id, Ok(false));
}
@ -148,9 +152,8 @@ impl GoogleHome {
// Convert vec of results to a result with a vec and the first
// encountered error
let results = results
.into_iter()
.collect::<Result<Vec<_>, ErrorCode>>();
let results =
results.into_iter().collect::<Result<Vec<_>, ErrorCode>>();
// TODO: We only get one error not all errors
if let Err(err) = results {

View File

@ -181,7 +181,9 @@ impl OnMqtt for ContactSensor {
let mut light = light.write().await;
if !previous {
// If the timeout is zero just turn the light off directly
if trigger.timeout.is_zero() && let Some(light) = As::<dyn OnOff>::cast_mut(light.as_mut()) {
if trigger.timeout.is_zero()
&& let Some(light) = As::<dyn OnOff>::cast_mut(light.as_mut())
{
light.set_on(false).await.ok();
} else if let Some(light) = As::<dyn Timeout>::cast_mut(light.as_mut()) {
light.start_timeout(trigger.timeout).await.unwrap();