Lightwave RF Energy Monitor Sensor

Hey all,

Ive just cobbled together a Sensor listening for the LightwaveRF energy Monitor output. The platform contains two sensors (Current Usage (W) and Current Day Usage (kWh)…

Before I clean it up and submit a PR Id like some testers!!!

let me know how it goes, appears to work for me

I would be interested.

What are the requirements? i.e hardware wise

Are you talking direct to the energy monitor or via the LWRF hub?

For hardware you need the Lightwaverf hub (tested on v1) and the LWRF Energy monitor… thats it!

the github repo is up to date

I see you have had no further feedback, so just wanted to thank you for the work.

Are you thinking of making this a component in HA itself?

Hey there, thanks for the comment. Yes I am in the process of cleaning up the code and trying to publish it as part of the HA component itself but the process is frankly a bit of a pain… … Ive also heard/read/commented on that it takes ages for stuff to get published but I’ll perserve

Just gotten back from hols, kids , diy getting in the way… but I’ll get to it soon…

:slight_smile: Keep bugging me!!!

Angelo

Just let me know if and when you need testing, am happy to help

Well Ive cleaned up the code and published a PR… Its a lot more convoluted than I hoped… and home DIY gets in the way… lets see how it goes

I will pull and test and let you know

Cheers

Hi,

I have installed this in Hassio but I can’t seem to find out how to open the port on my raspberry pi 4. I can ssh into hassio but I can’t find out how to ssh into the host in order to update the ports. Can anyone guide me please?

thanks,

Matt

Hey ,

Do you know if hassio installs a firewall? I use ufw (uncomplicated firewall) and that easy to setup but I dont know which fw haasio has installed…

Ok, I’ve found out that the hassio installation on the raspberry pi has all ports open as standard so it must be an issue with my config. I set it up as per the instructions (which do look a little inconsistent with other config settings). In my configuration.yaml I have:

lightwaverf_energy:
  scan_interval: 30

But this isn’t set up as any particular entity type, could that be the issue?

The yaml is correct. The reason why you dont see any entity types is because the platform( I think thats what they call it) , generates them at runtime… It generates two sensors.

try this piece of python … Its basically listens for messages from the lWRF energy sensor (via the link).

import json
import logging
import socket
import time
data = None
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('0.0.0.0', 9761))
sock.settimeout(30.0)  # Wait a Max of 30 seconds
while True:
    try:
       print("Waiting for data from LWRF Energy Device")
       data, _ = sock.recvfrom(1024)  # buffer size is 1024 bytes
       print("Data received from LWRF Energy %s " % data)
    except socket.timeout as ex:
       print("No data received  ")

run it using python filename.py

It should return some data within 30s (usually comes every 10 seconds). if you dont receive any data then its likely a network issue… The packets are UDP and dont travel through routers other subnets well.

let me know how this goes

Hi,

Thanks for your support, however I don’t know how to run this. I’m assuming I save it as a .py file on my raspberrypi and then run it using the cli. The issue I have is that i’m running home assistant through hass.io which I believe is a docker installation and I have no access to the raspberry pi that the hass.io installation is running on. I can only get to/ssh into the docker container itself.

I don’t have the level of understanding to allow me to try different things. I’ve got this far by closely following instructions but haven’t found anything about this sort of thing/obstacle.

Thanks,

Matt

Ok…I think I’ve made some progress. I found this…

so I saved your code snippet as filename.py (couldn’t think of a better name!), put it in /config using the Hassio configurator add on and then set up the sensor as:

- platform: command_line
  name: EnergyMon
  command: "python3 /config/filename.py"

After restarting, I checked the logs and I’m getting:

Fri Nov 22 2019 15:49:36 GMT+0000 (Greenwich Mean Time)
Timeout for command: python3 /config/filename.py

so something’s not working/connecting and I’m stuck once again, albeit further forward than before! :slight_smile:

ive never used hass.io

Can you not get to the command line?

It’s supposed to be possible…

but I cannot get in following these instructions, so I’m locked out and not knowledgeable enough to get in!

More info after trying again, maybe there’s something that you can identify in this…

Command executed: python3 /config/filename.py: 1
Traceback (most recent call last):
  File "/config/filename.py", line 7, in <module>
    sock.bind(('0.0.0.0', 9761))
OSError: [Errno 98] Address in use

Hey Matt,

this is because the code is running in HA too… Take out the lightwaverf_energy yaml lines and try again

Also , looking at Hass.io you can install a ssh server…
https://www.home-assistant.io/addons/ssh/

From reading the link, if you install this add on you can ssh (or use putty on a windows PC) and execute the script from the command line.

WRT executing the script, copy the lines of code into a file (with the extension .py) and then run it using python yourfilename.py

Hi…removing the lines and restarting has no effect. The error message is identical.
I have the ssh add-in, but it ssh’s into the container, not the host and the container cli is a cut down version where you have limited options
Regarding the script…that’s exactly what i did :smiley: