Manual trigger?

In my old Vera system I had the ability to create a scene with a manual trigger. The scene in Vera is more closely aligned with HA automations than HA scenes because Vera scenes had conditionals.

I want to create an action with a condition and trigger it from my Alexa devices.

For example, I want to say “Alexa, do something cool” and turn on/off a device but only if certain conditions are met.

I was thinking of using a boolean input but then I have to take care of the on/off state of the boolean.

I was able to do this in a script but I was wondering if there was an alternative.

I don’t use Alexa, but I think the idea would be for Alexa to trigger an automation, and include your condition in the automation.

your approach is exactly what I’ve done with my Google Home.
Not sure i’d do it any differently should I have to do it again tbh…

Yes, exactly, but I can’t create an automation without a trigger and there isn’t an Alexa trigger.

Ok, just making sure I wasn’t missing something.

You could use two input booleans.
One for the Trigger and one for the condition.
The boolean for the trigger could be reset by a second automation regardless of the condition.

just wondering why 2 input_booleans? Why not have an automation triggered by the input_boolean, condition with what’s already available and have an action at the end that turns the input_boolean off?

With only one automation you wouldn’t reset the trigger if the condition is false.

The condition could be anything, thought the condition should be a manual one as well.

With only one automation you wouldn’t reset the trigger if the condition is false.

Yes you still could, just make sure you reset your input_boolean before the condition
(yes you can add conditions in your actions :slight_smile: )

Write a script using service_template and put all of your conditions in that, then write an alexa skill that calls that script.

I have this setup to turn tv on and switch to the correct input on the receiver, with the condition to turn the tv on only if it’s off. If the tv is already on, then it just changes input on the amp.

What conditions are you trying to meet for your action to be performed?

Would you please post an example?

I’m unclear what you mean by “Write a script using service_template and put all of your conditions in that”

  alias: play playstation
  - service_template: >
      {% if is_state('binary_sensor.livingroom_tv_status', 'off') %}
      {% endif %}
  - wait_template: "{{ is_state('binary_sensor.livingroom_tv_status', 'on') }}"
  - service: switch.broadlink_send_packet_192_168_1_12

I’m checking for the state of a binary sensor that I have configured to ping the tv to know if it’s on or not, but anything can be substituted inside the if statement. Then inside one of my Alexa actions I have a call to script.turn_on to activate that script.

Here’s a link to how service_templates work

@Rhavin42 Thanks for that!

So if I create the script using the script component Alexa will be able to trigger the script just like a scene or device?

If so, I like this approach much better than writing an actual Python script!

ha ha, yes indeed, use the script component, scripts can be triggered just like switches. I can’t speak to scenes as I’ve never used them, everything in my config is either a light, switch, sensor, script or automation.

When you said ‘script’ in your initial post, I thought you were referring to the script component and not actual Python script. Through all of my messing around with HA I’ve always been able to accomplish what I wanted with the built in components, and have never had the need to write a python script.

What kind of Alexa integration are you doing? are you writing intents i.e. “Alexa [Do Something]” or HA Alexa integration i.e. “Alexa Ask Home Assistant to [Do Something]” the former is a bit more complicated, but uses less words spoken to Alexa as you can omit the ‘Ask Home Assistant’ part. The latter is a bit easier to implement, but can sometimes be a mouthful to say to Alexa.

I am not using intents. I am using Home Assistant Cloud so I can say “Alexa, turn the office light off” and it works.

@Rhavin42 So I added the script using your method and I tested the script by calling it from the services panel. I added it to my Alexa configuration but it is not showing up when I do a Discover from the Alexa website.

I verified on the Alexa page that scripts are supported.

Any suggestions?

Sorry, I’m not going to be much help here. I’m not using HA Cloud. I’m either using the built in hue emulation in order to be able to say “Alexa turn on/off [light name]” these all show up in the Alexa app when I do a discover. Or I’ve got self hosted Alexa Intents (I think that’s the right term.) through HA and Amazon developer website. Where I can say things like “Alexa how’s the pool” and she will respond with the pool temperature from HA, along with some custom flavor text, or “Alexa Bedtime” and she will turn almost everything off if it’s on.

I did it this way because:

  • I didn’t feel like $5/month was worth it for HA cloud when I was pretty sure I could figure it out myself (It was a pain in the ass but I finally got it).

  • For some things that I ask Alexa to do all the time, just being able to say “Alexa [Something]” was shorter than either “Alexa turn on/off [Something]” or “Alexa ask Home Assistant to [Do something]”

  • The kids can never remember the longer Alexa commands, so the shorter I can make them, the more they are able to do with her.

I didn’t know there was going to be a fee. Thanks for the info!

I think I am going to try the Hue Emulation route to see the difference.

I didn’t know there was going to be a fee. Thanks for the info!

I think it’s free for the time being, while it’s still in beta, which was supposed to end Mar 1, 2018, but I guess that got delayed.

I think I am going to try the Hue Emulation route to see the difference.

Lemme know if you need help getting Hue Emulation working and I’ll try to remember how I did it.

So here is my abbreviated configs (sans all my devices)…

    - script
    - scene
  expose_by_default: false
      hidden: false
      hidden: false
      hidden: false

When I go to I see all of my devices except the two scripts.

Any ideas?