Sense Energy Monitor (Enhanced to include devices)

Well as of 0.82 devices are included in the official component, but they’re implemented as binary sensors rather than sensors. Is there really that much of a need to have draw information for individual devices? In my testing all of the state changes put a huge load on the system.

Thanks so much. Those settings worked. Do Binary sensors or Sensors put more load on the system?

Neither necessarily uses more, but with my implementation the state constantly changes while a device is on and energy usage fluctuates slightly, binary sensors only have on and off so the state changes one time when device turns on or off.

I plan to use Sense as well. Does the home assistant implementation work with two sense monitors as I have two cabinets? Currently, sense can only work in one cabinet.

Greetings!

I’m a new-ish Home Assistant user who has had a Sense energy monitor for some time now. I’ve successfully integrated Sense into my Home Assistant install and it has already shown me some patterns that the Sense app itself does not. Cool stuff.

However, it seems to place an awful load on my Sense monitor, so much so that Sense’s own app has gaps in data – and indeed, the total daily consumption (and production, we’ve got a solar array) is low. If I disable the Home Assistant Sense component things go back to normal. I suspect that with 35 detected devices I am exceeding some official or defacto API limit. In fact if I look in the logs there are exceptions galore about Sense taking too long to return data.

I don’t actually care to export all of Sense’s devices to Home Assistant. I mostly care about the overall consumption and production data, plus a few selected devices. Is there any way to get it to ignore (and not poll) some of my Sense devices?

Thanks in advance for any insight.

-Doug

1 Like

I have noticed poor performance in both Sense and HA after including devices in my custom component and after the official component integrated devices. With my custom there’s an option for not including devices, but I’m no longer supporting it now that devices are included in the official component. Without modifying the python code the best you could do is set hidden: true in your customize section of your configuration for every sense device, that should at least improve the performance on the HA side.

There was just a commit a few hours ago bumping up the version of the sense_energy library that the component uses, but updates to webhooks and such…that may help with the performance.

Thanks. I have examined the code and hacked in a whitelist of device names. If that goes well I will attempt to make it configurable and maybe submit a patch.

This component doesn’t appear to be working as of .87. All of my energy sensors and binary sensors have stopped reporting any updates and are giving me the below error message. > Update for binary_sensor.microwave_oven fails

Traceback (most recent call last): File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state await self.async_device_update() File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 349, in async_device_update await self.hass.async_add_executor_job(self.update) File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run result = self.fn(*self.args, **self.kwargs) File “/usr/local/lib/python3.6/site-packages/homeassistant/components/binary_sensor/sense.py”, line 115, in update self._data.get_realtime() File “/usr/local/lib/python3.6/site-packages/sense_energy/sense_api.py”, line 84, in get_realtime self._realtime = websocket.get_realtime(url, self.wss_timeout) File “/usr/local/lib/python3.6/site-packages/sense_energy/ws_async.py”, line 24, in get_realtime asyncio.get_event_loop().run_until_complete( File “/usr/local/lib/python3.6/asyncio/events.py”, line 694, in get_event_loop return get_event_loop_policy().get_event_loop() File “/usr/local/lib/python3.6/asyncio/events.py”, line 602, in get_event_loop % threading.current_thread().name) RuntimeError: There is no current event loop in thread ‘SyncWorker_8’.

I’m seeing same error after upgrading to 0.87.0

There is a bug filed and a fix in the works. Hopefully 0.87.1 will be out soon.

https://github.com/home-assistant/home-assistant/issues/20844

Any idea if a fix is in the works for the next release?

1 Like

Has this being fixed?

Yes working in the latest beta 0.90. Wish there was a way to remove the binary sensors we don’t want exposed to HA.

Thanks, now I have ver 0.9 and can confirm it was fixed

Ahh, a sense monitor, I always thought smappee was the only clamps sensor with device discovery… Ok, some stuff to read

What’s the experience with device discovery, any good?

I’m still getting the errors every few minutes in all my sense sensors. Is this a new problem or the same unfixed? I’m running the latest in hassio on an rpi3b+

Sat Mar 30 2019 03:05:10 GMT-0400 (EDT)

Sat Mar 30 2019 03:05:10 GMT-0400 (EDT)

Update for binary_sensor.coffee_maker fails
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 220, in async_update_ha_state
await self.async_device_update()
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py”, line 377, in async_device_update
await self.async_update()
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/sense/binary_sensor.py”, line 108, in async_update
await self._data.update_realtime()
File “/usr/local/lib/python3.7/site-packages/sense_energy/asyncsenseable.py”, line 41, in update_realtime
await self.async_realtime_stream(single=True)
File “/usr/local/lib/python3.7/site-packages/sense_energy/asyncsenseable.py”, line 51, in async_realtime_stream
ws.recv(), timeout=self.wss_timeout)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/site-packages/websockets/protocol.py”, line 350, in recv
yield from self.ensure_open()
File “/usr/local/lib/python3.7/site-packages/websockets/protocol.py”, line 501, in ensure_open
self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason

I have 3 devices discovered after 1 week.
Furnace blower, water tank heater and garage door opener.

I re-enabled the Sense component for 0.90 and still got similar errors so I removed it. Think its still a problem.

1 Like

I am still getting the same issue…

version 0.92

2019-04-26 14:51:28 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.other fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 375, in async_device_update
    await self.async_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/sense/binary_sensor.py", line 109, in async_update
    await self._data.update_realtime()
  File "/usr/local/lib/python3.7/site-packages/sense_energy/asyncsenseable.py", line 41, in update_realtime
    await self.async_realtime_stream(single=True)
  File "/usr/local/lib/python3.7/site-packages/sense_energy/asyncsenseable.py", line 51, in async_realtime_stream
    ws.recv(), timeout=self.wss_timeout)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 350, in recv
    yield from self.ensure_open()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 501, in ensure_open
    self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason
2019-04-26 14:51:28 ERROR (MainThread) [homeassistant.helpers.entity] Update for binary_sensor.motor_1 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 375, in async_device_update
    await self.async_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/sense/binary_sensor.py", line 109, in async_update
    await self._data.update_realtime()
  File "/usr/local/lib/python3.7/site-packages/sense_energy/asyncsenseable.py", line 41, in update_realtime
    await self.async_realtime_stream(single=True)
  File "/usr/local/lib/python3.7/site-packages/sense_energy/asyncsenseable.py", line 51, in async_realtime_stream
    ws.recv(), timeout=self.wss_timeout)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 350, in recv
    yield from self.ensure_open()
  File "/usr/local/lib/python3.7/site-packages/websockets/protocol.py", line 501, in ensure_open
    self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason

Anyone have any ideas here…