Page 1 of 5 12345 LastLast
Results 1 to 10 of 47

Thread: Voice Control the £20 way

  1. #1
    Automated Home Sr Member
    Join Date
    Aug 2007
    Posts
    53

    Smile Voice Control the £20 way

    Iím fascinated by voice control and the possibilities around using a smart speaker, in my case an Alexa. It would be very easy to buy a bunch of smart plugs & bulbs etc, but then Iíd have two systems, and I love the reliability of Cortex (I still run mine on a Win XP, itís been going over a decade).

    Not having a clue how to integrate the two in a programming way, Iíve gone down the hardware route which I thought Iíd share in case you were interested. (forgive me if you do this already!)

    For £20 I can now control 4 Ďthingsí with my voice! I bought this off Amazon:

    https://www.amazon.co.uk/OWSOO-Wirel...5894427&sr=8-1

    module.jpg

    Itís basically 4 relays that you can control via Wi-Fi. Except you can also control it via an Alexa skill, which means you can set up routines with Alexa and say any words you like to set the routine going. It's powered by an old phone charger.

    Iíve connected the 4 relays to some spare inputs I had on a QRI Din module, told Cortex they are buttons, and anything you can control via a button I can know control with my voice. If I want more than 4 actions, I may buy another, I still have some spare inputs!

    Chris
    Attached Images Attached Images

  2. #2
    Automated Home Guru cliffwright's Avatar
    Join Date
    Mar 2007
    Posts
    112

    Default

    Pre-Context: I'm a cynical bugger when it comes to Voice Assistants ..

    a) I don't like the privacy side of them (yes, go on, take the piss out of my tin-foil hat wearing ways - I'm used to it )
    b) I don't like how Alexa (other voice assistants are available) isn't "that" reliable I find personally (I asked for "Dance Music" the other day, and I got "Dog Music". Did you even know Spotify had a "Dog" playlist FFS?!)
    c) I find that any use-case I've come up with, actually takes longer to say "Alexa, Alexa ... ALEXA ... turn the thing on please" takes longer than simply pushing a button, even if that means walking across the room or pressing a button on my phone.

    So short of when I'm cooking and happen to have my hands caked in oil or something, I can't bring myself to care about Voice assistants too much .. that said, I do use them to some degree ... and I'm interested in what you're using it for though ... what use-cases are you using it for? What devices / automations are you triggering with it?


    How I use voice, and if you wanted to integrate more than just a few things, you'd be better off using Software rather than more and more hardware. Are you an Android (Boo, hiss) or iOS user?

    If you have iOS devices and are willing to use Siri, then you can leverage the newish iOS "Shortcuts" feature, which you can very easily setup any shortcut to call a Cortex Web API and control a device. For example, my main use case is that I have a shortcut called "Garage Door" ... which fires a Cortex Web API .. which in turn presses a button on a 1 button module connected to my garage door controller. This means;

    a) I have a button on my iPhone "home" screen that when pressed, opens the garage door. (I now leave the door key-fob in a drawer, I just use my phone).
    b) I can say "Hey Siri, Garage door" ... and she'll open it for me

    This way, you've got Zero hardware to buy .. unless you want to buy an Apple voice assistant speaker .. and can control ANY module (or modules... you could fire several web requests in the 1 automation) in Cortex .. plus setup a load of logic or routine around it too

  3. #3
    Automated Home Sr Member
    Join Date
    Aug 2007
    Posts
    53

    Default

    The thing is I read the words Cortex Web API, and my brain translates that to blah blah blah….

    All I’ve achieved is the ability to sit in front of the fire with a large glass turn the telly on and say “Alexa, TV lights”, which starts a macro that turns some lights off, and dims a few more etc.

    Or I can say “Alex, close the blinds” or “Alexa, open the blinds” and the blinds on our Velux roof windows do their thing.

    Likewise “Alexa, open the roof”, and again the Velux’s respond. Like I said anything is possible, as long as it can be controlled via a digital input on Cortex.

    I'm stilling working on "Alexa, top my glass up"

    There’s nothing wrong with a bit of voice assistant cynicism, but not sure how asking you phone to do something via a voice request is much different to asking a smart speaker….?

  4. #4
    Automated Home Guru cliffwright's Avatar
    Join Date
    Mar 2007
    Posts
    112

    Default

    Sounds good - if it works for you - then why not ... but for every "feature" you want to add, you're going to have to have 1 relay from these boards, plus an input on a QRI (or any other module with Digital input). With the web API, you don't need either - you can have hundreds of voice commands, and need no additional hardware (assuming you've got an iOS device)

    The Web API basically allows you to in effect, "press" any button / input through a web-request (basically set any state of any object). So pretty much all is happening is you're hitting a URL of "https://yourcortexserveraddress/api/v1/Objects/123?0=1" which is the digital equivalent of your pressing button 1 on your module, or pulsing the digital input on your QRI - it's just a software equivalent.

    How have you got your Velux control hooked up btw? I've got wireless electric Velux and the wireless protocol is Velux's own and encrypted, so you can't mimic the remote .. is yours a wired system rather than wireless? I'd love to get mine hooked up ..


    but not sure how asking you phone to do something via a voice request is much different to asking a smart speaker….?

    It's not ... I just don't have a Siri based speaker (yet), so I can "only" use my phone / iPad. In my use-case, the phone is good because I use it for opening the garage door as I drive up to the house where clearly a smart speaker sat in the house won't hear me

  5. #5
    Automated Home Legend chris_j_hunter's Avatar
    Join Date
    Dec 2007
    Location
    North Lancashire
    Posts
    1,713

    Default

    very interesting thread ... !

    Cliff, when I try your :

    "https://yourcortexserveraddress/api/v1/Objects/123?0=1"

    with my codes substituted, of course

    the response is "Invalid user or password" ...

    so, should there be more in the string ??

    NB: to try it out, I was using Applescript (as an extreme novice), including the line :

    do shell script "open -a Safari 'https://yourcortexserveraddress/api/v1/Objects/123?0=1'"

    Chris
    Last edited by chris_j_hunter; 26th November 2020 at 07:32 PM.

  6. #6
    Automated Home Sr Member
    Join Date
    Aug 2007
    Posts
    53

    Default

    In response to your Velux question, I too have wireless windows/blinds. I control mine via a Velux KLF 200 interface that provides open & close control via 3 pins. Open/Common/Close which I've hooked up to a relay in a DRH-002. Here's a pic
    klf.jpg

    They are not hugely cheap, but solves the problem and has never failed. It doesn't give you the fine or individual control like a Velux control pad, but I've never needed to do anything other than to open and close them.
    Last edited by tizwaz; 26th November 2020 at 07:59 PM.

  7. #7
    Automated Home Guru cliffwright's Avatar
    Join Date
    Mar 2007
    Posts
    112

    Default

    Quote Originally Posted by chris_j_hunter View Post
    very interesting thread ... !

    Cliff, when I try your :

    "https://yourcortexserveraddress/api/v1/Objects/123?0=1"

    with my codes substituted, of course

    the response is "Invalid user or password" ...

    so, should there be more in the string ??

    NB: to try it out, I was using Applescript (as an extreme novice), including the line :

    do shell script "open -a Safari 'https://yourcortexserveraddress/api/v1/Objects/123?0=1'"

    Chris
    I'm not sure about Applescript, but however you make the request, you need to set a header key-value pair in the API request of "Authorization" "Basic <your base64 encoded value that represents your Cortex username / password>"

    You can generate the encoded value of your username / password combination by either;

    1) Use this website (or any other like it - there's a few) - https://www.blitter.se/utils/basic-a...der-generator/
    2) Download Postman, setup the API call you're trying to fire in here (which has the added benefit that you can test if from here too), set "Basic Auth" in the Authorization tab, enter your username / password, then view the "Code" that Postman will fire - this is your encoded value.


    Shout if screenshots of anything would help :-)

  8. #8
    Automated Home Guru cliffwright's Avatar
    Join Date
    Mar 2007
    Posts
    112

    Default

    Quote Originally Posted by tizwaz View Post
    In response to your Velux question, I too have wireless windows/blinds. I control mine via a Velux KLF 200 interface that provides open & close control via 3 pins. Open/Common/Close which I've hooked up to a relay in a DRH-002. Here's a pic
    klf.jpg

    They are not hugely cheap, but solves the problem and has never failed. It doesn't give you the fine or individual control like a Velux control pad, but I've never needed to do anything other than to open and close them.
    Very interesting - thanks .. Like you, 99.9% of the time it's either Open or Close ... not 50% open etc so this'd work fine. I'll look into it :-)

  9. #9
    Automated Home Legend chris_j_hunter's Avatar
    Join Date
    Dec 2007
    Location
    North Lancashire
    Posts
    1,713

    Default

    Cliff - many thanks ...

    have tried & tried, but still having trouble !

    successfully got the encoded value, but can't work out how exactly to include it in the request - have tried everything I can think, without luck !

    sending this :

    http://xyz.ab.cd.efg:hijkl

    of course results in the Cortex log-on window, waiting for User Name & Password to be entered manually ...

    and sending this :

    http://xyz.ab.cd.efg:hijkl/api/v1/Objects/123?0=1

    results in the message Invalid user or password

    which seems to give a clue, but no matter how I then add in (have tried a dozen ways)

    Authorisation & Basic <abcdefghijklmnopqrstuvwxyz12345=>

    I get the same message - Invalid User or password

  10. #10
    Automated Home Guru cliffwright's Avatar
    Join Date
    Mar 2007
    Posts
    112

    Default

    Quote Originally Posted by chris_j_hunter View Post
    Cliff - many thanks ...

    have tried & tried, but still having trouble !

    successfully got the encoded value, but can't work out how exactly to include it in the request - have tried everything I can think, without luck !

    sending this :

    http://xyz.ab.cd.efg:hijkl

    of course results in the Cortex log-on window, waiting for User Name & Password to be entered manually ...

    and sending this :

    http://xyz.ab.cd.efg:hijkl/api/v1/Objects/123?0=1

    results in the message Invalid user or password

    which seems to give a clue, but no matter how I then add in (have tried a dozen ways)

    Authorisation & Basic <abcdefghijklmnopqrstuvwxyz12345=>

    I get the same message - Invalid User or password

    OK - hopefully the following helps - sorry if the detail is too low, but will hopefully cover off any detail that might be missing / tripping you up;

    1. Make sure the Cortex object you're trying to control here is "Web enabled" and you've granted "Web API" permissions to your user in the Web server options of the object. (Clearly here, make sure you know the valid username / password too ... sometimes it's the simple things that trip us up the most!)
    2. Install Postman or an equivalent - and setup a GET request as follows;

    a) Select the Request Type as GET
    b) Set the URI as http://<yourcortexIP>:<yourcortexPort>/api/v1/Objects
    c) On the Authorization tab, select "Basic Auth" as the auth type, and enter your username / password

    This should give you a request such as follows;



    If you can hit this and get a successful response, you know your Auth is sorted.

    From the JSON body you get back, you can find the object you're interested in controlling and either use the FriendlyName value, or the IDNumber (which I prefer in case you ever rename an object).

    Using the same GET request above, append the object IDNumber or friendly name as a query param in the URI so you have;

    ...api/v1/Objects/504
    or
    ...api/v1/Objects/My Lounge Light

    ... and fire this. The JSON you'll get back will give you a Port array, within which you'll see;

    {
    "PortNumber": "5",
    "Description": "Turn On",
    "Type": "In"
    },

    Using this, you know that Portnumber 5 is what you'll need to use to Turn this light object on.


    Using this, construct a POST request similar to the above, such that you've got;




    which gives you a request of;

    POST /api/v1/Objects/504?5=1 HTTP/1.1
    Host: 192.168.1.254:9083
    Authorization: Basic Q2xpZmZTYW1wbGVVc2VyTmFtZTpNeVNhbXBsZVBhc3N3b3Jk

    ... which also gives you the base64 encoded value of your username/password combo.

    Firing this, will then instruct Cortex to "Turn On" this light object

    You can then reconstruct this request into whatever application you're going to use to command Cortex from (In my case an iOS Shortcut).

    Shout if you need anything else or have more questions

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •