HiI 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 ProblemThis module works fine in eventghost but not in Vox. The script allows me to call simple code to control the lights like
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
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
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 FinallySo 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