Creating an Alexa Skill to work with your Synology

I found this excellent article on creating a basic Alexa skill. Follow this tutorial to get a basic skill and use the php code below instead of the shell script in the tutorial as the Synology does not like non-PHP scripts.

<?php
 header("Content-Type: application/json;charset=utf-8");
?>
{ "version": "1.0", "response": { "outputSpeech": { "type": "PlainText", "text": "Got it. Yes, your command was received."} }}

In the Amazon skill testing you can see the JSON data sent to the Synology. After the tutorial you will find that that you are only sending the date and no other command data. To send more data the Amazon skill will need to be further developed.

More to come on linking the broadlink and Alexa skill

Posted in Code, Home Automation | Leave a comment

Broadlink RM IR control via Python

Christmas I received the Broadlink RM device for controlling IR devices with the intention of using it with Amazon Alexa. It turns out that the service is not available in the UK so the only way to control the device is with the phone App.

After ‘googling’ for options it turns out there are ways to bridge the connection using Android devices, which I don’t have. My next option was to look for ways to control the device through Python and create my own skills in Alexa.

Everything is easier said than done but here goes.

Step 1. make sure your broadlink RM device is on your network and you can see it with the phone App. Just follow the instructions in the box for this bit.

Step 2. I found a library on github to provide some basic API features. Download the API from user mjg59 on github. From this point you can follow the instructions on the README 🙂

or mine below…..

Step 3. I found that my install of Python did not have pyaes installed that is used by the API so ….. sudo pip install pyaes

Step 4. Okay, when I download the code from github I placed the contents of broadlink/__init__.py in to broadlink.py. You will need to do the same if you use the code below to learn one command from your remote and repeat it back out. This will prove you can communicate with the broadlink device and play out a recorded IR code.

import broadlink
import time

devices = broadlink.discover(timeout=5)
print(devices)

devices[0].auth()

devices[0].enter_learning()
print("learning")
time.sleep(5)
ir = devices[0].check_data()

print("wait")
time.sleep(10)

print("learnt")
devices[0].send_data(ir)
print(ir)
print("end")

Running the above will give you 5 seconds to learn an IR code (your broadlink should show an amber light) and 10 seconds later the broadlink will reply the command.

This proves you have control of your broadlink. The next stages will be to learn all your IR commands to build a database that Alexa can use.

Posted in Code, Home Automation | Leave a comment

Synology Certificates and Alexa Skills

If you want to host Alexa skills on your Synology you will need to use Let’s Encrypt certificates as the default one will not authenticate for the skill.

To check if your certificate is okay use SSLChecker to validate the certificate from the Synology. You should get all green ticks. Anything else will cause a failure while testing the skill.

Posted in Code, Home Automation | Leave a comment

Installing Screen on Synology

Home page for screen

To install on synology you need to have ipkg installed. Mine is located in /opt/bin.

sudo /opt/bin/ipkg install screen

If you just run /opt/bin/screen you will get a terminal error as you may not have a termcap entry. For me the fix was:

TERM=xterm-color /opt/bin/screen

Screen commands:

  • Ctrl-a Ctrl-d  = detach from screen
  • screen -r = re-attach to screen
  • Ctrl-a Ctrl-\ = kill session and terminate

Loads more command on the above screen page

Posted in Code, Software | Leave a comment

FFMPEG to crop MP3

Using ffmpeg to crop a file is fast and efficient if you know the time positions to crop. I used VLC to identify the positions (my version of vlc would not crop – sad face).

fmpeg -i input-file.mp3 -ss 6:40:00 -to 10:29:00 -c copy output-file.mp3

-ss = start time in hh:mm:ss
-to = end time in hh:mm:ss
Posted in Code | Tagged | Leave a comment

Finding devices on local network

Run the following command on a UNIX based machine:

ping -c 3 192.168.1.255 > /dev/null; arp -a

The first command pools devices and the second outputs the known devices on the network

Posted in Code | Tagged | Leave a comment

git & Synology

Setting up Synology with git

A great article here with screenshots – How to install Git Server

Some git commands now to use:

Creating working store:
cd git_repo
mkdir project.git
cd project.git
git --bare init
cd ..
chown -R git:users project.git

Working from remote location:
git clone ssh://git@192.*.*.11/volume1/git_repo/project.git/
cd project
mkdir test
git add test
git commit -m "adding test"
git push -u origin master
git status
git pull origin master
git ls-files
git log -n 10
git help [-a]

git works best bringing in the complete project tree so break projects up where you don’t want to bring down multiple project files.

Reference links:

Posted in Code, Software | Tagged , , | Leave a comment

Convert DV footage for IPad Editting

My DV footage is:

  • video – 720 x 576, dv video dvdd,  25 frame
  • audio – pcm s16 le, 48k, 16bit stereo

I need to convert to:

  • video – h264 mpeg-4 abc avc1, 1920×1090, 25 frame
  • audio – aac sterio 44.1k

Automated the conversion using ffmpeg with the following options:

ffmpeg -i in.avi -vcodec libx264 -vf yadif -codec:a aac -vb 5M out.mp4

Posted in Software | Tagged | Leave a comment

Great Tutorial on CSS Image Transitions

http://css3.bradshawenterprises.com/cfimg/

Posted in Code, Software | Tagged , | Leave a comment

Subversion

Links for using subversion

Command examples:

svn import -m "Import new folder to the project" new_folder \
svn://SVN_REPO/projects/new_folder

 

Posted in Code | Tagged | Leave a comment