This commit is contained in:
parent
db17b68e90
commit
5333d8042f
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user