Sense Energy Monitor (Enhanced to include devices)

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…

@gregg098 / @Sebastien_Couture / @AndyRPH

Is this component working for you guys?

I tried it the last few releases and it was still broken. I have not tried it in .92.

this is still broken in .94

Just upgraded everything last night to .94 as well and you’re right it still throws the errors. Everything seems to work OK though is that everyone else’s experience or is there something broken that I don’t realize?

Same thing for me

Same here.

Has anyone opened an issue for the “WebSocket connection is closed: code = 1000 (OK), no reason” in the logs? Everything works fine, it’s just log spam.

1 Like

@claytonjn - Any plans to get this merged back into the main repo ?

1 Like

Not really. This was written before the native integration included devices; now that it does, the only difference is that my CC included energy usage of each device but to be honest that was probably a really bad idea. Entity state changes result in a relatively high amount of overhead…having all Sense devices updating very frequently is a lot more demanding then just updating state on/off. In my case, at least, there’s no good reason for me to know per-device energy use.

I think there is value in being able to rate limit the sensors and then use the utility component to selectively tally up daily/monthly usage of specific devices Sense can report. I’d love to keep track of how much power/money I spend plugging in my PHEV car m, but there isn’t another way to get at the data than sense right now.

But that’s not your use case so I cant blame you for not continuing it.

I can definitely see the use of that, I just don’t think including that in HA entities is the right way to go. If you’re already using Node-RED, there’s a Sense node (https://flows.nodered.org/node/node-red-contrib-unofficial-sense) and you could write a simple flow that logs energy use every n seconds to a database, or Google Sheets, or whatever. You could also use IFTTT to pull data from Sense and log to Google Sheets, which wouldn’t be any overhead for your system and for something like this latency and even a few missfires wouldn’t be an issue. Just a couple ideas that (IMO) would be a better solution.

I agree 100%… I would be “ok” with it if I could limit the devices via include/exclude or just get the overall Current, Daily, Weekly, Monthly, Yearly. I have 60 devices that sense has found and polling takes it’s toll. But that is just my use case.

I just got a Sense monitor, I wish the official component would create each sensor entity_id as “binary_sensor.sense_xxxx”.

1 Like

Yes it is.
You will have
binary_sensor.always_on, binary_sensor.other and binary_sensor.device_name.
To have it in HA you have to restart HA.

I believe he’s talking about name-spacing Sense entity’s… as it stands today if sense detects a “light” you get an entity named “binary_sensor.light” which isn’t very easy to find when you maybe have 100 other lights …

1 Like