Lightwave Generation 2 component

Sorry for the cross-post, but just seen that Lightwave announced API information for their Smart Series (Gen 2) devices. Exciting times!

Hi - have just pushed a new version that fixes the structure. Works for me, but as always, let me know if any problems.

Bah! I knew it wouldn’t be long after I released this that they’d finally release the official API!

I’ll have a look and see whether I can face rewriting everything for local control!

Hmmm. Had a quick look at the API. Still seems to be cloud based. Sending commands to the linkplus seems relatively straightforward, but receiving events looks to be a bit awkward and not necessarily easy to hook up to HA. I’ll play around more this weekend.

1 Like

Thank you so much. I managed to cobble it together very late last night myself but had no faith I did it right.

So glad that you spun the update out so swiftly, looking forward to seeing what more you can do now with the public api. Thanks again.

Has anyone managed to get Lightwave G2 working with HA now they have released their API?

I can connect and send commands using the official API, but the API for receiving events appears to be broken. I’ve emailled Lightwave but no response.

BTW I’ve just pushed a new version, should be slightly more responsive.

Not sure if anyone else is getting this but I had the latest custom component you just posted installed on 0.88.1 with no errors. Just now upgraded to 0.89 and it is spitting out the below about the climate component

Error loading custom_components.lightwave2.climate. Make sure all dependencies are installed

Traceback (most recent call last): File "/usr/src/app/homeassistant/loader.py", line 166, in _load_file module = importlib.import_module(path) File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/config/custom_components/lightwave2/climate.py", line 2, in <module> from homeassistant.components.climate import ( ImportError: cannot import name 'STATE_AUTO' from 'homeassistant.components.climate' (/usr/src/app/homeassistant/components/climate/__init__.py)

Thankfully I don’t have any climate stuff so doesn’t really affect me. All I get is that notification on startup.

Thanks john - fixed!

No problem that was rapid. Have updated to your latest version and the error has gone away. Just the normal warnings that say you are using a custom component. Or as I read it custom component loaded successfully.

Thanks again for all the effort you have no idea how much it’s appreciated.

Hey @bigbadblunt, First of all I want to say a massive thanks for creating this component, it’s been a real life saver! I’m just experiencing a few issues that I myself don’t have the technical knowledge to fix, so I was hoping for your insight…
or context I’m fairly new to HA but have been playing with lightwaverf gen 2 for a couple of months and am gradually getting through the process of swapping every light switch in the house. So this could be a problem I’m facing due to my own inexperience or a misconfiguration on my part, but I think I’ve found a bug with the component.

The issue first I’m experiencing relates to dimming, essentially I can turn my lights on and off fine, but if I set a light to some random brightness like 42% in HA/HA Homekit integration it’ll dim down to that brightness, but if I turn the light on and off it’ll drop by 1 or 2% each time I switch it on and off. so if I set a light to 11% and turn it on and off 10 times it’ll end up at one percent. This issues doesn’t present all of the time but it does happen most of the time. The only solution I can think of is setting an automation to run each night that sets all my lights to 100% then turns them off, but this seems like a bit of a faff and wouldn’t be best suitable for lights in the bedroom etc.

The other issue I’m facing is where a light will be physically on but will say it’s off in HA. initially I thought my link could be losing signal with the switch or something but upon checking the lightwave app the status is right in the native app but not in HA. Essentially the light is physically on, on in the lightwave app, but says it’s off in HA.

If you or anyone else on here has any ideas on this, or would like more info, please do get in touch!

Thanks again!
Nicki

Hi Nicki - the brightness bug is now fixed. I’ve just pushed a new version to github.

The second problem is more difficult as I can’t reproduce. If you can capture some logging output then I can see if I can work out the problem. Put the following lines in your configuration.yaml

logger:
  default: warning
  logs:
    lightwave2.lightwave2: debug

Also, when does the problem occur - is it if you use the physical switch, or the lightwave app to control the light?

Hey, Thanks so much for working on this so quickly!
Loaded the new component and the dimming issues have resolved, so no more funky automations needed for me! cheers

I’ve added the code above to my config so hopefully I’ll be able to capture something useful that you can take a look at. It’s a difficult one really as it seems to happen at random with just one or two lights out of the blue. I’ll leave it logging for a week or so and then get back to you with something. Where are the logs stored? I have SAMBA enabled…

The problem seems to only occur when using the physical switch, but then again I never really use the lightwave app, except for trying to investigate issues like this, so I’m not sure I’d notice it.
Basically I can switch a switch on at the wall and 9 times out of 10 it appears as on in HA, but every now and again I’ll switch the hallway or conservatory light on with the switch and the light will come on but will appear as off in HA. Yet oddly, when I go to the lightwave app to check if the hub knows it’s turned on it says on in the LWRF app but is still off in HA. It’s as-though the lightwave app isn’t telling HA a switch is on, even though it obviously knows about it… if that makes sense?

Honestly can’t thank you enough for all your help in this,
Nicki

I too have had the same issue that Nicki has been reporting regarding the action on a physical switch is not captured on HA but is on lightwaverf app. Much like Nicki I too have been setting up HA for about 2 months so have been monitoring and ironing out a lot of things. I am now at a point where my system is very stable and works.

So wasn’t wanting to report this to you until I knew it wasn’t just my setup being borked.

From what I have seen the issue occurs after HA has been running for a long period of time without restarts for say +12 or more hours but does vary depending on active use of the system at home.

If I press a physical light switch it does not register on HA. If I then use HA to toggle a switch it will work but there is a delay. As if it is re-establishing it’s connection to Lightwave again.

After a HA toggle action the physical button toggles are picked up by HA again for a long period of time.

I will add the log lines of code to my configuration and see what that captures to help you out.

Again thanks so much for your development in this component. You rock, without it HA would be pretty useless for me.

I managed to catch it with the debug log script on just now.

I came home today anticipating it could happen as I know that’s when this normally occurs as I am at work and nothing has been used for that whole time.

Switched on the kitchen light and watched HA, it did not update. Checked LWRF app and it correctly had the Kitchen light status as on.

This is what was in the log.

2019-04-09 18:58:53 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"operation":"event","class":"feature","direction":"notification","transactionId":52301738,"source":"rfProtocol","items":[{"payload":{"featureId":"5c3b515e5e33aa33645653cc-83-3157330816+1","value":1,"status":"ok"},"itemId":1}]}', extra='') 2019-04-09 18:58:53 WARNING (MainThread) [lightwave2.lightwave2] Message with no _feature: {'version': 1, 'senderId': 1, 'operation': 'event', 'class': 'feature', 'direction': 'notification', 'transactionId': 52301738, 'source': 'rfProtocol', 'items': [{'payload': {'featureId': '5c3b515e5e33aa33645653cc-83-3157330816+1', 'value': 1, 'status': 'ok'}, 'itemId': 1}]} 2019-04-09 18:58:53 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"operation":"event","class":"feature","direction":"notification","transactionId":52301738,"source":"rfProtocol","items":[{"payload":{"featureId":"5c3b515e5e33aa33645653cc-87-3157330816+1","value":3,"status":"ok"},"itemId":2}]}', extra='') 2019-04-09 18:58:53 WARNING (MainThread) [lightwave2.lightwave2] Message with no _feature: {'version': 1, 'senderId': 1, 'operation': 'event', 'class': 'feature', 'direction': 'notification', 'transactionId': 52301738, 'source': 'rfProtocol', 'items': [{'payload': {'featureId': '5c3b515e5e33aa33645653cc-87-3157330816+1', 'value': 3, 'status': 'ok'}, 'itemId': 2}]}

I really really hope this helps you out.

After the previous post I toggled on my lounge lights through HA it worked but this is what the log spurted out. Sorry I don’t know if this is of use but thought better you have this rather than never knowing about it and it assist.

2019-04-09 19:07:27 WARNING (MainThread) [lightwave2.lightwave2] Message with no _feature: {'version': 1, 'senderId': 1, 'operation': 'event', 'class': 'feature', 'direction': 'notification', 'transactionId': 52324146, 'source': 'rfProtocol', 'items': [{'payload': {'featureId': '5c3b515e5e33aa33645653cc-88-3157330816+1', 'value': 31, 'status': 'ok'}, 'itemId': 3}]} 2019-04-09 19:10:53 DEBUG (MainThread) [lightwave2.lightwave2] Sending: {"class": "feature", "operation": "write", "version": 1, "senderId": "3ab5d93d-b227-4815-b373-fafddb994830", "transactionId": 82, "direction": "request", "items": [{"itemId": 82, "payload": {"featureId": "5c3b515e5e33aa33645653cc-90-3157330816+1", "value": 20}}]} 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"direction":"response","items":[{"itemId":82,"payload":{"value":20,"status":"ok","_feature":{"deviceId":"5c3b515e5e33aa33645653cc-11-3157330816+1","productCode":"L22","featureId":"5c3b515e5e33aa33645653cc-90-3157330816+1","featureType":"dimLevel"}},"success":true}],"class":"feature","operation":"write","transactionId":52333146}', extra='') 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Response received: {'version': 1, 'senderId': 1, 'direction': 'response', 'items': [{'itemId': 82, 'payload': {'value': 20, 'status': 'ok', '_feature': {'deviceId': '5c3b515e5e33aa33645653cc-11-3157330816+1', 'productCode': 'L22', 'featureId': '5c3b515e5e33aa33645653cc-90-3157330816+1', 'featureType': 'dimLevel'}}, 'success': True}], 'class': 'feature', 'operation': 'write', 'transactionId': 82} 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Sending: {"class": "feature", "operation": "write", "version": 1, "senderId": "3ab5d93d-b227-4815-b373-fafddb994830", "transactionId": 83, "direction": "request", "items": [{"itemId": 83, "payload": {"featureId": "5c3b515e5e33aa33645653cc-89-3157330816+1", "value": 1}}]} 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"operation":"event","class":"feature","direction":"notification","transactionId":52333204,"source":"server","items":[{"payload":{"featureId":"5c3b515e5e33aa33645653cc-89-3157330816+1","value":1,"status":"ok","_feature":{"deviceId":"5c3b515e5e33aa33645653cc-11-3157330816+1","productCode":"L22","featureId":"5c3b515e5e33aa33645653cc-89-3157330816+1","featureType":"switch"}},"itemId":4}]}', extra='') 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Calling callbacks [<bound method LWRF2Light.async_update_callback of <Entity Kitchen Lights: on>>, <bound method LWRF2Light.async_update_callback of <Entity Kitchen Lights: off>>, <bound method LWRF2Light.async_update_callback of <Entity Hallway Light S: off>>, <bound method LWRF2Light.async_update_callback of <Entity Hallway Light M: off>>] 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"direction":"response","items":[{"itemId":83,"payload":{"value":1,"status":"ok","_feature":{"deviceId":"5c3b515e5e33aa33645653cc-11-3157330816+1","productCode":"L22","featureId":"5c3b515e5e33aa33645653cc-89-3157330816+1","featureType":"switch"}},"success":true}],"class":"feature","operation":"write","transactionId":52333201}', extra='') 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Response received: {'version': 1, 'senderId': 1, 'direction': 'response', 'items': [{'itemId': 83, 'payload': {'value': 1, 'status': 'ok', '_feature': {'deviceId': '5c3b515e5e33aa33645653cc-11-3157330816+1', 'productCode': 'L22', 'featureId': '5c3b515e5e33aa33645653cc-89-3157330816+1', 'featureType': 'switch'}}, 'success': True}], 'class': 'feature', 'operation': 'write', 'transactionId': 83} 2019-04-09 19:10:54 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"operation":"event","class":"feature","direction":"notification","transactionId":52333288,"source":"rfProtocol","items":[{"payload":{"featureId":"5c3b515e5e33aa33645653cc-93-3157330816+1","value":3,"status":"ok"},"itemId":5}]}', extra='') 2019-04-09 19:10:54 WARNING (MainThread) [lightwave2.lightwave2] Message with no _feature: {'version': 1, 'senderId': 1, 'operation': 'event', 'class': 'feature', 'direction': 'notification', 'transactionId': 52333288, 'source': 'rfProtocol', 'items': [{'payload': {'featureId': '5c3b515e5e33aa33645653cc-93-3157330816+1', 'value': 3, 'status': 'ok'}, 'itemId': 5}]} 2019-04-09 19:10:55 DEBUG (MainThread) [lightwave2.lightwave2] Received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"version":1,"senderId":1,"operation":"event","class":"feature","direction":"notification","transactionId":52333383,"source":"rfProtocol","items":[{"payload":{"featureId":"5c3b515e5e33aa33645653cc-93-3157330816+1","value":10,"status":"ok","_feature":{"deviceId":"5c3b515e5e33aa33645653cc-11-3157330816+1","productCode":"L22","featureId":"5c3b515e5e33aa33645653cc-93-3157330816+1","featureType":"power"}},"itemId":6}]}', extra='') 2019-04-09 19:10:55 DEBUG (MainThread) [lightwave2.lightwave2] Calling callbacks [<bound method LWRF2Light.async_update_callback of <Entity Kitchen Lights: on>>, <bound method LWRF2Light.async_update_callback of <Entity Kitchen Lights: off>>, <bound method LWRF2Light.async_update_callback of <Entity Hallway Light S: off>>, <bound method LWRF2Light.async_update_callback of <Entity Hallway Light M: off>>]

@john500y2k - are you using the latest version of the component? The slow response is due to re-establishing a connection as you surmised, but that behaviour should have been fixed in a recent version.

Nothwithstanding that, I found that HA was dropping a small proportion of messages received, so have pushed a new version that hopefully is more robust.

Daaaaaamn that’s quick.

I had a look and I am pretty sure I was using the latest version of the component as the file was modified 4 days ago which lines up to when you pushed that version.

I have downloaded the latest version and running it now so will see how we do.

Can I ask a very very daft question just so I know I am not missing anything here. I have downloaded the custom components that you have linked in your original post.

So in my custom components I have a lightwave2 folder and in there I have init.py, climate.py, light.py & switch.py. That is it only those 4 files

That is it there is nothing else in that folder other than the pycache folder HA self creates

There is also nothing else in the root custom_components folder as this is the only custom component I am running.

I also see you have this:

Which was updated recently too. Am I also meant to have these files somewhere too? I know this is all coming across moronic but I really just want to make sure I am not doing something daft and leading you down a frustrating path.

Yes, those 4 files are all you need.

If you’re curious: HA pulls the underlying lightwave2 python library automatically. The init.py file tells HA which version of the underlying library it needs, and it automatically downloads and installs that. So typically what I’m doing with the bugfixes is updating the underlying library, and just telling the custom component to download a new version. The location it downloads to on my system is /srv/homeassistant/lib/python3.5/site-packages/lightwave2

If you’re up to date and you still get the laggy behaviour where the lights take a while to respond, if you could PM me your whole log file I can try and see why it’s not maintaining the connection. It should notice when the connection drops and try to reconnect straight way, not wait until you try and do something.

That clarifies a lot thank you so much for the explanation. I was wondering when I looked at the code changed all you had to do was change the version number.

If I notice any odd behaviour as you mentioned I will PM you the full log.

Again thank you so much for all your work and support on this.