In my last post I looked at integrating mControl with VeraLite. The next thing I wanted to setup was to be able to control Z-wave devices associated with Vera and run scenes that I’d setup in Vera via the command line on the Windows 7 Home Theatre PC.
Overview:
Why control Vera Z-wave devices and scenes from the command line you may ask? So I could program my Logitech Harmony universal remote control to be able to run these .CMD files with a little help from AutoHotKey installed on the HTPC. So for example I have added additional custom buttons to the Harmony remote’s LCD screen for my Watch Movies activity, so I can control the lights in the room via the Harmony remote at the click of a button.
The way that this works, is you teach your Harmony remote a keyboard command like Ctrl+Alt+A you then have an AutoHotKey script on the HTPC that waits for this keyboard command, once detected the script runs your .CMD file that sends a HTTP request to Vera to do something, like turn on a light. You can read more about setting up AutoHotKey and programming the Harmony remote on a previous post here. Scroll down the blog post and look for the part entitled:Logitech Harmony remote control.
Below is an example of what’s in the AutoHotKey script:
^!A::
IfWinExist Untitled – Left Lamp On
WinActivate
else
Run C:\Lights\Run-CMD.vbs C:\Lights\Lounge-On-Left.cmd
return
Getting started:
wGet
You will need to install and setup Wget on your HTPC first. I installed wGet on to my Windows 7 HTPC, I also had to add the path of where wget.exe is located which on my x64 PC was C:\Program Files (x86)\GnuWin32\bin in to the Windows Environment Variables PATH. To do this right click Computer from the start menu and select properties, then select Advanced System Settings and the Environment Variables button, under system variables scroll down to PATH click Edit and add in the path to wget.exe be sure to separate with ;
So now you have setup Wget you can look at creating some Vera HTTP commands.
Turning a Z-wave device on and off
Here is an example HTTP command which turns on my Lamp (Left) device in my living room. You need to know what your DeviceNum is?
There are two ways to work out the device number, you can go to the Vera UI in a browser find the device in question, click the spanner icon and then go to the settings tab. You can see that this Lamp (Left) device is ID 3 and DeviceNum=3 in the above HTTP string to turn on this device.
The second method of listing the ID numbers for all your devices and scenes in Vera is to use the URL below, which displays a page of XML with all the information in it. Change IP-Address for the internal IP address of your Vera box.
To test your Vera HTTP commands you can just run them in a browser and the Z-wave device should respond. Obviously you need to change the IP address 192.168.1.100 to the IP address of your own Vera unit.
Once you have confirmed that they work you can create the .CMD files and just paste in the whole HTTP command. I won’t tell you how to create a new .CMD file as you should know how to do that. If you double click the .CMD file the HTTP command should be sent to Vera and the Z-wave device respond.
Run a Vera scene
In this example we are going to look at a HTTP command to run a scene in Vera. Again first you need to know the scene number of the particular scene you would like to create your .CMD file for. My scene is called “Lounge On” if I look at the scene in Vera I can see its number is = 1
Or if I look at the XML code from the URL I mentioned above, I can see this:
So now I know the ID number of the scene I want to create a .CMD file for, I can use the HTTP command below, note I have the number 1 at the end: RunScene&SceneNum=1 If my scene had an ID of 5 I would change this to be RunScene&SceneNum=5 etc.
So what I ended up with was folder on the HTPC with all my .CMD files in it to run various scenes and turn on/off various devices.
If you want to know more about how to setup AutoHotkey and program your Harmony remote control to be able to run these .CMD files then as I already said you need to read my previous post here. Ignore all the stuff about mControl Soap commands and the Amulet voice remote, the part you need to follow is entitled: Logitech Harmony remote control.
Summary:
Using the command line with your Home Theatre PC to send HTTP requests to your Vera Home Automation box, enables you to use your programmable universal remote control like a Logitech Harmony, to turn on and off Z-wave devices and also enables you to run scenes in Vera. When setup correctly it works perfectly and at the touch of a button on your remote control you will be able to initiate pretty much anything you have configured in Vera. Why spend extra money on a Z-wave compatible remote control? When you can program your existing Harmony remote to control Vera via your HTPC.
Here is a photo of my Logitech Harmony’s LCD screen with some custom buttons to control Z-wave devices like my lights an fireplace.
{"id":null,"mode":"button","open_style":"in_place","currency_code":"GBP","currency_symbol":"\u00a3","currency_type":"decimal","blank_flag_url":"https:\/\/thedigitallifestyle.com\/w\/wp-content\/plugins\/tip-jar-wp\/\/assets\/images\/flags\/blank.gif","flag_sprite_url":"https:\/\/thedigitallifestyle.com\/w\/wp-content\/plugins\/tip-jar-wp\/\/assets\/images\/flags\/flags.png","default_amount":500,"top_media_type":"none","featured_image_url":false,"featured_embed":"","header_media":null,"file_download_attachment_data":null,"recurring_options_enabled":true,"recurring_options":{"never":{"selected":true,"after_output":"One time only"},"weekly":{"selected":false,"after_output":"Every week"},"monthly":{"selected":false,"after_output":"Every month"},"yearly":{"selected":false,"after_output":"Every year"}},"strings":{"current_user_email":"","current_user_name":"","link_text":"Leave a tip","complete_payment_button_error_text":"Check info and try again","payment_verb":"Pay","payment_request_label":"TheDigitalLifestyle.com","form_has_an_error":"Please check and fix the errors above","general_server_error":"Something isn't working right at the moment. Please try again.","form_title":"TheDigitalLifestyle.com","form_subtitle":null,"currency_search_text":"Country or Currency here","other_payment_option":"Other payment option","manage_payments_button_text":"Manage your payments","thank_you_message":"Thank you for being a supporter!","payment_confirmation_title":"TheDigitalLifestyle.com","receipt_title":"Your Receipt","print_receipt":"Print Receipt","email_receipt":"Email Receipt","email_receipt_sending":"Sending receipt...","email_receipt_success":"Email receipt successfully sent","email_receipt_failed":"Email receipt failed to send. Please try again.","receipt_payee":"Paid to","receipt_statement_descriptor":"This will show up on your statement as","receipt_date":"Date","receipt_transaction_id":"Transaction ID","receipt_transaction_amount":"Amount","refund_payer":"Refund from","login":"Log in to manage your payments","manage_payments":"Manage Payments","transactions_title":"Your Transactions","transaction_title":"Transaction Receipt","transaction_period":"Plan Period","arrangements_title":"Your Plans","arrangement_title":"Manage Plan","arrangement_details":"Plan Details","arrangement_id_title":"Plan ID","arrangement_payment_method_title":"Payment Method","arrangement_amount_title":"Plan Amount","arrangement_renewal_title":"Next renewal date","arrangement_action_cancel":"Cancel Plan","arrangement_action_cant_cancel":"Cancelling is currently not available.","arrangement_action_cancel_double":"Are you sure you'd like to cancel?","arrangement_cancelling":"Cancelling Plan...","arrangement_cancelled":"Plan Cancelled","arrangement_failed_to_cancel":"Failed to cancel plan","back_to_plans":"\u2190 Back to Plans","update_payment_method_verb":"Update","sca_auth_description":"Your have a pending renewal payment which requires authorization.","sca_auth_verb":"Authorize renewal payment","sca_authing_verb":"Authorizing payment","sca_authed_verb":"Payment successfully authorized!","sca_auth_failed":"Unable to authorize! Please try again.","login_button_text":"Log in","login_form_has_an_error":"Please check and fix the errors above","uppercase_search":"Search","lowercase_search":"search","uppercase_page":"Page","lowercase_page":"page","uppercase_items":"Items","lowercase_items":"items","uppercase_per":"Per","lowercase_per":"per","uppercase_of":"Of","lowercase_of":"of","back":"Back to plans","zip_code_placeholder":"Zip\/Postal Code","download_file_button_text":"Download File","input_field_instructions":{"tip_amount":{"placeholder_text":"How much would you like to tip?","initial":{"instruction_type":"normal","instruction_message":"How much would you like to tip? Choose any currency."},"empty":{"instruction_type":"error","instruction_message":"How much would you like to tip? Choose any currency."},"invalid_curency":{"instruction_type":"error","instruction_message":"Please choose a valid currency."}},"recurring":{"placeholder_text":"Recurring","initial":{"instruction_type":"normal","instruction_message":"How often would you like to give this?"},"success":{"instruction_type":"success","instruction_message":"How often would you like to give this?"},"empty":{"instruction_type":"error","instruction_message":"How often would you like to give this?"}},"name":{"placeholder_text":"Name on Credit Card","initial":{"instruction_type":"normal","instruction_message":"Enter the name on your card."},"success":{"instruction_type":"success","instruction_message":"Enter the name on your card."},"empty":{"instruction_type":"error","instruction_message":"Please enter the name on your card."}},"privacy_policy":{"terms_title":"Terms and conditions","terms_body":null,"terms_show_text":"View Terms","terms_hide_text":"Hide Terms","initial":{"instruction_type":"normal","instruction_message":"I agree to the terms."},"unchecked":{"instruction_type":"error","instruction_message":"Please agree to the terms."},"checked":{"instruction_type":"success","instruction_message":"I agree to the terms."}},"email":{"placeholder_text":"Your email address","initial":{"instruction_type":"normal","instruction_message":"Enter your email address"},"success":{"instruction_type":"success","instruction_message":"Enter your email address"},"blank":{"instruction_type":"error","instruction_message":"Enter your email address"},"not_an_email_address":{"instruction_type":"error","instruction_message":"Make sure you have entered a valid email address"}},"note_with_tip":{"placeholder_text":"Your note here...","initial":{"instruction_type":"normal","instruction_message":"Attach a note to your tip (optional)"},"empty":{"instruction_type":"normal","instruction_message":"Attach a note to your tip (optional)"},"not_empty_initial":{"instruction_type":"normal","instruction_message":"Attach a note to your tip (optional)"},"saving":{"instruction_type":"normal","instruction_message":"Saving note..."},"success":{"instruction_type":"success","instruction_message":"Note successfully saved!"},"error":{"instruction_type":"error","instruction_message":"Unable to save note note at this time. Please try again."}},"email_for_login_code":{"placeholder_text":"Your email address","initial":{"instruction_type":"normal","instruction_message":"Enter your email to log in."},"success":{"instruction_type":"success","instruction_message":"Enter your email to log in."},"blank":{"instruction_type":"error","instruction_message":"Enter your email to log in."},"empty":{"instruction_type":"error","instruction_message":"Enter your email to log in."}},"login_code":{"initial":{"instruction_type":"normal","instruction_message":"Check your email and enter the login code."},"success":{"instruction_type":"success","instruction_message":"Check your email and enter the login code."},"blank":{"instruction_type":"error","instruction_message":"Check your email and enter the login code."},"empty":{"instruction_type":"error","instruction_message":"Check your email and enter the login code."}},"stripe_all_in_one":{"initial":{"instruction_type":"normal","instruction_message":"Enter your credit card details here."},"empty":{"instruction_type":"error","instruction_message":"Enter your credit card details here."},"success":{"instruction_type":"normal","instruction_message":"Enter your credit card details here."},"invalid_number":{"instruction_type":"error","instruction_message":"The card number is not a valid credit card number."},"invalid_expiry_month":{"instruction_type":"error","instruction_message":"The card's expiration month is invalid."},"invalid_expiry_year":{"instruction_type":"error","instruction_message":"The card's expiration year is invalid."},"invalid_cvc":{"instruction_type":"error","instruction_message":"The card's security code is invalid."},"incorrect_number":{"instruction_type":"error","instruction_message":"The card number is incorrect."},"incomplete_number":{"instruction_type":"error","instruction_message":"The card number is incomplete."},"incomplete_cvc":{"instruction_type":"error","instruction_message":"The card's security code is incomplete."},"incomplete_expiry":{"instruction_type":"error","instruction_message":"The card's expiration date is incomplete."},"incomplete_zip":{"instruction_type":"error","instruction_message":"The card's zip code is incomplete."},"expired_card":{"instruction_type":"error","instruction_message":"The card has expired."},"incorrect_cvc":{"instruction_type":"error","instruction_message":"The card's security code is incorrect."},"incorrect_zip":{"instruction_type":"error","instruction_message":"The card's zip code failed validation."},"invalid_expiry_year_past":{"instruction_type":"error","instruction_message":"The card's expiration year is in the past"},"card_declined":{"instruction_type":"error","instruction_message":"The card was declined."},"missing":{"instruction_type":"error","instruction_message":"There is no card on a customer that is being charged."},"processing_error":{"instruction_type":"error","instruction_message":"An error occurred while processing the card."},"invalid_request_error":{"instruction_type":"error","instruction_message":"Unable to process this payment, please try again or use alternative method."},"invalid_sofort_country":{"instruction_type":"error","instruction_message":"The billing country is not accepted by SOFORT. Please try another country."}}}},"fetched_oembed_html":false}
Can this same approach be used to send commands from an Xbox One? Im looking for an excuse to buy an Xbox one and like the idea of voice commands…