This commit is contained in:
parent
db17b68e90
commit
5333d8042f
|
@ -88,7 +88,9 @@ impl GoogleHome {
|
||||||
.map(|device| device.id)
|
.map(|device| device.id)
|
||||||
.map(|id| async move {
|
.map(|id| async move {
|
||||||
// NOTE: Requires let_chains feature
|
// 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
|
device.query().await
|
||||||
} else {
|
} else {
|
||||||
let mut device = query::Device::new();
|
let mut device = query::Device::new();
|
||||||
|
@ -135,7 +137,9 @@ impl GoogleHome {
|
||||||
.map(|id| {
|
.map(|id| {
|
||||||
let execution = command.execution.clone();
|
let execution = command.execution.clone();
|
||||||
async move {
|
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() {
|
if !device.is_online() {
|
||||||
return (id, Ok(false));
|
return (id, Ok(false));
|
||||||
}
|
}
|
||||||
|
@ -148,9 +152,8 @@ impl GoogleHome {
|
||||||
|
|
||||||
// Convert vec of results to a result with a vec and the first
|
// Convert vec of results to a result with a vec and the first
|
||||||
// encountered error
|
// encountered error
|
||||||
let results = results
|
let results =
|
||||||
.into_iter()
|
results.into_iter().collect::<Result<Vec<_>, ErrorCode>>();
|
||||||
.collect::<Result<Vec<_>, ErrorCode>>();
|
|
||||||
|
|
||||||
// TODO: We only get one error not all errors
|
// TODO: We only get one error not all errors
|
||||||
if let Err(err) = results {
|
if let Err(err) = results {
|
||||||
|
|
|
@ -181,7 +181,9 @@ impl OnMqtt for ContactSensor {
|
||||||
let mut light = light.write().await;
|
let mut light = light.write().await;
|
||||||
if !previous {
|
if !previous {
|
||||||
// If the timeout is zero just turn the light off directly
|
// 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();
|
light.set_on(false).await.ok();
|
||||||
} else if let Some(light) = As::<dyn Timeout>::cast_mut(light.as_mut()) {
|
} else if let Some(light) = As::<dyn Timeout>::cast_mut(light.as_mut()) {
|
||||||
light.start_timeout(trigger.timeout).await.unwrap();
|
light.start_timeout(trigger.timeout).await.unwrap();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user