philipslight
philipslight copied to clipboard
Improve philips.light.moonlight support
Hello,
I have the following message in home assistant:
Unsupported device found! Please create an issue at https://github.com/syssi/philipslight/issues and provide the following data: philips.light.moonlight
I am a developper myself, and could help if needed.
Alex
Please update the custom component to the development version (branch: develop)! The device is already supported.
Hello, thanks for your help. I am noob to python and virtual envs, (i am .NET dev), so I don't know how to install the dev branch.
Went in my virtual env, ran this
pip3 install https://github.com/syssi/philipslight/archive/develop.zip
the result was
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting https://github.com/syssi/philipslight/archive/develop.zip Downloading https://github.com/syssi/philipslight/archive/develop.zip \ 102kB 1.0MB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/python3.5/tokenize.py", line 454, in open buffer = _builtin_open(filename, 'rb') FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-wuct2s7c/setup.py' Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-wuct2s7c/
So I tried with
(homeassistant) root@DietPi:/srv/homeassistant# python3 -m pip install https://github.com/syssi/philipslight/archive/develop.zip
Same result. What am I doing wrong?
I am sure this is a stupid question but I can't find the answer myself :(
I tried to find something to replace it in the libs, but looks like i miss some preprocessing or whatsoever (the files are splitted by type, unlike in the repository)
(homeassistant) root@DietPi:/srv/homeassistant/lib/python3.5/site-packages/miio# dir airconditioningcompanion.py device.py __pycache__ airfresh.py discovery.py tests airhumidifier.py exceptions.py updater.py airpurifier.py extract_tokens.py utils.py airqualitymonitor.py fan.py vacuum_cli.py ceil_cli.py __init__.py vacuumcontainers.py ceil.py philips_bulb.py vacuum_mapparser.py chuangmi_ir.py philips_eyecare_cli.py vacuum.py chuangmi_plug.py philips_eyecare.py version.py click_common.py philips_moonlight.py waterpurifier.py cli.py plug_cli.py wifirepeater.py cooker.py powerstrip.py wifispeaker.py data protocol.py yeelight.py
Please download & extract this file: https://github.com/syssi/philipslight/archive/develop.zip
Place the "custom_components" folder (incl. content) into your config directory. On hassbian the directory structure looks like this:
/home/homeassistant/.homeassistant/custom_components/light/xiaomi_miio.py
On hass.io it should be something like this:
/config/custom_components/light/xiaomi_miio.py
Restart Home Assistant and try to control the moonlight.
Hello, and merry christmas! Works perfectly, thank you very much :)
Il will try to use the sleep assistant and sleep off time features when I go back from holidays.
Thanks Again
I would be happy if you provide some details (example values, mihome settings -> moonlight behavior) about the sleep assistant & sleep off time features. Thanks in advance!
Of course, will do this either next weekend or the first week of january
I hope the naming of the properties (brand_sleep, brand f.e.) can also be improved some day if the meaning is known.
Hello, sorry for the delay, The component works perfectly!!! I try to figure out the meaning of the properties (brand_sleep, brand), it looks like it is an indicator of supported features (you can do anything, it never changes)
Alex
@AsWaM Do you own a Miband?
Yes, a miband 3
The property should be miband related. If you enable the "miband dependend turn off" the brand_sleep property should be true
. If you don't use the feature it's false
.
I will try this, and keep you informed
@syssi you were right, this is MiBand Related brand_sleep --> Auto power off with MiBand when asleep brand --> Auto power on/off when miband is close sleep_off_time --> remaining time before countdown ends (minutes) --> set to 0 if sleep mode deactivated total_assistant_sleep_time --> original countdown time (minutes)
Hello, I've found some issues related to the scenes. HA allows 1,2,3 and 4 only. But when I chose midnight theme from MI home, it shows as "6" in HA When I chose music mode, in HA i have the error below:
Got exception while fetching the state: {'code': -5001, 'message': 'music mode'}
@frkos How did you choose the "music mode"?
@frkos If you change this line in HA
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/xiaomi_miio/light.py#L91
Is scene 5 and 6 available/usable via the set_scene
service?
@frkos How did you choose the "music mode"?
Music mode is the colored button at the bottom of mi home.
@frkos If you change this line in HA
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/xiaomi_miio/light.py#L91
Is scene 5 and 6 available/usable via the
set_scene
service?
I have hass.io installation with doker. So I've set up ssh, connected to hassio.local, but couldn't find components folder to amend the file ((( If you let me know how to do this, I will be glad to help you with testing
Provide some testing on docker setups is hard. Could you install python-miio
(pip3 install python-miio
) on your desktop and provide some output of the miiocli
command line interface?
Provide some testing on docker setups is hard. Could you install
python-miio
(pip3 install python-miio
) on your desktop and provide some output of themiiocli
command line interface?
Here it is... Sorry for the screenshot, I'm doing it from my cell phone 😬
Is it what you need?
Perfect! Please try:
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "['4']"
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "['5']"
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "['6']"
Does it work?
Unfotunately, for apply_ I have param err, so i tried other options, but with timeout error((
Is it possible to increase it? BTW info, on,off... works, but not the raw_command
It looks like you missed a space between property (set_fixed_scene
) and the new value ("['1']"
). You could enable the deboug output of miiocli by -d
to get more insights / details.
Done... But with rhe same UART timeout error(
But set_scene without raw_command works. Of course, just for 1-4 options
Next try:
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "[4]"
miiocli device --ip 192.168.1.101 --token f.... raw_command get_prop "['scene']"
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "[5]"
miiocli device --ip 192.168.1.101 --token f.... raw_command get_prop "['scene']"
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "[6]"
miiocli device --ip 192.168.1.101 --token f.... raw_command get_prop "['scene']"
Note the removed single quotes for the numbers. The value must be an integer and no string.
Now it works for all scenes except 6. Also get_prop 'scene' doesn't work. But it works for get_prop 'status'... I think 'scene' is not available property name (
Also i confirm, that scene 5 is 'scrreen reading' from mi home app. And when I chose 'midnight' in mi home, I see 6 in HA. But can't set it via miiocli... Weird
Okay. Could you try to enable the night light by:
# make sure "scene 6" isn't active
miiocli device --ip 192.168.1.101 --token f.... raw_command apply_fixed_scene "[1]"
# get the scene property called "snm"
miiocli device --ip 192.168.1.101 --token f.... raw_command get_prop "['snm']"
# enable the night light mode?
miiocli device --ip 192.168.1.101 --token f.... raw_command enable_bl "[True]"
# the value of snm should be 6 now
miiocli device --ip 192.168.1.101 --token f.... raw_command get_prop "['snm']"
# turn off the night light mode?
miiocli device --ip 192.168.1.101 --token f.... raw_command enable_bl "[False]"
# check the scene again
miiocli device --ip 192.168.1.101 --token f.... raw_command get_prop "['snm']"
Looks like it's not for scene 6... Also i tried "['on']" and "[1]" but with the same result
Could you try
miiocli device --ip 192.168.1.101 --token f.... raw_command go_night "[]"
too?
And now it works! As I'm doing it remotely, I can check the lamp itself in the evening only. But HA shows scene 6 and Mi Home shows midnight scene. So it definitely works.
I tried go_music randomly and it works too - MI home opens music mode screen. So as I understand, the only promblem is that HA expects scene as int, and crashes when receive str 'music mode'. Maybe in the code it's pissible to map music mode to scene 7, for example... And we are done )