I’ve a few items that I want to check if I turned them ON/OFF using Google Asisstant it is possible to know how I turn on the switch VIA the Basic UI, or with Google Assistant?
I need to check this because I want to do when I turn on any item it will say the item status, example I turned on the lights, if I made it from the Basic UI - ‘say(“Lights ON”)’ just for example…
2nd question:
I’ve a few Xiaomi Window/Door sensor, and when I open/close the window, it’s need to do a few thing, the problem is when I Close the window here is what happand (Close,Open,Close) for one second the sensor think it’s open then close it again, I hope with my english I made it clear…
anyway, there is any thing I can do about it? Like time or something?
I tried Approach 3 Proxy Items, And I can’t define where do I turn on the lights, I tried to turn on the lights manually but nothgin pop up, look at my codes, I changed it when I turn on the lights manually it’s need to sms me.
sorry for the messy code
rule “Light control received command”
when
Member of LightControls received command
then
// Get access to all the relevant Items
val lightName = triggeringItem.name.split("").get(0)
val source = triggeringItem.name.split("").get(1)
val proxy = LightControls.members.findFirst[ l | l.name == lightName + "_Proxy" ]
val device = LightControls.members.findFirst[ l | l.name == lightName + "_Device" ]
val ui = LightControls.members.findFirst[ l | l.name == lightName + "_UI" ]
val rules = LightControls.members.findFirst[ l | l.name == lightName + "_Rules" ]
// The Proxy Item should never receive a command
if(source == "Proxy") {
logWarn("light", "Received command on " + triggeringItem.name + ", this should not occur, ignoring.")
return;
}
// When a command comes in from any source not the Device, a command gets sent to the Device
// This let's us skip this command so we don't end up in an infinite loop.
if(source == "Device") {
Thread::sleep(50) // experiment, may not be needed, may need to be longer, give the Item registry time to update the proxy
if(receivedCommand == proxy.state) return;
}
// Detect whether the light was triggered manually or automatically and do what needs to be done
if(source == "Device" || source == "UI") {
sendBroadcastNotification("This done manually from the wall")
}
else {
sendBroadcastNotification("This done from Google or UI")
}
// Forward the new state to those Items that are not already in the new state. Use sendCommand
// for the device so the light actually turns on/off.
if(proxy.state != receivedCommand) proxy.postUpdate(receivedCommand)
if(ui.state != receivedCommand) ui.postUpdate(receivedCommand)
if(rules.state != receivedCommand) rules.postUpdate(receivedCommand)
if(device.state != receivedCommand device.sendCommand(receivedCommand
end
rule “Change the light”
when
Item mlight received update
then
HallLight_Rules.sendCommand(ON) // always use the Rules Item to send commands in your Rules
// some code