Lightwave RF Energy Monitor Sensor

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:

Doesnt make sense to me… Have you tried running the command on your PC instead? Be good to validate that the UDP packets are being sent by the hub

Good call! I’ve run in on Windows and it’s not receiving any data…drat…I’ll have to investigate further. Thanks for your help this far!!

Is your lightwaverf link and the PC/Hassio on the same “physical” network.

yep, same network

(Sorry for the delay)

Sorry dont know, im guessing firewall/networking issue… Once you get the python to work the component will also work.

Hi Angelo

Finally got a load off stuff off my plate and managed to test - My LWRF link has been off since december but now up in the loft and works fine for the energy monitor

Anyway, I have added results pulled on my ubuntu box to the issue open on github for multiple sensors but here they are anyway

Looks like serial number is pulled and can distinguise between multiple monitors

Data received from LWRF Energy *!{“trans”:65,“mac”:“20:40:A8”,“time”:1591027715,“pkt”:“868R”,“fn”:“meterData”,“prod”:“pwrMtr”,“serial”:“DB81FE”,“type”:“energy”,“cUse”:1350,“todUse”:187}

Data received from LWRF Energy *!{“trans”:66,“mac”:“20:40:A8”,“time”:1591027737,“pkt”:“868R”,“fn”:“meterData”,“prod”:“pwrMtr”,“serial”:“CF50FE”,“type”:“energy”,“cUse”:138,“todUse”:14}

Cheers

Nice, thanks for sharing!

Is this still required? My energy monitor shows up by default

I quickly checked and I cant see a OOTB HA integration for the Lightwave RF Energy monitor…

What model Energy monitor do you have?

Hey @Angelo_Santagata

Anychance you managed to support multiple monitors yet?