Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Energy metrics not being collected #10

Open
proffalken opened this issue Aug 19, 2021 · 12 comments
Open

Energy metrics not being collected #10

proffalken opened this issue Aug 19, 2021 · 12 comments

Comments

@proffalken
Copy link
Contributor

Hello,

Since #7 was fixed I've gone back through my config and confirmed that I can talk to my WiFiLink (LW390) from the Raspberry Pi that is running HA.

If I send the command !R1D1F1 to the Link on UDP 9760 then the appropriate light turns on, so that's fine.

I'm still not seeing any data from the energy monitor however, and the log is full of lines such as:

2021-08-19 07:40:26 ERROR (SyncWorker_10) [custom_components.lightwaverf_energy.sensor] No data received from lightwaveRF energy monitor timed out

https://api.lightwaverf.com/energy.html#communication suggests that the energy meter data should be sent as a UDP broadcast (which is exactly what the code is expecting), however even if I run Netcat listening for broadcast data, I still can't see any data from the Link at all.

I'm now wondering if the LWLink has stopped broadcasting as even a tcpdump -n 'broadcast' isn't showing the packets from the Link - can anyone else confirm this behaviour?

@gshoebridge
Copy link

I'm seeing data intermittently but not enough to be confident of the total
I notice other attributes available - could these be used toward the total daily usage?

@asantaga
Copy link
Owner

asantaga commented Aug 21, 2021

Hey,

I too have noticed this on my server, but then all of a sudden it started working again. Is you HA Server on the same network as the LFRF WifiLink? I remember when developing that if I was connected to a different AP I also didnt get the packets..

this piece of code can be run on anything to test its receiving data..

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  ")

oh and firewalls, thats the otherthing I tweaked on my server..
let me know if this works

@gshoebridge
Copy link

Will have a go - I run a Mac mini and would use terminal

Using varying network options - will look to bring lw off wifi

@asantaga
Copy link
Owner

I have the LW930, i have it hardwired, actually I dont think it has WIFI support..

it should work on a macmini too, i originally developed the code on a macbook pro but it now runs on my ubuntu server..

let me lknow

@gshoebridge
Copy link

gshoebridge commented Aug 21, 2021 via email

@gshoebridge
Copy link

what should i run to get import json.... etc working?

@gshoebridge
Copy link

data recovered

Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'!{"trans":43826,"mac":"03:3D:5D","time":1629565152,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":446,"todUse":14608}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'
!{"trans":43827,"mac":"03:3D:5D","time":1629565167,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":450,"todUse":14610}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'!{"trans":43828,"mac":"03:3D:5D","time":1629565182,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":448,"todUse":14612}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'
!{"trans":43829,"mac":"03:3D:5D","time":1629565197,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":448,"todUse":14613}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'!{"trans":43830,"mac":"03:3D:5D","time":1629565212,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":443,"todUse":14615}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'
!{"trans":43831,"mac":"03:3D:5D","time":1629565227,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":437,"todUse":14617}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'!{"trans":43832,"mac":"03:3D:5D","time":1629565242,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":439,"todUse":14619}'
Waiting for data from LWRF Energy Device
Data received from LWRF Energy b'
!{"trans":43833,"mac":"03:3D:5D","time":1629565257,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":437,"todUse":14621}'
Waiting for data from LWRF Energy Device
^[Data received from LWRF Energy b'*!{"trans":43834,"mac":"03:3D:5D","time":1629565272,"pkt":"868R","fn":"meterData","prod":"pwrMtr","serial":"5253FE","type":"energy","cUse":437,"todUse":14623}'
Waiting for data from LWRF Energy Device

@asantaga
Copy link
Owner

Sorry, looks like I cut'n'pasted something without checking , the code doesnt use json or even time, sorry, but I think you figured it out.

Well the data is coming through.. From the macMini? or the HA Server..

@proffalken
Copy link
Contributor Author

I too have noticed this on my server, but then all of a sudden it started working again. Is you HA Server on the same network as the LFRF WifiLink? I remember when developing that if I was connected to a different AP I also didnt get the packets..

Yup, LW930 (no LCD display) hardwired to the same VLAN as the Pi that's running HomeAssistant, and as I say sending commands to the LWLink results in the correct lights activating, I'm just not seeing anything from the energy monitor.

The energy monitor is definitely working though, because I can see the data in the LWRF app.

@proffalken
Copy link
Contributor Author

Fwiw, I rebooted the lwlink and it all started working again...

@gshoebridge
Copy link

gshoebridge commented Aug 23, 2021

data collected on Mac mini - data being seen intermittently in HA server

Looks like 15 second polling.

@asantaga
Copy link
Owner

asantaga commented Sep 2, 2021

Hey, in sensor.py (line56) the timeout is set to 10seconds. I did that as the code isnt async and I didnt want to hang the HA thread. Can you try changing it to say 20 and see how that works. Im not 100% sure if HA will like that and I probably need to port the code to an async model..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants