Written some Osram Lightify support

Hi,
I’d like to confirm the same as @tchellomello that thanks to @tfriedel and @MindrustUK I’ve had no issues after running the osramlightify.py and init.py code on my HA too.

Hello! I’ve been having problems with my osram lightify bulbs as you guys had. The thing is, I’ve tried to read all of the posts in this thread but it’s all so fragmented. Can someone post the simple steps to get this ‘fixed’ in a single post? I’d greatly appreciate it for us noobs! :slight_smile:

1 Like

Hello @enricfp1,

Let me see if I can summarize it for you. The steps you have to do to are:

  1. First you have to create the directory structure to override the current osramlightify.py. So create the following directories under configuration directory (the directory that has configuration.yaml file)
$ cd /home/hass/.homeassistant    # <== this is my configuration directory for HA
$ mkdir -p custom_components/light
$ cd custom_components/light
$ wget https://raw.githubusercontent.com/MindrustUK/python-lightify/master/osramlightify.py

The result will be a new file under home/hass/.homeassistant/custom_components/light/osramlightify.py

  1. The second step now is to override the __init__.py file that will be under the deps directory. Note that the deps directory is created automatically to download on the fly the HA dependencies. For example, if you upgrade your HA, the deps directory will be deleted and created again. That means you will need to repeat this step 2. You should already have the deps/lightify directory created. If not, start normally HA and then you can replace the file.
$ cd /home/hass/.homeassistant/deps/lightify/
$ mv __init__.py __init__.py.old
$ wget https://raw.githubusercontent.com/tfriedel/python-lightify/master/lightify/__init__.py

Restart your HA and you should be good to go.

Please let me know if you have need any further assistance.

Marcelo

3 Likes

Thank you so much! Easy to follow and great explanation to all the steps. I’ve followed them and HA is back up and running. I’ll edit this post in a day or so to update if it’s fixed my issues.

Thanks again! :slight_smile:

2 Likes

Had a lot of network timeouts after I updated to latest version but it turned out there was problems with network earlier and this new version just brought it up. Seems there are serious problems with Raspberry pi3’s wifi. My Pi is just 5 meters from router.
I changed to cable connection and network seems to be ok now.

No it wasn’t ok.

Oct 15 09:17:00 homeautomation hass[475]: OSError: [Errno 113] No route to host
Oct 15 09:17:30 homeautomation hass[475]: WARNING:lightify:lost connection to lightify gateway.
Oct 15 09:17:30 homeautomation hass[475]: WARNING:lightify:Trying to reconnect.

But this is something that has nothing to do with HA. No route to host might mean that Lightify hub is disconnected from network.

@MarkoMarjamaa did you check if your Osram gateway is taking a different IP via DHCP? Maybe the DHCP lease time is different or causing the gateway to change its IP. How about to create a monitoring script to ping the gateway to keep the arp cache alive and to check its connectivity?

I have manual IP’s( of course). I have now to sensors metering ping to lightfy hub and router in 30s interval and the connection seems to be ok.
But, the lightify plugin have been losing it’s connection many times today. Loosing the connection would be ok, but there’s also that “No route to host”. How can it be? At the same time ping is working ok…

Which is the current firmware version?

Are you just using IP or names?

Don’t know the version, but most recent.
I use ip’s.

Here’s my Lightify hub ping meter. Router ping works flawless.

Next I try to comment out Lightify from hass and see if there is any change in Lightify ping.

1 Like

Still breaks even when hass is not using Lightify Hub, so it’s not hass’s fault.
I have two wifi networks, so I closed to unused one just for testing.

No luck. Even change to different plug.

Now I changed the connect-function to this:
def connect(self):
“”" trys to establish a connection with the lightify gateway
“”"
tries = 30
for i in range(tries):
try:
with self.__lock:
self.__sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.__sock.settimeout(TIMEOUT)
self.__sock.connect((self.__host, PORT))
except:
if i < tries - 1: # i is zero indexed
time.sleep(5)
continue
else:
raise
break

(even when I selected Unformatted text, forum’s still changing it…)

I’ll try now with this. When connecting, it will now retry for 30 times, with 5 second delays between.

I have followed @tchellomellos instructions and all of a sudden my Lightify lamps seems to work well. Only problem so far was that when I hammered it with commands from HA they got queued up and seemed to choke on it for a while until it started to spit out all the changes in rapid succession. Doesn’t matter. I do not use my lights that way…

I’m using 0.30.2 - I’ll need to fixa init.py again if I update to latest, right?

Will this be included in next version?

Thanks for your great work!

/Johan

Hello,

after update to new version HA 0.31.1 the component Osram Lightify doesn’t find any light and switches.
I try @tchellomellos instructions, no success…

Regards Vaclav

Hello @johano,

Yes, every time you update the version you will need to re-apply the fix.
I think the original developers @tfriedel and @MindrustUK are working on a PR to get it incorporated to HA.

Thanks for your feedback on it.
mmello

Hello @vhrabe,

Do you see the component being loaded on the HA logs? Could you share some logs to help you to troubleshoot it?

~mmello

Hello @mmello,

is was started read components when I enable debug log… When disable debug, no lights component…

Bellow is part of log. You can see some free lines and not recognized characters.

Regards Vaclav

16-10-26 09:10:18 lightify: Logging lightify
16-10-26 09:10:18 lightify: sending “b’070002130000070201’”
16-10-26 09:10:18 lightify: 2
16-10-26 09:10:18 lightify: Length 1409
16-10-26 09:10:18 lightify: Expected 1409
16-10-26 09:10:18 lightify: received “1409 b’8105’”
16-10-26 09:10:18 lightify: received "

ß





















16-10-26 09:10:19 lightify: num: 28
16-10-26 09:10:19 lightify: 0 9 50
16-10-26 09:10:19 lightify: light: adac 8418260000d9bd2e lampa1 0
16-10-26 09:10:19 lightify: status: 50 ff
16-10-26 09:10:19 lightify: onoff: 0
16-10-26 09:10:19 lightify: temp: 4000
16-10-26 09:10:19 lightify: lum: 47
16-10-26 09:10:19 lightify: red: 255
16-10-26 09:10:19 lightify: green: 241
16-10-26 09:10:19 lightify: blue: 80
16-10-26 09:10:19 lightify: 1 59 50

To me this looks like there might be problems handling special characters, could you rename the lights to something simple like A, B, C, D etc and try again to see if this helps with the problem? It’s a bit of a knee jerk reaction but at least will rule out the names as a problem.

1 Like

The rename of components doesn’t help…
and now no lights

16-10-28 08:38:17 lightify: Logging lightify
16-10-28 08:38:17 lightify: sending “b’070002130000070201’”
16-10-28 08:38:17 lightify: 2
16-10-28 08:38:17 lightify: Length 1409
16-10-28 08:38:17 lightify: Expected 1409
16-10-28 08:38:17 lightify: received “1409 b’8105’”
16-10-28 08:38:17 lightify: received “1409 b’031300000702001c00acad2ebdd90000261
8840a01020401020000001da00ffff150ff6c616d706131000000000000000000000000000000000
000ffffb2a7da00002618840a01020401000000013ba00ff0ffecff6c6564706173656b310000000
00000005406000000000000ffff67fc07000026188400010204000001000164de12010000ff73747
56c310000000000000000000000a200000000000000ffff366509000026188400010204000001000
164de12010000ff7374756c320000000000000000000000a200000000000000ffffac64090000261
88400010204000001000164de12010000ff7374756c330000000000000000000000a200000000000
000ffffe119010000261884020102040700020001648e0a010000ff6465736b610000000000000000’”
16-10-28 08:38:17 lightify: received "





16-10-28 08:38:17 lightify: num: 0