Sense Energy Monitor (Enhanced to include devices)

Thanks for the info! Looks like Sense isn’t going to work for me.

sense.py updated to pull in upstream changes:

FYI, local monitoring can be achieved via an Iotawatt device.

1 Like

I took a look, and I think it looks perfect for my needs. Even does InfluxDB! Thanks for the tip!

I just installed, and I’m getting this error:

File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 223, in async_update_ha_state
yield from self.async_device_update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 352, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/sensor/sense.py”, line 204, in update
self._current = round(device[‘c’])
KeyError: ‘c’

The log suggests an issue with what’s returned from the sense_energy package, although I just checked my system and everything seems to be working. Is the Sense app working for you? If so, I would try rebooting HA and see if that’s enough to fix it.

Continuing the discussion from Sense Energy Monitor (Enhanced to include devices):

Sense app is working fine. I changed my config to: devices: false, and it is working fine with your custom sense app.

The electrician just installed the sense unit, and I used your app for the first time not more than an hour after installation. Very possible that since there are no devices found yet, brand new, the code is getting tripped up. Perhaps a test/try statement on the devices until at least one is initialized…

Yes, I think you’re spot-on. I thought at least always on existed from the get-go but I’ve had my system for over a year so things may have changed. I’ll get that updated hopefully in the next few days but feel free to submit a pull request.

Hi @claytonjn , I had your custom sense monitor installed and running then it looks like the binary sensors have been added in V 0.82 and 0.82.1. How do I get the official Sense component working again? I removed the files under \HASSIO\config\custom_components_pycache_ and \HASSIO\config\deps and I removed “devices: true” from my configuration file but I still get the following errors:

image

Unable to prepare setup for platform sensor.sense: Could not set up all dependencies.

9:21 PM setup.py (ERROR)

Unable to set up dependencies of sensor.sense. Setup failed for dependencies: sense

9:21 PM setup.py (ERROR)

Error during setup of component sense

9:21 PM components/sense.py (ERROR)

Any idea what steps I need to take to get Sense working again?

Documentation hasn’t been updated yet but the configuration now only takes email password and optionally timeout. Also, it’s a “component” rather than a “platform” so the configuration is no longer under sensor. It should be something like in configuration.yaml:

sense:
  email: !secret sense_email
  password: !secret sense_password

I’m working on a pull request to update the documentation now.

1 Like

I think it’s just US have email after email every year waiting to try it in Australia. Has anyone try this in Australia yet an did it work. If it did I will be getting one but till then I have to wait.

Great work! How about contributing this back into the official HASS code base?

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’.