Lightwaverf via Wifi link

This is wonderful… Thanks for taking the time, @GeoffAtHome

I thought I’d give this a go and try to set it up.

I followed all the instructions and added the custom component in HA, but can’t get it register with the LightwaveRF link/hub.

Could it be the fact that I’m running HA as a Docker container that it doesn’t work, or should it work anyway?


I de-authorised all devices from my LightwaveRF link/hub and set it up from scratch. I've previously been using LightwaveRF through the homebridge plugin and (interestingly) couldn't get homebridge to register with the hub by turning on/off the switches, I could only get it to register by running the command through Terminal

echo -ne "100,\!F*p." | nc -u -w1 192.168.0.52 9760


So maybe that’s the reason tuning on/off the switches in HA won’t make it register? It needs to somehow run the Terminal command from HA instead?

Hey Jono,

The latest code will automatically send the registration code to the hub when a switch or light is turned on or off. It gets a message back from the hub to say the device is not registered and then does the registration. Try switching a light on or off and look at the hub. You should be prompted to press ‘yes’ on the hub.

I thought that this would be easier that dropping into the terminal.

Cheers,
Geoff

Thank you.

Thanks Geoff, I tried that but it didn’t work. Here’s what it said in the log:

2018-11-14 17:42:35 ERROR (Thread-15) [custom_components.lightwave] LW broker something went wrong!
2018-11-14 17:42:38 ERROR (Thread-16) [custom_components.lightwave] LW broker something went wrong!
2018-11-14 17:42:42 ERROR (Thread-17) [custom_components.lightwave] LW broker something went wrong!
2018-11-14 17:42:46 ERROR (Thread-18) [custom_components.lightwave] LW broker something went wrong!

I have the dimmer switches to control my lights, are they classed as lights or switches?

Dimmer switches are classed as lights.

Does you hub have a static IP address?
Did you put the IP address of the hub into your configuration files?

The entry for the lightwave platform should like something like:

lightwave:
host: 192.168.0.1

Replace 192.168.0.1 with the IP address of you hub.

Let us know how you get on.

Ah, thanks for confirming that.

Yes, the hub has a static IP address, and here’s my entry:

lightwave:
    host: 192.168.0.52


light:
  - platform: lightwave
    devices:
      R2D1:
        name: "Lounge Ceiling Light"
      R2D2:
        name: "Dining Room Ceiling Light"

I've tried again, but still no luck registering.

Hi Jono,

All looks correct in your configuration file. Are you sure your lights are in room 2 (R2)? I have not tested what happens when the device is unreachable. That is, trying to turn on or off a device that does not exist.

I’ll try this when I get home tonight and see if I get the same error as you see in the event log. I’ll also add some additional code to report exactly what the error is. Saying “Something went wrong” is true but not very helpful - I should have thought more about handling errors and helping with diagnosing the issues.

For development I use the same platform/lightwave.py file but debug it in a standalone python program. I still have this code available and this helps finding issues.

Lastly, what version of the LightWave WiFiLink hub do you have? It is possible that the version you have is different to mine and that could be the cause of the problem but it is unlikely.

Cheers,
Geoff

Yes, it’s R2 (D1 and D2).
I used to have command line switches set up for them in HA on a Raspberry Pi with a .py script, and currently use them with homebridge in a docker container.

My LightwaveRF link is the 1st gen.


Thanks for the help!

Can you change the lines in platform/lightwave.py from:

    except socket.timeout:
        _LOGGER.error("LW broker timeout!")
        return result

    except:
        _LOGGER.error("LW broker something went wrong!")
        raise

    if result:
        _LOGGER.info("LW broker OK!")
    else:
        _LOGGER.error("LW broker fail!")
    return result

to:

    except socket.timeout:
        _LOGGER.error("LW broker timeout!")
        return result

    except Exception as ex:
        _LOGGER.error(ex)
        raise

    if result:
        _LOGGER.info("LW broker OK!")
    else:
        _LOGGER.error("LW broker fail!")
    return result

Catching the real exception and printing it is more useful that saying “Something went wrong”. With this in place please post what you see in the error log.

OK I’ve tried that, and it says the address is already in use. Presumably the address of the LightwaveRF Link?

2018-11-15 15:54:31 ERROR (Thread-15) [custom_components.lightwave] [Errno 98] Address already in use
2018-11-15 15:54:36 ERROR (Thread-16) [custom_components.lightwave] [Errno 98] Address already in use
2018-11-15 15:54:39 ERROR (Thread-17) [custom_components.lightwave] [Errno 98] Address already in use
2018-11-15 15:54:40 ERROR (Thread-18) [custom_components.lightwave] [Errno 98] Address already in use

But I don't know what else in HA could be using it.

You got me stumped for now. Something else must have be attempting to connect to the hub on 192.168.0.52.

No sure how I can replicate this error and see how to mitigate the problem.

I can’t reproduce the problem.

I have updated the code in GitHub to print the exception (change as above) and to attempt to re-use the read socket as it may be the read socket and not the write socket.

@jono It is likely that the IP address is in use by another process running on HA. Do you have any other platforms/options that may be using the same address? Maybe try restarting removing any likely candidates and restarting HA to identify what component is clashing.

In the code I only grab the port for as long as needed. After the messages have been sent the port is released. I could hold the port from initialisation but I don’t believe that this is best practise.

1 Like

I don’t think so, but I’ll go through my config and double check.

Because I have homebridge running as a Docker container on the same machine I wondered if that could be causing it?

I think I’ll disable the homebridge container, remove all devices from the LightwaveRF Link and set it up from scratch again (without homebridge), just to make sure :slightly_smiling_face::crossed_fingers:t3:

…OK, I’ve managed to sort it out :slightly_smiling_face:

After de-authorising all devices from the Link I managed to get it to work by removing homebridge.

Thanks a lot for the help!

@jono Good to hear you have it resolved.

1 Like

Hey all,

I think that the Lightwave component may get added to Home Assistant directly. See https://github.com/home-assistant/home-assistant/pull/18026 for details.

Please note that after several code reviews that the configuration file has changed. This will be a breaking change from the current configuration file. See https://github.com/home-assistant/home-assistant.io/pull/7600 for details.

Look out for the component in a future release of Home Assistant. After this change you may not be able to use the custom component. The changes to the configuration file are straight forward and keeps it all under the lightwave platform.

3 Likes

Great, looking forward to the ‘official’ release :slightly_smiling_face:

Hey @GeoffAtHome
Awesome to see your work get added to Home Assistant directly today! Awesome stuff.
Regarding the documentation, I wondered whether on the component page it would make sense to specify this is only for the Gen 1 gear - what I now think they call the “Connect Series” ?