Home Automation Complex Routine

Hi All,

I’ve been doing some home automation and need some help from the pros.
I use Alexa as my ecosystem.
I’ve got a motion sensor Tuya on the front door when it detects motion it turns on the hallway lights. I’ve set it as it turns off after 5 mins.

Now the hard part. If I request Alexa to turn on the lights by voice or switch hallway lights manually after detecting motion the lights turns off after 5 mins.

I want a Boolean code of if - else or. For example if my lights are manually turned on then motion sensor will not kick in to turn off lights. Or with voice commands or manual switch I can overwrite the motion sensor.

Comments

  • I'm not too sure about these things, but would it be easier to get the whole sequence to not run if the light is already on? So if hallway light is off and motion is detected then turn on the hallway light and turn off after 5 mins?

    • This is totally not what the dude wants. Stay tuned. I am also very interested in this …

  • +2

    Not sure about Alexa, but with Home Assistant, it works like this:

    1st Automation (Light activated by motion detection)
    Trigger: motion detected
    Actions: turn on light, wait 5 mins, turn off light.
    Condition for the trigger: Light is not on.

    2nd Automation (Light activated by command)
    Trigger: Voice, Manual Switch
    Actions: Turn on light
    Condition for the trigger: Light is not on

    3rd Automation (Light switched off by command)
    Trigger: Voice, Manual Switch
    Actions: Turn off light
    Condition for the trigger: Light is on

    • Silly question is Hone Assistant an app or an ecosystem like Alexa? Home Assistant = Apple if yes I don’t have Apple speakers.

      • Home Assistant is an open source system. Was giving you an idea of the logic needed.

  • Home assistant is always the answer !.

  • Ozbargain, where the home automation experts dwell!

    But on a more serious note, why are you asking here VS. In a dedicated subreddit or product forums where they would actually know more?

  • The new version of Chat GPT (4o) says:

    To achieve the desired behavior with your home automation setup, you need to create a conditional routine that checks whether the lights were turned on manually or by voice command and bypasses the motion sensor's timer if they were. Here’s a step-by-step guide to achieve this using Alexa routines and possibly some custom Alexa skills or scripts:

    Step 1: Set Up Your Motion Sensor Routine
    Create a Routine in Alexa:
    Go to the Alexa app.
    Tap on the More menu and select Routines.
    Tap the + button to create a new routine.
    Set the trigger to be the motion detected by your Tuya motion sensor.
    Add an action to turn on the hallway lights.
    Add a wait action for 5 minutes.
    Add an action to turn off the hallway lights.
    Step 2: Create a Manual Override
    To distinguish between the lights being turned on manually (voice or switch) versus by motion, we need to introduce a virtual switch or variable that can be used to track the state.

    Create a Virtual Switch:

    Use a platform like SmartThings, Hubitat, or another home automation system that integrates with Alexa and supports virtual switches.
    Create a virtual switch called "Manual Override".
    Integrate the Virtual Switch with Alexa:

    Ensure the virtual switch is discoverable in Alexa (you might need to enable the skill corresponding to your home automation hub).
    Step 3: Update Your Alexa Routines
    Routine for Motion Sensor:

    Edit your existing motion sensor routine.
    Before turning on the hallway lights, add a condition to check if the Manual Override switch is off. If it's on, skip the routine.
    Routine for Manual Activation:

    Create a new routine triggered by a voice command like "Alexa, turn on the hallway lights".
    Add actions to turn on the hallway lights and turn on the Manual Override switch.
    Routine for Turning Off Manually:

    Create another routine triggered by turning off the hallway lights manually.
    Add actions to turn off the hallway lights and turn off the Manual Override switch.
    Step 4: Custom Skill or Script (if needed)
    If your home automation hub supports scripting or custom skills, you can write a script to handle the logic.

    Custom Script (Example in Pseudocode):
    python
    Copy code
    if motion_detected:
    if manual_override == False:
    turn_on_hallway_lights()
    wait(5 minutes)
    turn_off_hallway_lights()

    Summary
    This setup ensures that the motion sensor will not turn off the hallway lights if they were turned on manually or by voice command, thus giving you the flexibility you need. The key elements are the creation of a virtual switch to track manual overrides and updating the routines to check the state of this switch.

    • Wow thank you so much. I’m using Smart Life and automation are discoverable in Alexa. Will this work?
      I’ll give it a go tonight when I’m back home.

      • No idea. But I pay for Chat GPT premium and they have their new model out, so I fed it your question. Chat GPT is often wrong. But it's often right. Just note that it gave pseudocode. It's perfectly capable of writing Python though if you ask it.

  • @AustriaBargain I’ve done everything as per the instructions but ChatGPT fails as there’s no way in Alexa to set a precondition to set before triggering the motion sensor. This is just weird. Why can’t Alexa or even Smart Life set a simple algorithm before checking the status of motion sensor.

    If the hallway lights are on manually or by Alexa voice the motion sensor will not execute the lights. It’s easy… how can I make this possible?

    “ Edit your existing motion sensor routine.
    Before turning on the hallway lights, add a condition to check if the Manual Override switch is off. If it's on, skip the routine.”

    • ChatGPT suggests a combination of Virtual Switch, Alexa Routines, IFTTT, and Webhook using AWS Lambda. Might be more trouble than it's worth even if it works.

      • Ya. I’m thinking how come Alexa or Smart Life or Tuya can’t do this simple precondition checks?
        Apple Home Assist has those precondition checks (I think).

        I hope someone can share some light here

        • What if instead of turning them off and, after five minutes they just go really dim. And when motion detected, full brightness. So they'd never be turned fully off. LED bulbs can't use that much power especially at low brightness yeah? Wouldn't solve your problem but would be a bit more elegant, especially if it smoothly transitions between dim and full brightness and back again.

          • @AustriaBargain: Thanks mate I thought of it but I got few problems with it. Only the smart 3 switch gang was changed but the lights are old spot lights (halogen). I have to change them but need an electrician who quoted us $30 per spot light to led spot light with au plug.

            I gave up on Alexa at the moment. I’m trying to figure out in Smart Life how it was be done.

            Tbh ChatGPT came up with a great solution but it forgot to check the Alexa capabilities and predicted Alexa has those features.

  • You will not be able do such thing with alexa, siri or dumb google. Only home assistant and similar commercial hub like hubitat can let you customise it that far.

    • Thank you mate. I never knew I’m growing into complex solutions until now.

      What’s home assistant or Hubitat? Just wondering how much will it take if I upgrade to those ecosystem ? I searched in Amazon couldn’t find Hubitat.

      This certainly opens a new window into my smart home.

      • Home assistant is sort of a network server that collects all smart communications between your devices, present it on a single dashboard and allow you to cross communicate between them and using automation to control complex behaviour. Currently there are just too many brands doing their own ecosystem and allow limited cross platform support. Home assistant solves the issue mostly because the large amount of third party integration it support and the large support community behind it. Hubitat and others are similar but proprietary in nature so it's more exxy.

        • Thanks mate. I was really surprised to see our dumb Alexa Smart Life Google or Apple doesn’t even know how to check if the light is on and if it’s on do the next steps.

          To me it’s a deal breaker for any home automation ecosystem. I wish I knew this before investing in all smart lights motion sensor etc.

          I’ll need to start studying on Hubitat and other things.

Login or Join to leave a comment