LightwaveRF ruby gem

  • September 30, 2014 at 11:21 #16142
    homeoffice_lf
    Participant

    yep 2.9 firmware has broken it, pain in the Bum !!!

    I use the Gem from OS X and up to now have only ever had issues with graphing, basically no matter what i do the graph date and time is incorrect – its weird (this is graph for energy monitors).

    But…. on the plus side getting the energy readings myself using your gem is easy 🙂 so I just use RRD for my own graphs which are now working great.
    I calculate Current Usage, Current Cost, Max Peak Power, etc.. only thing missing is power by device – finding some way to get a reading wireless from each individual device – must be something on the market to do this.

    I run small home office and each device is connected via lightwave sockets, lights, plugs for blinds and even allows me switch between AC and Solar (which kinda works).

    Hopefully you’ll have a fix soon – (by the way you mentioned in the part a raspberry pi RF controller – did you get anywhere on this)

    cheers mate

    Attachments:
    You must be logged in to view attached files.
    September 30, 2014 at 19:18 #16160
    pauly
    Participant

    I have made no progress with the raspberry pi rf controller, I’ve had some success with an arduino one though, following some tips from people here. Don’t get the time to work on it really! Glad you have had more success, I’ll have a look at my own graphing too…

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    October 2, 2014 at 16:11 #16194
    pauly
    Participant

    I fixed the graphs in the webpage on the gem in a new branch, so if you are working from source code

    git checkout 0.7
    gem build lightwaverf.gemspec && sudo gem install lightwaverf-0.7.gem

    I have to write some more tests before I can release the new version of the gem

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    October 21, 2014 at 11:39 #16535
    adamjseed
    Participant

    Hi @pauly,

    I have just tried to get this running and hit an issue

    $ sudo gem install lightwaverf
    Fetching: lightwaverf-0.6.6.gem (100%)
    Successfully installed lightwaverf-0.6.6
    1 gem installed
    Installing ri documentation for lightwaverf-0.6.6…
    Installing RDoc documentation for lightwaverf-0.6.6…

    $ lightwaverf configure
    /var/lib/gems/1.9.1/gems/lightwaverf-0.6.6/lib/lightwaverf.rb:64:in `+’: can’t convert nil into String (TypeError)
    from /var/lib/gems/1.9.1/gems/lightwaverf-0.6.6/lib/lightwaverf.rb:64:in `configure’
    from /var/lib/gems/1.9.1/gems/lightwaverf-0.6.6/bin/lightwaverf:9:in `’
    from /usr/local/bin/lightwaverf:23:in `load’
    from /usr/local/bin/lightwaverf:23:in `’

    any advise?

    October 21, 2014 at 17:29 #16553
    mmcnamee
    Participant

    I use @pauly ‘s ruby script with some custom monitoring scripts on a raspberry pi – they work great with the old v2.51 firmware.

    I am also using the PHP control scripts and UI on the same rpi, and additionally using the Lightwave “OpenAPI” on a Windows box. I mention this, because I invoke that using a powershell script, and pass the results to the PRTG network monitor, which graphs the power consumption quite nicely (see attachments)

    Attachments:
    You must be logged in to view attached files.
    October 24, 2014 at 12:42 #16595
    pauly
    Participant

    i’ll take a look, can you email me? pauly@clarkeology.com

    I’ve had a go with a fresh install and it’s just my mistake… “lightwaverf configure” should create a config file for you, but it crashes out because it can’t find the config file… /home/ec2-user/lightwaverf-config.yml does not exist! Or specifically the calendar part of it… add a line with

    calendar: ''

    to the bottom of ~/lightwaverf-config.yml and that will fix it. Either open that file and edit it or just type this on the command line:

    echo "calendar: ''" >> ~/lightwaverf-config.yml

    thanks for your help in getting to the bottom of this!

    – copy lightwaverf-configy.yml from https://github.com/pauly/lightwaverf

    Hi @pauly,

    I have just tried to get this running and hit an issue

    $ sudo gem install lightwaverf
    Fetching: lightwaverf-0.6.6.gem (100%)
    Successfully installed lightwaverf-0.6.6
    1 gem installed
    Installing ri documentation for lightwaverf-0.6.6…
    Installing RDoc documentation for lightwaverf-0.6.6…

    $ lightwaverf configure
    /var/lib/gems/1.9.1/gems/lightwaverf-0.6.6/lib/lightwaverf.rb:64:in `+’: can’t convert nil into String (TypeError)
    from /var/lib/gems/1.9.1/gems/lightwaverf-0.6.6/lib/lightwaverf.rb:64:in `configure’
    from /var/lib/gems/1.9.1/gems/lightwaverf-0.6.6/bin/lightwaverf:9:in `’
    from /usr/local/bin/lightwaverf:23:in `load’
    from /usr/local/bin/lightwaverf:23:in `’

    any advise?

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    October 28, 2014 at 17:05 #16660
    adamjseed
    Participant

    Hi @pauly,

    That did the trick.

    I seem to remember a way of pulling the online configuration down, but cant seem to find a way. Is it possible?

    October 28, 2014 at 17:11 #16663
    pauly
    Participant

    lightwaverf update email@example.com 1234

    with your email and your pin, it’ll grab the config from lightwaverfhost.co.uk

    look out if you have spaces in your room or device names there, you might find you need to edit ~/lightwaverf-config.yml after that – i’ll fix this in the next issue.
    the latest version of the gem fixes the other issues above though.

    My own setup has gone completely tits up right now. Everything was working apart from the energy monitor, following the 2.91F firmware update; energy monitor was responding but showing 0 all the time. Tech support told me to just reset the wifi link and repair and all would be fine. So I did and now it looks like it’s just hanging waiting for a response from the energy monitor. That’s my best guess, something has brought down the raspberry pi that it runs on since I did that anyway. Still gives me a good new scenario to try and code around!

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    October 28, 2014 at 17:30 #16665
    mmcnamee
    Participant

    Hi Paul,

    I’m taking a guess here, but I suspect your script is failing to receive/process the response, but it does appear to be sending the commands correctly and the wifi link is still receiving them – in my case anyway!

    I have your script linked via /usr/local/bin/lightwaverf

    I was having problems calling it from a python script, in that occasionally it would hang (never return) when executing a command. As a result, my process would then also hang, pending a response.

    I worked around this using the following Python script, in a file called LightwaveAPI.py


    import sys, os
    import subprocess, datetime, os, time, signal

    lwrfcmd = "/usr/local/bin/lightwaverf"

    def lwrf_on(room, device):
    cmd = lwrfcmd + " \"" + room + "\" \"" + device + "\" on"
    print "LWRF:", cmd
    timeout_command(cmd, 10)

    def lwrf_off(room, device):
    cmd = lwrfcmd + " \"" + room + "\" \"" + device + "\" off"
    print "LWRF:", cmd
    timeout_command(cmd, 10)

    def lwrf_light(room, device, percentage):
    cmd = lwrfcmd + " \"" + room + "\" \"" + device + "\" \"" + str(percentage) + "%\""
    print "LWRF:", cmd
    timeout_command(cmd, 10)

    def timeout_command(command, timeout):
    start = datetime.datetime.now()
    print command
    process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    print 'Starting polling...'
    while process.poll() is None:
    time.sleep(5)
    now = datetime.datetime.now()
    print 'Still waiting...'
    if (now - start).seconds> timeout:
    print 'Process timeout! Sending kill signal'
    os.kill(process.pid, signal.SIGKILL)
    os.waitpid(-1, os.WNOHANG)
    return None

    #return process.stdout.read()

    In the log (stdout), I would occasionally see a “Still waiting…” – but only sometimes. Recently it’s happening with every single call to the script…

    So the output of my higher-level script is as follows:


    Turn Off - AT-BX-SR
    LWRF: /usr/local/bin/lightwaverf "AT-BX-SR" "AT-Lights" off
    /usr/local/bin/lightwaverf "AT-BX-SR" "AT-Lights" off
    Starting polling...
    Still waiting...
    LWRF: /usr/local/bin/lightwaverf "AT-BX-SR" "AT-Sounds" off
    /usr/local/bin/lightwaverf "AT-BX-SR" "AT-Sounds" off
    Starting polling...
    Still waiting...

    I do wish Lightwave would grow up and publish API changes before deploying the firmware! Actually I wish they’d do some test-first development and some manual testing as well, but hey!

    October 28, 2014 at 17:34 #16666
    mmcnamee
    Participant

    I can’t get that code to stay pre-formatted, advice on how to do this appreciated and I’ll edit the post! 🙂

    October 29, 2014 at 08:44 #16685
    pauly
    Participant

    no worries I got it emailed to me and all formatted there… I’ll add the timeout / polling into the gem itself, that’s a good call.
    My setup is working again, just not the energy monitor. It’s responding now but responding with a 0, so back to tech support.
    Ah first going to check if the energy monitor responds in a slightly different format now. If they’ve changed the format the code won’t be able to parse the response…

    I’m sending 666,@?
    I’m receiving 666,?W=0,0,0,0;

    Does that look right? Looks like the wifi link is responding as I would expect, just with all zeros, it has not got the correct value from the energy monitor.

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    November 13, 2014 at 21:31 #16933
    rodders
    Participant

    Hi I’m hoping for a bit of help if anyone can shed light on this I would appreciate it.

    Setup is RPI, Lightwaverf gem, and a bunch led sequencing stuff running on with a decent psu running the lot.

    The system was working fine for a year, then one day stopped responding, no ping and at the time, no idea where in the house it was. After finding it and trying a power cycle with no response I retired to the workbench with it, plugged it in and it sprang to life. However after it had come to life and I’d updated all the software with an apt-get etc. including updating the lightwaverf elements, regenerating the config file in the new format (yes it was that old) and testing from the command line to see everything working ok. I was rather disappointed to wake the next morning to darkness, no hot kettle and having to actually turn things on and off with my hands.

    After digging through the logs, I’m finding these errors :

    ### Updated timer cache - SUCCESS!
    2014-11-13 20:15:13 +0000 - Set device: main in room lounge to state off - FAILED!
    2014-11-13 20:15:13 +0000 - *** Ran timers - SUCCESS!
    2014-11-13 20:15:14 +0000 - ### Updated timer cache - SUCCESS!

    So it works from the command line but generates errors from the timer run commands.

    Any ideas ?

    I will try to contribute back in any way I can.

    Rods

    November 16, 2014 at 14:58 #16974
    rodders
    Participant

    Actually, I’ve got it sorted. Sharing just in case anyone comes across the same problem.

    In the early days of my Pi / Linux/ lightwaverf apprenticeship and my command line fu was a dangerous thing, in an effort to get cron jobs to work, I installed the lightwaverf script EVERYWHERE and there was an old one lurking in /usr/bin that the cron job still referenced, hence everything worked from the command line but the cronjob was running an old gem that didn’t work with the new config file formats.

    I am triumphantly sitting here in the dark after shutting the house down from google calendar once again.

    November 17, 2014 at 17:01 #16991
    pauly
    Participant

    glad to hear you are working again, sorry I didn’t get back here sooner to help…
    I’ve had to reinstall recently on fresh kit and it’s helped me find some improvements for the next version…

    12 rooms automated, time to stop now... API + more at https://github.com/pauly/lightwaverf
    January 27, 2015 at 22:21 #18122
    wrcaston
    Participant

    Hi guys,

    Using this gem is great from an RPi, but can someone shed some light on how the bash file should look like for a simple “lightwaverf Lounge Light on” command? I have written some code in C# that will run the bash file, I get text in the console but nothing is happening, I’m it is just printing the command rather than running it. So either the C# to run the command directly or to call a bash file to run the command. The C# way if anyone knows one is preferable but either way is fine.

    Secondly Pauly, I can’t for the life of me get the web page working, nor your robot-butler.

    Thanks in advance

You must be logged in to reply to this topic.