Turn off a generic outlet with Alexa/Google Assistant

Hello there,

First of all I am a noob, I don’t have much insight on setting up things with openHAB.

I have an android tv which is connected to a smart plug/outlet, which I can control by Google Assistant and Alexa to trigger ON and OFF.

I would like to automate things a little bit.

I have openHAB 3.2.0 running on a lab machine in my home. This is a docker container on my lab PC’s Alpine Linux.

What I would like to accomplish is, I want to turn off the smart plug when the Android TV turns off. I can get the state of the TV, with either ping or some other implementation. However, this smart plug is a generic one, and can’t be added to openHAB directly.

Can someone offer me a solution to turn off the smart plug by openHAB instruction Alexa/Google Assistant to turn off this.

I have researched for a day, and I have added amazonechocontrol in openHAB, but could not find a way to send text/string to Alexa.

Is it possible to do this via a shell script with curl posting to an URL.

Any help will be much appreciated.

Thanks,
DMJ

Hi
I’m using openhab to control switches via google assistant. However my switches is Z wave and added to Openhab, I also have some ptoxy switches (switches not linked to any channel) jus for triggering my favorites i Yamaha musiccast.

Hence your switches was not able to be recognized by Ooenhab maybe you should have a look at http binding or exec binding if it still exist.

If your tv doesnt have a bindning or other way to post tv status then you could use networkbindning to ping your tv on regular basis.

Hi Marcus,

Thanks much for your reply.

I understand that you are talking about http binding. I am not sure if that’s possible for the switch in question since it may require some sort of authentication which the manufacture does/will not provide.

My doubt was, is there a way to POST to Alexa/Google Assistant a text/string like “Turn off TV” from OH, so that it turns off the switch, like when I talk to Alexa/Google Assistant. If that’s possible, almost all of my problems can be sorted. I am just looking for a simple way to turn off the power. :innocent:

I brief, my need is openhab should speak/instruct(not verbally, but programatically) to Alexa/GA to “Turn off Device”.

Thanks in advance.

If your smart plug is already connected to your Amazon echo, you can use the echo control binding and make the connected devices available in openhab.
There is a discovery option in the thing configuration of your Amazon account thing.

Hello Matthias,

Thanks for the reply.

I am sorry for the noob questions. I have enabled discovery in the Amazon Account thing. However, I cannot see any devices added to amazon account showing up in OH. I could only see AmazonAccount_SendMessage under Model and Items. I was able to send messages to the Echo device.

Do I have to make any additional configuration to get the devices showed up in OH.

Can you point me in the correct direction. Thanks in advance.

I have never used the feature by myself, therefore can only reference to documentation.

Before you see your device within items and model, you first need to discover the thing.

After turning on the discoverSmartHome function wait minimum 10 minutes and you should find the things.
Please also note that there is a difference if the smart plug is directly connected to a echo device (e.g. via Bluetooth, zigbee) or if you are using a skill.

I would recommend to set the discoverSmartHome to 2, than you should not miss something.

If you have your switch visible and working in google assistant I belevie that you schould be able to control it using google binding, set up a switch with correct metadata and you should be able to control your item. I remember setting upp google binding was a bit messy due to different versions of binding and threads in community. But I think you need to expose yout items to cloud instance.

Hi Matthias,

Thanks for the reply. After a slight troubleshooting I luckily found the issue. I was using HTTP instead of HTTPS while working and discovering devices in OH UI. Once I used https://, the device discovery was seamless.

Much thanks for your inputs.

1 Like

Hi Marcus,

Thank you so much for the information. I will definitely try this with Google Assistant too and will update my findings in this thread. As you have mentioned that it is going to be a lil pain, I would play around with the Alexa integration for now.

I don’t know how to thank you guys for your time and input. I am so grateful.