tfriedel / python-lightify Goto Github PK
View Code? Open in Web Editor NEWThis project forked from andreasofthings/python-lightify
Python module for Osram lightify. This is a work in progress.
License: Apache License 2.0
This project forked from andreasofthings/python-lightify
Python module for Osram lightify. This is a work in progress.
License: Apache License 2.0
This is a minor feature request to support an external LogHandler in order to output logging info for debugging/etc.. I am using this library with a home-grown plugin for Indigo Domotics ( https://github.com/rbdubz3/sylvania-lightify-indigo ).
See sample code snippets below - updated constructor plus new method to allow changing the log level:
class Lightify:
""" main osram lightify class
"""
def init(self, host, new_device_types=None, loghandler=None):
.......
.......
.......
'max_temp': 6500
}
}
}}
"""
self.__device_types = DEVICE_TYPES.copy()
self.__device_types.update(new_device_types or {})
self.__logger = logging.getLogger(MODULE)
self.__logger.setLevel(logging.INFO)
if loghandler is not None:
self.__logger.addHandler(loghandler)
else:
self.__logger.addHandler(logging.NullHandler())
self.__logger.info("Initializing python %s, version=%s", MODULE, __version__)
# a sequence number used to number commands sent to the gateway
self.__seq = 0
.......
.......
.......
def set_loglevel(self, debugLevel):
self.__logger.setLevel(debugLevel)
level_str = 'NOTSET'
if debugLevel == logging.DEBUG:
level_str = 'DEBUG'
elif debugLevel == logging.INFO:
level_str = 'INFO'
elif debugLevel == logging.WARNING:
level_str = 'WARNING'
elif debugLevel == logging.ERROR:
level_str = 'ERROR'
elif debugLevel == logging.CRITICAL:
level_str = 'CRITICAL'
self.__logger.info("set_loglevel to '%s'", level_str)
I'm getting the following error with Home-Assistant 0.102.3 & 0.103.0 and my Osram Lightify Gateway (current FW).
2019-12-12 01:29:53 INFO (SyncWorker_5) [homeassistant.loader] Loaded osramlightify from homeassistant.components.osramlightify
2019-12-12 01:29:54 INFO (MainThread) [homeassistant.components.light] Setting up light.osramlightify
2019-12-12 01:29:54 WARNING (SyncWorker_16) [lightify] Unknown device type id: 0. Please report to https://github.com/tfriedel/python-lightify
2019-12-12 01:29:54 INFO (SyncWorker_16) [lightify] Initializing lightify, version=1.0.7.2
There is no functionality to activate a scene now. According to https://github.com/noctarius/lightify-binary-protocol#packet_activate_scene there is a way to do so (though it's not really clear how to get a scene ID).
External Lightify API supports scenes already: https://docs.lightify-api.com/#d0237010-be9a-4994-a9bb-88aefa272c8a .
Thanks!
Is this just a PyPi error or something on my end?
https://pypi.org/project/lightify/
returns a 404 and pip install lightify
(homeassistant3.8) homeassistant@ubuntu:~/.homeassistant/custom_components$ pip install lightify==1.0.72
ERROR: Could not find a version that satisfies the requirement lightify==1.0.72 (from versions: none)
ERROR: No matching distribution found for lightify==1.0.72
WARNING: You are using pip version 20.2.1; however, version 21.0.1 is available.
You should consider upgrading via the '/srv/homeassistant3.8/bin/python3.8 -m pip install --upgrade pip' command.
A large number of errors/warnings in my Indigo Domotics setup which uses python lightify version 1.0.7.1.. Below is the dump of indigo plugin log along with Warnings from the lightify plugin (reference messages 'LightifyDirect Warning'
Error Block 1
Sylvania Lightify Starting concurrent thread
LightifyDirect Warning Couldn't unpack light status packet:
LightifyDirect Warning struct.error: unpack requires a string argument of length 50
LightifyDirect Warning payload: 060000000000000000
Sylvania Lightify Error Error in plugin execution runConcurrentThread:
Traceback (most recent call last):
File "plugin.py", line 297, in runConcurrentThread
File "/Library/Application Support/Perceptive Automation/Indigo 7.2/Plugins/SylvaniaLightify.indigoPlugin/Contents/Server Plugin/lightify/init.py", line 1309, in update_group_list
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa4 in position 2: invalid start byte
Sylvania Lightify Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Sylvania Lightify Starting concurrent thread
LightifyDirect Warning Unknown device type id: 105. Please report to https://github.com/tfriedel/python-lightify
LightifyDirect Warning Unknown device type id: 115. Please report to https://github.com/tfriedel/python-lightify
LightifyDirect Warning Unknown device type id: 77. Please report to https://github.com/tfriedel/python-lightify
LightifyDirect Warning Couldn't unpack light status packet:
LightifyDirect Warning struct.error: unpack requires a string argument of length 50
LightifyDirect Warning payload: 61204c6967687473000000000a004d656469612054560000000000000000
Sylvania Lightify Error Error in plugin execution runConcurrentThread:
Traceback (most recent call last):
File "plugin.py", line 297, in runConcurrentThread
File "/Library/Application Support/Perceptive Automation/Indigo 7.2/Plugins/SylvaniaLightify.indigoPlugin/Contents/Server Plugin/lightify/init.py", line 1309, in update_group_list
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa4 in position 2: invalid start byte
Sylvania Lightify Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
****** End Error Block 1
NOTE - no new devices were actually added to my system so I suspect this is something different. There were a large number of recurring errors prior to the above Warnings about missing device types.. The errors were as seen below - potentially some type of memory corruption in my system with python? From what I can tell, the python utf8 errors in 'Error Block 2' persisted throughout the night repeatedly while the ones listed above for the missing device types in 'Error Block 1' occurred just once this morning - triggered via motion sensor as I entered a room.
Error Block 2
Traceback (most recent call last):
File "plugin.py", line 297, in runConcurrentThread
File "/Library/Application Support/Perceptive Automation/Indigo 7.2/Plugins/SylvaniaLightify.indigoPlugin/Contents/Server Plugin/lightify/init.py", line 1309, in update_group_list
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py", line 16, in decode
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa4 in position 2: invalid start byte
Sylvania Lightify Error plugin runConcurrentThread function returned or failed (will attempt again in 10 seconds)
Sylvania Lightify Starting concurrent thread
Sylvania Lightify Error Error in plugin execution runConcurrentThread:
***** End Error Block 2
Anyhow, thought I'd pass along in case it is of any value
According to https://github.com/noctarius/lightify-binary-protocol, it may be possible to read "Battery value", "Enabled value" and "Triggered value" for motion sensors.
Unfortunately, I don't have one and can't help here.
I can use the various accessor methods for all properties, except alpha. For alpha
I need to to use raw_values tuple, would be nice to add aplha()
to the Light
class to avoid need to handle raw_values()
, e.g. to avoid something like this:
# Alpha is only available from raw_values()
(onoff, lum, temp, red, green, blue, alpha) = light.raw_values()
# if online is false then override on to be false, the light can't be on if it's not even powered on
state = {
"online": light.reachable(),
"lastSeen": light.last_seen(),
"on": (light.reachable() and light.on()),
"lum": light.lum(),
"temp": light.temp(),
"colour": {
"red": light.red(),
"green": light.green(),
"blue": light.blue()
},
"alpha": alpha
}
At the moment the library reports all devices as bulbs. According to https://github.com/noctarius/lightify-binary-protocol#device-types it should be possible to distinct them.
See also home-assistant/core#12206 .
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.