Closed chros73 closed 9 years ago
Hi The easy solution: create a php file, add desired functionality using my class and create a cron to run this php file. (install php on your OpenWRT before doing this)
As I'm not very good in bash script I recommend you to visit (FYI: limitlessled and easybulb have the same hardware spec and use the same API) http://www.limitlessled.com/dev/ http://smileytechadventures.blogspot.co.nz/2013/07/control-limitless-led-from-linux-bash.html
#!/bin/bash
if [ -z "$1" ] ; then
echo "You must enter a parameter: "
echo " e.g. $0 allon"
exit 1
fi
incmd="$1"
ipaddress="255.255.255.255"
portnum="8899"
allon="\x42\00\x55"
alloff="\x41\00\x55"
#note for disco commands these will impact the group you are currently in for example if you previously typed "./bashlight group2on" then
#when you turn on disco it will only affect group 2, if you want disco to apply to all then type "./bashlight allon" first
discoon="\x4D\00\x55"
discofaster="\x44\00\x55"
discoslower="\x43\00\x55"
discomode="\x4D\00\x55"
group1on="\x45\00\x55"
group1off="\x46\00\x55"
group2on="\x47\00\x55"
group2off="\x48\00\x55"
group3on="\x49\00\x55"
group3off="\x4A\00\x55"
group4on="\x4B\00\x55"
group4off="\x4C\00\x55"
#Set all to white
allwhite="\xC2\00\x55"
#Set Group 1 to white
group1white="\xC5\00\x55"
group2white="\xC7\00\x55"
group3white="\xC9\00\x55"
group4white="\xCB\00\x55"
#Working (range: 2 to 27 need to work out Hexidecimal eg Hexidecimal 1B is Decimal 27
#note this will impact the group you are currently in for example if you previously typed "./bashlight group2on" then
#when you adjust the brightness it will only affect group 2, if you want the brightness to apply to all groups then type "./bashlight allon" first
#Special NOTE #1: The LimitlessLED bulb remembers its own Brightness setting memory separately for ColorRGB and separately for White.
#For example dimming Green, then switching to White full brightness, and when you go back to a specific color the brightness returns
#to what the ColorRGB was before. Same vice versa for the White. The previous brightness setting is remembered specifically for the
#White and specifically for the ColorRGB.
brightest="\x4E\x1B\x55"
lowest="\x4E\x02\x55"
half="\x4E\xd\x55"
#Colours
# 0x00 Violet
# 0x10 Royal_Blue
# 0x20 Baby_Blue
# 0x30 Aqua
# 0x40 Mint
# 0x50 Seafoam_Green
# 0x60 Green
# 0x70 Lime_Green
# 0x80 Yellow
# 0x90 Yellow_Orange
# 0xA0 Orange
# 0xB0 Red
# 0xC0 Pink
# 0xD0 Fusia
# 0xE0 Lilac
# 0xF0 Lavendar
# Note there are more colours (0-255) in between, this color chart is just steps of 16.
# and they are incrementing by 10 so example mint is 40 but you could use 41 42 43 44 45 etc for the in between colours
#First byte x40 says change colour , second byte is the colour that you want.
#Usage note when using these commands they will impact the current active group for example if you previously typed "./bashlight group2on" then
#when you adjust the colour it will only affect group 2, if you want the colour to apply to all then type "./bashlight allon" first
#or if you wanted to make only group 1 red then type "./bashlight group1on" first then "./bashlight col_red"
col_violet="\x40\x00\x55"
col_royal_blue="\x40\x10\x55"
col_baby_blue="\x40\x20\x55"
col_aqua="\x40\x30\x55"
col_mint="\x40\x40\x55"
col_mint2="\x40\x45\x55"
col_seafoam_green="\x40\x50\x55"
col_green="\x40\x60\x55"
col_lime_green="\x40\x70\x55"
col_yellow="\x40\x80\x55"
col_yelloworange="\x40\x90\x55"
col_orange="\x40\xA0\x55"
col_red="\x40\xB0\x55"
col_pink="\x40\xC0\x55"
col_fusia="\x40\xD0\x55"
col_lilac="\x40\xE0\x55"
col_lavendar="\x40\xF0\x55"
eval incmd=\$$incmd
echo -n -e "$incmd" >/dev/udp/"$ipaddress"/"$portnum"
and also this may help you
http://iqjar.com/jar/wake-up-gently-to-gradually-increasing-light/
Thanks, I went through quickly all the links you gave me :) Maybe I wasn't straightforward enough in my 1st post: that IS the solution which is working! :) (I didn't want to use bash since it's not available on lot's of platforms, I wanted to make it more general.) And, yes, I didn't know that Easybulb is just a rebranded limitless bulb :) Thank you, again!
I read your comment again and got it . Thank you for sharing your solution.
One more thing, about how portable that script is (using your approach): it took me half an hour to port it to Windows :) (I'm using Windows 8.1 x64), including finding the ported necessary nc
and printf
commands.
nc
from here (we can use the without -e
version): http://joncraton.org/blog/46/netcat-for-windows/printf
from the unixutils: http://unxutils.sourceforge.net/c:\Windows
directoryAnd the batch scripts, save them into a directory:
EasybulbVariables.cmd
ECHO Off
REM Easybulb variables
SET rgbwGroup1On="\x45\x00"
SET rgbwGroup1Off="\x46\x00"
SET rgbwSetColorToYellow="\x40\x80"
SET rgbwBrightness80="\x4e\x16"
SET host="192.168.10.50"
SET port="8899
SET nc=nc -n -u -w1 %host% %port%
SET printf=printf
EasybulbTurnOn.cmd
ECHO Off
REM Turn On group 1, set colour and brightness
call EasybulbVariables.cmd
%printf% %rgbwGroup1On% | %nc%
%printf% %rgbwSetColorToYellow% | %nc%
%printf% %rgbwBrightness80% | %nc%
EasybulbTurnOff.cmd
ECHO Off
REM Turn Off group 1
call EasybulbVariables.cmd
%printf% %rgbwGroup1Off% | %nc%
Create a desktop shortcut for EasybulbTurnOn.cmd
and EasybulbTurnOff.cmd
and there you go: "Let there be light" or dark! :)
And let me thank you one more time: that was exactly what I have been looking for half a year!
https://github.com/mrwhale/limitlessled-bash
Here is a bash script I wrote for this purpose, I use it with my raspberry pi and cron. Should also work on openwrt and any other *nix OSes too!
Thanks mrwhale, if I knew about your script I wouldn't have to reinvent the wheel :)
1 note: ash
shell on openwrt doesn't support arrays, for example, who knows what else. That's why I wanted to make it generic.
I like the way how you fallback from bash builtin to nc when sending data.
Thanks for you script!
Hi!
It's not an issue, but rather I want to say a big Thank You! :)
I have bought couple of Easybulb rgbw bulbs a half a year ago and I didn't know to to communicate with them. All I wanted to do is:
I couldn't do so far, until I've found your code :) :
Based on your API, here's a simple script on OpenWRT Chaos Chalmer, called e.g.
manageEasybulb.sh
, what we can use in cron (maybe it will be useful for somebody else as well):