asantaga / lightwaverf_ha_energysensor Goto Github PK
View Code? Open in Web Editor NEWHome Assistant Sensor for the LightwaveRF energy monitor
License: MIT License
Home Assistant Sensor for the LightwaveRF energy monitor
License: MIT License
Branch : MigrateComponnetToNewModel
No idea why the default valuing isnt working for scan_interval
. If not supplied you get a key error
I have my energy monitor working well now and have just added another energy monitor to my LightWave HUB as I have two electricty feeds I want to monitor 1 x main utility feed into my house and then to a sub db to my Annexe that I want to monitor
Do you support multipl monitor sensor? I am testing now so may find the answer myself soon
They are showing in my lightwave portal fine so assume they send data based on serial number or ID to the HUB which you could possible use in the sensor name to distinguise the different monitors
After installing the integration via HACS and adding the sensor to configuration.yaml the integration failing to complete setup after restarting Home Assistant:
sensor lightwaverf_energy:
- platform: lightwaverf_energy
scan_interval: 30
2022-05-07 18:45:34 ERROR (MainThread) [homeassistant.setup] Error during setup of component lightwaverf_energy Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/setup.py", line 235, in _async_setup_component
result = await task
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/homeassistant/.homeassistant/custom_components/lightwaverf_energy/init.py", line 29, in setup
hass.data[DATA_KEY] = config[DOMAIN][0][CONF_SCAN_INTERVAL]
IndexError: list index out of range
2022-05-07 18:45:34 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform lightwaverf_energy.sensor: Unable to set up component.
version: core-2022.4.7
installation_type: Home Assistant Core
dev: false
hassio: false
docker: false
user: homeassistant
virtualenv: true
python_version: 3.9.2
os_name: Linux
os_version: 5.10.0-14-amd64
arch: x86_64
timezone: Europe/London
Hello,
Just installed this, and it works great most of the time, but occasionally I will get the following error in the logs and the sensors won't start updating again until I restart Home Assistant. Any ideas? Thanks
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 401, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 609, in async_device_update
raise exc
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/lightwaverf_energy/sensor.py", line 55, in update
sock.bind(("0.0.0.0", 9761))
OSError: [Errno 98] Address in use
I created a PR into the main HA Lightwave integration, to add direct support for lightwave TRVs.
home-assistant/core#85385
Testing by @hunterdriver has seen an issue (https://community.home-assistant.io/t/lightwave-thermostatic-valves/131644/23).
This is caused by both the TRV listener and your code needing to listen on UDP Port 9761.
I believe the following change would resolve the issue.
https://github.com/asantaga/lightwaverf_HA_EnergySensor/blob/master/custom_components/lightwaverf_energy/sensor.py
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("0.0.0.0", 9761))
to
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
sock.bind(("0.0.0.0", 9761))
Add necessary attributes to allow home assistant's new energy dashboard to use lightwaverf energy monitor sensor data
Also seem to experience excessive timeouts events. see below:
Logger: homeassistant.helpers.entity
Source: helpers/entity.py:657
First occurred: 4:02:20 (559 occurrences)
Last logged: 21:36:12
Update of sensor.electricity_current_usage_w is taking over 10 seconds
Update of sensor.electricity_energy_today_usage_kwh is taking over 10 seconds
I have HASS running on a Pi4 - what is the instruction to open the following?
Ensure port 9761/UDP is open on your linux server.
Thanks
Hello
I recently upgraded my HA to 2023.6.1 and the energy monitor integration seems to have stopped working.
Log entry below:
This error originated from a custom integration.
Logger: homeassistant.helpers.entity
Source: custom_components/lightwaverf_energy/sensor.py:55
Integration: Lightwave Energy Monitor
First occurred: 00:37:13 (58 occurrences)
Last logged: 00:51:13
Update for sensor.electricity_current_usage_w fails
Update for sensor.electricity_energy_today_usage_kwh fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/lightwaverf_energy/sensor.py", line 55, in update
sock.bind(("0.0.0.0", 9761))
OSError: [Errno 98] Address in use
It was working prior to the upgrade. Any ideas?
Anthony
New model for some reason gives to sets of sensors.. not sure why
@matthewjporter : Any chance you can checkout code in branch MigrateComponnetToNewModel
and see if it works for you?
Hi There,
Firtly, Great work, and realy appreciate you putting this together
I have found an issue and resolved the it, hope it helps unless its my setup. So, I am ruinning latest HASSIO and just getting back to test this component and getting the following error in my log
"Error parsing manifest.json file at /config/custom_components/lightwave_energy/manifest.json: Expecting ',' delimiter: line 5 column 3 (char 162)"
In the manifest.json at line 4 it has
"documentation": "https://www.home-assistant.io/components/lightwave_energy"
It should however be
"documentation": "https://www.home-assistant.io/components/lightwave_energy",
When I fix as above, my homeassiosant then wont start and gets tonnes of python errors so removed the custom component and hassio started fine
I made various changes and the following is the result in my manifest.json and my HASSIO starts up fine and creates the sensors as expected etc
{
"domain": "lightwave_energy",
"name": "Lightwave Energy Monitor Platform",
"documentation": "https://www.home-assistant.io/components/lightwave_energy",
"codeowners": [
"@asantaga"
],
"requirements": [
],
"dependencies": [
]
}
Cheers
Matthew
in 0.96.x i get the error
Error during setup of component lightwaverf_energy
Traceback (most recent call last):
File "/usr/src/app/homeassistant/setup.py", line 156, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/lightwaverf_energy/__init__.py", line 27, in setup
hass.data[DATA_KEY] = config[DOMAIN][CONF_SCAN_INTERVAL]
TypeError: list indices must be integers or slices, not str
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?
Hello
The following error (see below) has appeared in my home assistant log. The values are coming through. Although it was returning "Unknown" for a time.
Regards
Anthony
This error originated from a custom integration.
Logger: homeassistant
Source: custom_components/lightwaverf_energy/sensor.py:108
Integration: Lightwave Energy Monitor
First occurred: 4 January 2022, 19:36:22 (6 occurrences)
Last logged: 23:27:13
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 734, in _update_entity_states
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 492, in async_update_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 511, in _stringify_state
if (state := self.state) is None:
File "/config/custom_components/lightwaverf_energy/sensor.py", line 108, in state
return int(self.today_usage) / 1000
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.