LightwaveRF ruby gem

  • January 10, 2013 at 22:33 #3874
    pauly
    Participant

    Thanks for the new forum, this seems like the right place to mention my ruby gem, use it and abuse it to a) talk to the wifi link from the command line, or b) incorporate it in your own code. I’m keen to receive any feedback or pull requests.

    I’m using it right now to automate my own home using a google calendar for the timer settings. I don’t have my central heating automated yet but when I do this is going to be great. No more fiddling about with an unfriendly timer interface in the cupboard, instead just set repeating events on a familiar interface. It’s already working nicely for the lights and switches, turn off lights and devices at bed time and so on.

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    January 18, 2013 at 01:07 #4148
    velkrosmaak
    Participant

    Google calendar! That’s genius! I’ve been using Eventghost to trigger a python script that sends a UDP string.

    January 29, 2013 at 22:49 #4420
    pauly
    Participant

    Thanks, been live for a few weeks now and working nicely! Some more updates to the gem now too, it annotates a log file as it turns devices on and off so I can see how the different events affect power usage on a graph, see attached… all the source code is there https://github.com/pauly/lightwaverf

    Attachments:
    You must be logged in to view attached files.
    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    January 30, 2013 at 16:22 #4482
    stephenmelody
    Participant

    This is awesome, I’d love to do something similar on my raspberry pi.

    Is there some brief instructions you could give on how to get this installed and working / what’s required?

    Cheers.

    January 30, 2013 at 22:57 #4492
    pauly
    Participant

    This is awesome, I’d love to do something similar on my raspberry pi. Is there some brief instructions you could give on how to get this installed and working / what’s required? Cheers.

    I’ll try and write it up properly tomorrow, as I have to do a completely fresh install anyway – just fritzed my raspberry pi somehow while trying to install some webcam software on it. A complete aside but a friend at work has just set up a “cat cam” motion detector on an old pc and I’m going to do the same on my pi. Here are some instructions that I don’t have time to finish!

    # open a terminal on the pi and install ruby and git

    sudo apt-get install git-core ruby
    # then install my gem

    sudo gem install lightwaverf

    # then try and run it once, this will create the config file

    lightwaverf lounge light on

    # that will probably fail, then edit your config file

    vi ~/lightwaverf-config.yml

    # you need the ip address of your wifi link in there http://amzn.to/V7yPPK 
    # then pair the pi with one of your devices,
    # so hold down your light switches until they flash and power on with

    lightwaverf lounge light on

    # if that worked you are mostly there…
    # next you need your energy monitor in place
    # then make a calendar at google.com/calendar find the “share” option and get the address of it
    # i’ll post some screen grabs of this later
    # then add some events where the title is just “room device”, for example “lounge light”
    # then set up a cron job on the pi that calls this command every 5 mins, so
    crontab -e
    # that will put you into the editor, save the file with this line at the bottom
    */5 * * * * lightwaverf energy 5 > /tmp/lightwaverf.out 2> /tmp/lightwaverf.err

    # actually there is more to this than I realised, I will have to come back to this! If you can pick the rest up from https://github.com/pauly/lightwaverf then please let me know how you get on. If not I’ll be adding a proper installation guide there and will post it back here too.

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    January 31, 2013 at 08:49 #4493
    pauly
    Participant

    http://rubygems.org is down right now they’ve been hacked so you can’t install the gem, but you can clone the github repo and build it yourself if you are interested.

    I will be back with clear instructions, just hard to fit it in round work and home life… if you’re a programmer though you can work it out. I forgot to mention if you want to run the little website in my repo you need nodejs too, but you can probably pick the bits out of the source code that reads the file and displays the graph, it’s all just html and javascript really.

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    January 31, 2013 at 09:40 #4494
    Chris
    Keymaster

    Pauly

    This sounds like a great feature. Would you be willing to put together a decent write up with screenshots that we can publish on the ‘features’ section of this site?

    Chris

    Chris Mills
    Founder and Editor - LightwaveRF Community
    http://cpmills.com/ https://staging.lightwaverfcommunity.org.uk

    January 31, 2013 at 13:06 #4495
    pauly
    Participant

    Yes no problem. It’ll force me to simplify the process too and split it out into chunks. First need to recover my bricked raspberry pi!

    Hey it’s pay day, time to buy more STUFF! Next stop for me is some relays so I can control the kitchen downlighters without having to replace them with dimmables…

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    February 1, 2013 at 10:34 #4515
    stephenmelody
    Participant

    Hey Pauly,

    I’m fairly new to linux and I’m definitely not a programmer! I’m looking forward to your full guide… then I’ll start 😉

    February 9, 2013 at 00:56 #4697
    ian.p
    Participant

    Hi Pauly

    great work on the ruby gem. I’ve been able to get it working on a Raspberry Pi via a plugin in SiriProxy (http://www.hometoys.com/emagazine/2013/02/siri-home-automation-integration-from-start-to-finish-brpart-2–raspberry-pi-installation/2090), your notes above and this YouTube video (http://www.youtube.com/watch?v=cTuhjTvg_pw)

    one thing I haven’t been able to get working is the dimmer settings. From the source, it looks like it is supported by get_state, however “lightwaverf lounge light 75” simply returns the message “did not recognise state, got 75”. Am I doing something wrong, or is this one of the things on your todo list?

    keep up the great work

    Ian

    February 9, 2013 at 16:18 #4701
    foggy
    Participant

    Hi ian.p,

    I have SiriProxy working on my phone and have been trying to get Pauly’s Gem to work for ages, but without success.

    I’m guessing you have created a specific plugin. Could you share it? and also how you installed it?

    Best wishes.

    James.

    February 10, 2013 at 16:48 #4715
    ian.p
    Participant

    Hi James

    I’ve pushed the SiriProxy plugin to GitHub and quickly put together some accompanying notes (from memory) of the steps I followed to get things working. You can find it here – https://github.com/ianperrin/siriproxy-lwrf

    Do bear in mind that I’m new to Github, Ruby and SiriProxy so hopefully I’ve done things correctly!

    If you do try to follow the notes in order to get things working in your environment, I’d welcome any thoughts on how you get on.

    Good luck

    Ian

    February 10, 2013 at 20:21 #4718
    pauly
    Participant

    one thing I haven’t been able to get working is the dimmer settings. From the source, it looks like it is supported by get_state, however “lightwaverf lounge light 75″ simply returns the message “did not recognise state, got 75″. Am I doing something wrong, or is this one of the things on your todo list? keep up the great work Ian

    Yep just my slack code, I don’t dim much so I have not got round to fixing it. I’ll try and sort that later today and will reply here when I publish an update. It’s down to the param always being a string I think and I’m only checking for a number.

    Really pleased to hear people are using the code I wrote!

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    February 10, 2013 at 22:08 #4720
    pauly
    Participant

    I fixed the dimmer support (and added tests for it), so update your gem!

    gem install lightwaverf

    or

    gem update lightwaverf

    then

    lightwaverf lounge light 25

    lightwaverf lounge light 50

    lightwaverf lounge light 90

    etc

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    February 10, 2013 at 22:08 #4721
    simonrg
    Participant

    Pauly and Ian thanks to your work I now am able to turn my lights on and off using Siri plus a Raspberry Pi.  Plus obviously the author of SiriProxy.

    Please keep up the great work.

    Being new to Ruby and gem, I had been trying with the original SiriProxy image from Sourceforge, but had ended up with at least two Ruby installations and several versions of everthying in different rvm / gem areas.  I did succeed in turning lights on by putting out lightwaverf command line commands from SiriProxy, but it is far neater to have it all within Ruby and somehow I had created a new version of SiriProxy too.

    What’s the best way to learn Ruby?  More precisely where I need to go to get the understanding of what Gem and RVM are doing that results in me having multiple copies of everything, presumabely I am doing something wrong.

    My next puzzle is to work out how SiriProxy (or Ruby) deals with capitalisation or more sensibly reading in the lightwaverf configuration file and doing case insensitive matching.  I have a “centre light” in one room and this is “Centre light” for SiriProxy.

    Thanks, Simon

You must be logged in to reply to this topic.