Mi_light Ibox v6 (API) not working

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post
User avatar
borwolf
Posts: 6
Joined: Saturday 21 March 2015 17:51
Target OS: Windows
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby borwolf » Sunday 01 January 2017 21:42

Looks like there is movement in using a switch from domoticz with the ibox v6.0
Its only on and off switch. (site in dutch)

Big thanks to bwydoogh.

https://github.com/bwydoogh/domoticz-scripts

https://gathering.tweakers.net/forum/li ... 3#49691573

bwydoogh
Posts: 4
Joined: Monday 26 December 2016 12:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby bwydoogh » Tuesday 03 January 2017 8:17

Great to see my script is shared over here :). It is a very basic script, which is currently able to turn ON or OFF all bulbs.
It is still a work in progress as I plan to implement other features (color setting, dimming, zone control...).

ziaziung
Posts: 16
Joined: Friday 13 February 2015 11:23
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby ziaziung » Tuesday 03 January 2017 18:29

Thank you bwydoogh. :D

It works for me with Milight IBox V6 and RGBWW Gu10 Milight lamps. :P

Just a remark :


Steps to follow:

Put the script in your Domoticz scripts folder
Change the IP address of the iBox controller in the script: variable UDP_IP
Add a virtual/dummy switch in Domoticz (see https://www.domoticz.com/wiki/Wemo#Crea ... y_Switches )
The ON action of the dummy switch should be set to: script:///<script location>/milight-home.py ON
The OFF action of the dummy switc should be set to: script:///<script location>/milight-home.py OFF

deennoo
Posts: 561
Joined: Wednesday 10 December 2014 14:06
Target OS: Raspberry Pi
Domoticz version:
Location: Bordeaux France
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby deennoo » Tuesday 03 January 2017 23:27

OK guys, you start something great, maybe it's time to made a python plugin for domoticz : https://www.domoticz.com/wiki/Developin ... hon_plugin
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

deennoo
Posts: 561
Joined: Wednesday 10 December 2014 14:06
Target OS: Raspberry Pi
Domoticz version:
Location: Bordeaux France
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby deennoo » Wednesday 04 January 2017 1:44

@bwydoogh

I made some addition to your py script by adding disco control and brightness for wifibox. just made pull request on your github.

Left controling color on wifi box;
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

bwydoogh
Posts: 4
Joined: Monday 26 December 2016 12:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby bwydoogh » Wednesday 04 January 2017 8:01

deennoo wrote:@bwydoogh

I made some addition to your py script by adding disco control and brightness for wifibox. just made pull request on your github.

Left controling color on wifi box;


Great :). Really appreciated :).

I merged the pull request (but modified (after merging...) some minor code stuff (f.e. use of elif)).

Thanks!

deennoo
Posts: 561
Joined: Wednesday 10 December 2014 14:06
Target OS: Raspberry Pi
Domoticz version:
Location: Bordeaux France
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby deennoo » Wednesday 04 January 2017 11:48

New pull request for Color order on the bridge.

Next step :
- automatique calcul for checksum
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

Bastien
Posts: 19
Joined: Friday 31 July 2015 10:12
Target OS: Windows
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby Bastien » Wednesday 04 January 2017 18:05

Hi all,

I've seen this discussion and as I've just bought some milight products, (I think) I'm concerned by it. I'm really regarding milight products, and my skills regarding scripts are quite null...I'm trying to use the script you've made but I have some questions to make it work :

- First I have an Ibox 1, so can you confirm that I need your script to be able to use it in DOmoticz ?
- When editing the script, to modify the ip adress, don't I also need to modify the port ? When I look in the Ibox1 settings, default port is 8899.
- I'm using Domoticz on Windows (yeah I know...nobody is pefect... :? ) can you help me regarding the path to put in "On Action" ? If my file is in C:\Program Files (x86)\Domoticz\scripts\python, I should put : script:///C:\Program Files (x86)\Domoticz\scripts\python/milight-home.py ON ?

Thank you in advance for your patience... :D

User avatar
LumKitty
Posts: 24
Joined: Sunday 11 October 2015 12:50
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: South Wales, UK
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby LumKitty » Thursday 05 January 2017 1:25

I've taken the script at the start of this thread, and expanded on it massively. It implements all milight functions (except the iBox light because that thing is stupid), and some nice functions like smoothly fading on/off, smoothly to/from colour/white, color temp setting/fading.

Some simple sample scripts are included which are literally the ones I'm using in Domoticz to turn the lights on/off and to swap colour temperatures at sunset/sunrise. Let me know if there's any bugs as it hasn't had a huge amount of testing yet and I've no idea how to get the domoticz RGBW selector to appear or to make it call my scripts.

On my todo list is to provide an option for sending to a serial port for people who have done the hack where you remove the wifi board from the milight PCB and attach it to the serial pins on a Pi, but I've not done this hack myself yet (my MiLight 2.0 box is on those pins!), so can't test it.

https://github.com/LumKitty/MiLight3

Code: Select all

import milightbox
milight = milightbox.MiLight3("192.168.1.1", 5987)           # hostname/IP and port are optional

# Basic bulb colour setting commands

milight.on(1,100)        # Turn zone 1 on at 100% brightness # brightness optional but recommended
milight.off(1)           # Turn zone 1 off
milight.night(1)         # Set zone 1 to nightlight          # this resets colour temperature to 100 (cool) as the
                                                             # nightlight is in cool white
milight.white(1)         # Set zone 1 to white
milight.brightness(1,50) # Set zone 1 to 50% brightness      # works on both white and colour
milight.colour(1,255,50,100) # Set zone 1 to hue 255, 50% saturation, 100% brightness
milight.saturation(1,50) # Set zone 1 to 50% saturation      # works on colour only
milight.temperature(1,0) # Set zone 1 to warm white          # works on white only
milight.status(1)        # Print the current stored values for zone 1 - used for debugging

# Fade commands - in all cases there is an optional speed parameter not shown. Note these only work correctly if
#                 you don't mess with the bulbs via an external method, such as the app or remote control.
#                 These commands handle transition from night, colour or white to colour or white

milight.fadetocolour(1,255,0,100) # Smoothly fade zone 1 to pure red at 100% brightness
milight.fadetowhite(1,50,100)     # Smoothly fade zone 1 to cold white at 50% brightness
milight.fadeoff(1)                # Smoothly fade out zone 1 then turn it off
milight.fadetotemp(1,0)           # Smoothly fade zone 1 to warm white

print milight.IsDay()             # True if the sun hasn't set yet
Last edited by LumKitty on Thursday 05 January 2017 1:32, edited 1 time in total.

deennoo
Posts: 561
Joined: Wednesday 10 December 2014 14:06
Target OS: Raspberry Pi
Domoticz version:
Location: Bordeaux France
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby deennoo » Thursday 05 January 2017 1:31

Great ! Some cool fonction again !

I'm sure we can provid a plugin for the next stable !
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

bwydoogh
Posts: 4
Joined: Monday 26 December 2016 12:21
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby bwydoogh » Thursday 05 January 2017 7:52

LumKitty wrote:I've taken the script at the start of this thread, and expanded on it massively. It implements all milight functions (except the iBox light because that thing is stupid), and some nice functions like smoothly fading on/off, smoothly to/from colour/white, color temp setting/fading.

Some simple sample scripts are included which are literally the ones I'm using in Domoticz to turn the lights on/off and to swap colour temperatures at sunset/sunrise. Let me know if there's any bugs as it hasn't had a huge amount of testing yet and I've no idea how to get the domoticz RGBW selector to appear or to make it call my scripts.

On my todo list is to provide an option for sending to a serial port for people who have done the hack where you remove the wifi board from the milight PCB and attach it to the serial pins on a Pi, but I've not done this hack myself yet (my MiLight 2.0 box is on those pins!), so can't test it.

https://github.com/LumKitty/MiLight3

Code: Select all

import milightbox
milight = milightbox.MiLight3("192.168.1.1", 5987)           # hostname/IP and port are optional

# Basic bulb colour setting commands

milight.on(1,100)        # Turn zone 1 on at 100% brightness # brightness optional but recommended
milight.off(1)           # Turn zone 1 off
milight.night(1)         # Set zone 1 to nightlight          # this resets colour temperature to 100 (cool) as the
                                                             # nightlight is in cool white
milight.white(1)         # Set zone 1 to white
milight.brightness(1,50) # Set zone 1 to 50% brightness      # works on both white and colour
milight.colour(1,255,50,100) # Set zone 1 to hue 255, 50% saturation, 100% brightness
milight.saturation(1,50) # Set zone 1 to 50% saturation      # works on colour only
milight.temperature(1,0) # Set zone 1 to warm white          # works on white only
milight.status(1)        # Print the current stored values for zone 1 - used for debugging

# Fade commands - in all cases there is an optional speed parameter not shown. Note these only work correctly if
#                 you don't mess with the bulbs via an external method, such as the app or remote control.
#                 These commands handle transition from night, colour or white to colour or white

milight.fadetocolour(1,255,0,100) # Smoothly fade zone 1 to pure red at 100% brightness
milight.fadetowhite(1,50,100)     # Smoothly fade zone 1 to cold white at 50% brightness
milight.fadeoff(1)                # Smoothly fade out zone 1 then turn it off
milight.fadetotemp(1,0)           # Smoothly fade zone 1 to warm white

print milight.IsDay()             # True if the sun hasn't set yet


What a great work :). Great job, and I am glad I initiated some nice work around this new API. I don't have the time to put that much time in this development, so I guess users can switch to your script. I will still use mine for my own purposes here at home (I do use the iBox led light for example...). Anyway, thanks a lot!

User avatar
LumKitty
Posts: 24
Joined: Sunday 11 October 2015 12:50
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: South Wales, UK
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby LumKitty » Thursday 05 January 2017 11:20

I'll add support for the iBox light eventually. I do have plans for mine. It's just not a top priority and I haven't decided how best to implement it. I'll probably make it into zone -1 or Something, then ignore saturation values.

Also please note that using zone 0 as an all lights control is not supported, and while it might work, it'll screw up the state tracking. I have a plan to fix this for the basic (non-fade) commands, but doing a zone 0 fade is going to be bloody hard.

ziaziung
Posts: 16
Joined: Friday 13 February 2015 11:23
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby ziaziung » Thursday 05 January 2017 20:00

Hi LumKitty. Great job. iBox light not so stupid. We could use it for, for example, to know an new email is in the box, or a motion detector has been actived,.....

Can you, please, explain how to use your script in Domoticz?

User avatar
LumKitty
Posts: 24
Joined: Sunday 11 October 2015 12:50
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: South Wales, UK
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby LumKitty » Thursday 05 January 2017 20:47

Using it well in domoticz is still something I'm working on as I've no idea where to start with integrating it.

For now I'm just creating a dummy switch and making calls to

script:///home/domoticz/milight/milight-on.py 1
script:///home/domoticz/milight/milight-off.py 1

in the script actions for the switch.

iBox is on my todo list. I intend to use it for the doorbell, phone, email etc. It's just not my priority, and when that thing turned up on my doorstep I was a bit WTF.

ziaziung
Posts: 16
Joined: Friday 13 February 2015 11:23
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby ziaziung » Thursday 05 January 2017 22:12

Not working :
I've written
script:///home/pi/domoticz/scripts/python/milight-on.py 1
in "Action on"
and

script:///home/pi/domoticz/scripts/python/milight-off.py 1
in "Action off"

of a switch,

and get this error in log

2017-01-05 21:07:32.318 Executing script: /home/pi/domoticz/scripts/python/milight-off.py
2017-01-05 21:07:32.341 Error: Error executing script command (/home/pi/domoticz/scripts/python/milight-off.py). returned: 32256

User avatar
LumKitty
Posts: 24
Joined: Sunday 11 October 2015 12:50
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: South Wales, UK
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby LumKitty » Thursday 05 January 2017 22:15

Can you run that script directly from the command line and paste the actual error returned?

also make sure that milightbox.py is in the same directory as milight-on.py as that is where most of the code lives.


Also for those asking for iBox support. I literally have it sat next to me on the sofa and am about to start poking at it :)

User avatar
LumKitty
Posts: 24
Joined: Sunday 11 October 2015 12:50
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: South Wales, UK
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby LumKitty » Thursday 05 January 2017 23:49

Ok the iBox light is being a PITA. The documented codes don't seem to work (eg. the one to set it to white actually turns it off) apart from basic on/off. I can't be bothered to search for the real codes manually as there's loads of them, so that's on hold for now.

I've emailed the limitless people asking for clarification on the API.

deennoo
Posts: 561
Joined: Wednesday 10 December 2014 14:06
Target OS: Raspberry Pi
Domoticz version:
Location: Bordeaux France
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby deennoo » Friday 06 January 2017 0:31

Have a look here :

All fonction for ibox are working :
https://github.com/bwydoogh/domoticz-scripts
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

ziaziung
Posts: 16
Joined: Friday 13 February 2015 11:23
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby ziaziung » Friday 06 January 2017 12:47

@LumKitty :
Hi. Here's my /domoticz/scripts/python directory :
[email protected] ~/domoticz/scripts/python $ ls -al
total 76
drwxr-xr-x 2 pi pi 4096 janv. 6 11:28 .
drwxr-xr-x 6 pi pi 4096 déc. 29 17:22 ..
-rw-r--r-- 1 pi pi 3751 août 15 2015 domoticz.py
-rwxr-xr-x 1 pi pi 66 janv. 5 18:41 isday.py
-rwxr-xr-x 1 pi pi 15299 janv. 5 18:45 milightbox.py
-rwxr-xr-x 1 pi pi 3403 janv. 3 17:23 milight-home.py
-rwxr-xr-x 1 pi pi 62 janv. 2 18:54 milight-home-trigger.sh
-rwxr-xr-x 1 pi pi 158 janv. 5 18:41 milight-off.py
-rwxr-xr-x 1 pi pi 184 janv. 5 18:42 milight-on.py
-rwxr-xr-x 1 pi pi 309 janv. 5 18:42 milight-temp.py
-rw-r--r-- 1 pi pi 1302 août 15 2015 reloader.py
-rw-r--r-- 1 pi pi 1213 août 15 2015 script_device_PIRsmarter.py



Here are my tries :
[email protected] ~/domoticz/scripts/python $ ./milight-on.py 1
Traceback (most recent call last):
File "./milight-on.py", line 2, in <module>
import sys,milightbox
File "/home/pi/domoticz/scripts/python/milightbox.py", line 1, in <module>
import socket,sys,time,os,ephem;
ImportError: No module named ephem
[email protected] ~/domoticz/scripts/python $ python milight-on.py 1
Traceback (most recent call last):
File "milight-on.py", line 2, in <module>
import sys,milightbox
File "/home/pi/domoticz/scripts/python/milightbox.py", line 1, in <module>
import socket,sys,time,os,ephem;
ImportError: No module named ephem
[email protected] ~/domoticz/scripts/python $ python milight-on.py
Traceback (most recent call last):
File "milight-on.py", line 2, in <module>
import sys,milightbox
File "/home/pi/domoticz/scripts/python/milightbox.py", line 1, in <module>
import socket,sys,time,os,ephem;
ImportError: No module named ephem


It seems it needs a ephem python module. Right?

Nautilus
Posts: 319
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi
Domoticz version: beta
Location: Finland
Contact:

Re: Mi_light Ibox v6 (API) not working

Postby Nautilus » Friday 06 January 2017 13:52

ziaziung wrote:It seems it needs a ephem python module. Right?


There's a README file in Github:
Python 2.7 control class for controlling MiLight-3.0 (Limitless V6.0) lights.
Edit default settings in milightbox.py for IP, PORT speed etc. Requires PyEphem for the IsDay function pip install ephem or just remove that whole function if you don't want it. iBox light not yet supported because that thing is a bit stupid really.

:)


Return to “Bugs and Problems”

Who is online

Users browsing this forum: No registered users and 4 guests