Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mrDavisma

Pages: [1]
1
That sounds good, Off to work now so will have a play when I get home then. thanks for the help

Mark

2
I probably didn't read the original post carefully enough.  Sorry about that!  :bonk

No worries mate lol Thank you for the great program! I will be picking up a licence as soon as I make it useful to my wife and get permission lol

3
Hi guys
           Thank you for your quick replies!
James I already had the ledcontroller in the lib folder. I worked that bit out lol. I understand I would not be able to import eg within voxcommando, the code I posted is the one made for eventghost to use to process the events sent from voxcommando. I just wanted to try and use python within voxcommando to keep everything " In the same basket"
I wanted to use python because it seems easier to build and use more complex phases like " turn the main light on change the colour to red and dim to twenty" etc also I will look to incorporate  setting varibles in the same code for remembering individual light states and last active light etc

Hi nime5ter
                 cheers for the info. I did look line 168 in the code and tried traced it back it back to the import socket but didn't know where to go from there but at least I know why it may not be working.
I will take another look at the link James posted but it seems to need many commands for everything where as using the code I have with just 3 commands I can control all the lights individually with just 3 command phases

all else fails i will just continue to pass the payloads to eg from vox

Thanks

Mark

4
Python Scripting / milight (limitlessled) control python module error
« on: March 04, 2015, 12:15:36 PM »
Hi
I recently got some Mi Lights and straight away looked for better ways to control them, first through eventghost as I used it but then I found voxcommando! So with no python experience I set off and found the module https://github.com/ojarva/python-ledcontroller with this I can simple use comands like led.on(1)
My Problem
This module works fine in eventghost but not in Vox. The script allows me to call simple code to control the lights like
Code: [Select]
import ledcontroller
led = ledcontroller.LedController("ip.ad.re.ss")
led.on(1) # the command
This works in eventghost fine however when i try using it in voxcommando I get an error

Code: [Select]
python ready
Line: 168 >>
TypeError: expected str, got bytes
being a noob to python I could not fix this (nor can I now!) so I bypassed python in vox and passed payloads to eventghost to run the python. After a few days of learning python I came up with this bit of code

Code: [Select]
import eg
import ledcontroller
led = ledcontroller.LedController("192.168.0.115")
red, royal_blue, green, yellow, white = "red", "royal_blue", "green", "yellow", "white"
a, b, c, d, e, f, g, h, i, j = "10",  "20", "30", "40", "50", "60", "70", "80", "90", "100"
main_light, side_light, back_light, living_room_lights, dinning_room_light = 1, 4, 2, 0, 3
on = "on"
off = "off"
v = "set_brightness"
w = "set_color"
y = eg.event.payload[1]
x = eg.event.payload[2]
z = "led."
group = [main_light, side_light, back_light, living_room_lights, dinning_room_light]
power = [on, off]
colour = [red, royal_blue, green, yellow, white]
dim = [a, b, c, d, e, f, g, h, i, j,]
if x in group:
    x = x

if y in power:
    mycommand = z + y +"(" + (x) + ")"
    exec mycommand
if y in colour:
    mycommand = z + w + "("  + '"' + y + '"' + ", " + x + ")"
    print mycommand
    exec mycommand
if y in dim:
    mycommand = z + v + "("  +  y +  ", " + x + ")"
    exec mycommand
print x
print y


I am very happy with this  :) python is fun lol. This code works great, upon receiving payloads in eventghost from voxcommando.
I want to continue my learning by expanding on this code to set values etc so I can use vox commando to remember lights status ( if on or off etc ) as Mi lights have no talk back feature like the philips hue do  :( but to make this easier for me now to right the code and later to share it with people it would be better if I could get the ledcontroller module to work in voxcommander so I dont have to go back and forth between Vox and Eg

So Finally
So after my long winded post ( Sorry ) Can someone have a look at the module and try and work out why it works in eventghost but not voxcommando and if there is a away to fix it please

Thanks

Mark

Pages: [1]