LightwaveRF dimmer and switch support

Bare in mind that I am VERY new to all this! My only coding knowledge is hacking about with PHP and a good knowledge of HTML / CSS (I’m a web designer).

The code is kinda’ working.

I have managed to set up a few automations, and I can fire out scripts to turn on / off lights from the hassio GUI. The light switches on the overview page are definitely not working though. If I click on the light, it doesn’t give me the option of a dimmer.

Also, my lightwaverf setup is a real mixture of devices. I have relays operating GU10 ceiling lights, a double plug socket, multiple dimmer switches and loads of wall plugs.

I’ve spotted that the wall plugs that I have added are listed as lights. Is there a way to change this?

Oh - and I’m massively grateful for your help here! Simply wouldn’t have a clue doing this myself!

Ah ok! That might explain things.

Could you try editing the python file so you only have the dimmers in there? Let me know how you get on.

Because the whole file is written as a light component, I’m not sure it is going to be sending the right messages to the link box for the other devices.

So doing a few tests.

I have tried removing all components but a dimmer relay, exactly the same thing happens.

I have used the android UDP app to view what code is being sent out once I click the switch within HA GUI, and this is what is sent out (which seems fine):

*!{“trans”:
812, “mac”:“20:36:D5”,“time”:
1515691328,“pkt”:“433T”,“fn”:“d
im”,“param”:32,“room”:1,“dev”:
6}

This is what is sent when I use the message found in the LightwaveRF API for dimming the light (again I sent this using this message on the UDP app - 001,!R1D6FdP16)

*!{“trans”:
809, “mac”:“20:36:D5”,“time”:
1515691019,“pkt”:“433T”,"
fn":“dim”,“param”:16,“room”:1,“dev”:
6}

As you’ll see, the code seems correct, but it’s not doing anything to the light.

I’ve added a screenshot of the light control when opened in the HA GUI57

This is brilliant, thank you!

The issue I’ve got at the moment is that it throws the following error when I flip the switch in HA:

Jan 12 17:03:10 pine64 hass[7599]: Traceback (most recent call last):
Jan 12 17:03:10 pine64 hass[7599]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
Jan 12 17:03:10 pine64 hass[7599]:     result = coro.throw(exc)
Jan 12 17:03:10 pine64 hass[7599]:   File "/home/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1031, in _event_to_service_call
Jan 12 17:03:10 pine64 hass[7599]:     yield from service_handler.func(service_call)
Jan 12 17:03:10 pine64 hass[7599]:   File "/home/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/__init__.py", line 271, in async_handle_light_service
Jan 12 17:03:10 pine64 hass[7599]:     yield from light.async_turn_on(**params)
Jan 12 17:03:10 pine64 hass[7599]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Jan 12 17:03:10 pine64 hass[7599]:     yield self  # This tells Task to wait for completion.
Jan 12 17:03:10 pine64 hass[7599]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Jan 12 17:03:10 pine64 hass[7599]:     future.result()
Jan 12 17:03:10 pine64 hass[7599]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Jan 12 17:03:10 pine64 hass[7599]:     raise self._exception
Jan 12 17:03:10 pine64 hass[7599]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Jan 12 17:03:10 pine64 hass[7599]:     result = self.fn(*self.args, **self.kwargs)
Jan 12 17:03:10 pine64 hass[7599]:   File "/home/homeassistant/homeassistant/lib/python3.5/site-packages/homeassistant/components/light/lightwave.py", line 123, in turn_on
Jan 12 17:03:10 pine64 hass[7599]:     self.update_ha_state()
Jan 12 17:03:10 pine64 hass[7599]: AttributeError: 'LRFLight' object has no attribute 'update_ha_state'

I’m working through it now.

My version of HA may be a little out of date and therefore my component may be too.

If you check the docs and see what needs to be updated perhaps you could fix the code and send me a pull request. If not, I’ll take a look over the weekend.

I’ll see what I can do - it’s finding the time more than anything else! :frowning:

I’ve updated the code on github. Please try the new file and let me know how you get on.

@proffalken @Martin_Granger

1 Like

Just did a super quick test and it seems to work!!!

I’ll add more devices etc tomorrow.

Thanks again for your efforts

That is great news! I will do some work to make it more of an official plugin that will discover all of your devices for you. But that will have to be done another time. Glad it is working!

1 Like

@chillerz
I had a proper play around today.

The HA GUI light switch now at least operates the light in an on off sense, however there is still no dim option in the GUI.

On another note - I have many lights set up using an inline open close relay. The lightwave API states that these will operate with the standard light on off code (F0 & F1). Is it possible to configure the on off functions to use this instead of on always being brightness 32. Hope that makes some sense?!?

This code is awesome. I notice the class is set for lights and therefore have no effect on my dimmers. Any idea on the changes i could make to set switches?

Hi James - is the code working for you?

it is, i stripped the dimmer section out so i could turn on and off switches as well as lights.

Any chance that you could post some info on how to do this? I want to do much the same - control switches and relays etc.

change line 120:

    msg = '666, !%sF1|Turn On|%s ' % (self._deviceid, self._name)

So obvious when you see it!

Did you keep the lightave.py file in custom_components/lights ?

yeah, all in place

My z-wave dongle arrives tomorrow, hoping to get some sniffing done so i can interpret the trv command set. I’ll get wireshark inline to the hub and see if i can decypher whats being sent to the hub and whats being sent and received from the the rf coms…

Thanks @chillerz - this is now working fine.

The issue I had was that I’d registered too many controller devices to the wifi-link, so had to reset it to free up some slots.

I now have Alexa controlling my lightwaveRF lights directly via this script and the HUE Emulator.