Rainforest Automation EMU-2 (Energy Component)

TLDR: I needed the powered USB hub, and I needed to use the sensor name in the template that I manually set; then, after rebooting a few times and waiting an hour Used Power showed up as a usable statistic. There were also some code changes mainly for cosmetic reasons.

Just to follow up on how I eventually got things to work. I went through several iterations of the config, and finally settled on this version:

sensor:
  - platform: rainforest
    port: "/dev/ttyACM3"
    name: EMU-2
  - platform: template
    sensors:
      power_grid_usage:
        unique_id: used_kWh
        friendly_name: "Used kWh"
        unit_of_measurement: kWh
        value_template: "{{ state_attr('sensor.emu_2','Delivered kWh') }}"
        device_class: energy

utility_meter:
  grid_energy_usage:
    source: sensor.power_grid_usage
    name: "Used Power"

The main problem with the config was because I assigned a name to the sensor (name: EMU-2), I had to use the name I gave it rather than the default (rainforst_energy_monitoring_unit). In hindsight, this should have been obvious, but oh well.

Other changes I made locally included changing the sensor.py file in a number of placed. I fixed the exception by making the change to line 140 of the file as mentioned in my previous comment, and then I added properties to the EMU2Sensor class for:

  • device_class
  • unique_id
  • friendly_name

Iā€™m not sure if these changes are required, but it was nice to at least have the sensor show up as an energy device and the entity UI to not display that annoying message about not having a unique_id.

After doing all that stuff, Used Power showed up in the list of statistics I could use to monitor my grid consumption. I think the names suggested by others in previous posts are probably better, but it seemed like a good idea at the time. I also averaged out a few of my power bills to create a static cost for power, and put that into the energy dashboard.

Finally, I made my own custom dashboard just for fun that shows the history of the EMU-2 device. it turns out the state of this device is the same number that is output on the screen of the EMU-2 unit. My custom dashboard currently looks like this:

1 Like

I have this integration setup throgh HACS, but I noticed that recently I no longer have any attributes on my emu2 sensor, which means my template sensors dont work and the energy dashboard doesnā€™t update. Has anyone else had this isssue? The integration is working properly. The real time power consumption matches my Sense, I just dont have attributes.

In my sensors.yaml:

  - platform: rainforest
    port: '/dev/ttyACM1'
    name: emu2

Howdy everyone, I just got an EMU2 (well not yet itā€™s on order) I was pumped to add it to my HA install but realized now that itā€™s a USB tie in, unfortunately I run my HA in hyper-v and that doesnā€™t passthrough USB (I donā€™t want to change it around at all). Is there any other way to tie this in or use a pi to connect it to HA somehow? Amazing on all the work you have done on this!

Iā€™ve never used it, but looks up ser2net (I think). It would allow for serial over ethernet. So I would assume you could plug it into a PI and pipe it over to HA? Just guessing here though.

same here. happened after I went to one of the 2022.3 upgrades. spun up a test in 2022.3.0 and no issue

1 Like

I just released an updated EMU-2 integration to HACS, which integrates with the energy monitor system. I have it working on FreeBSD, but would really like feedback for Linux as I think there might be a problem with the detection loop.

1 Like

You could try this tutorial: Connect USB devices | Microsoft Docs

I had some problems with this in that the read loop would appear to lock up but wasnā€™t sure if that was just my implementation. I ended up rolling back to WSL1 which supports USB peripherals.

I have been using your integration with HASIO on the Blue hardware. I actually switched to your from the jrhorrisberger component because I liked your code more :smiley:

I was very happy to just have integration work without manually editing YAML (and not worrying about the /dev/tty changing if I reboot the OS. So no more configurations for the sensor, template, or utility meter required to work with the power dashboard.

1 Like

Ryan, I wish I could help you find our USB problem with Home Assistant OS on my Pi 4, but in frustration, and after trying multiple Integrations, I sent the EMU-2 back to Amazon. I tried everything I could think of including a different Integration using MQTT but could never get HA to see my EMU-2.

Although the unit connected correctly with my PG&E, it would never get real-time pricing that was supposed to happen as well. Kind of made the device useless to me, even if I got it connected with HA.

In the meantime, someone gave me a Sense Energy Monitor and Iā€™ll be installing that this weekend.

Thanx again for your initial help and troubleshooting.

Jim

1 Like

Iā€™m having this problem too. I tried to key off the emu2 itself, but thatā€™s wildly inaccurate for building usage stats. I am not sure if itā€™s a problem with the integration or with HA itself. For me it started after I upgraded to 2022.4.6 a few days ago.

1 Like

I ended up switching to the above new module instead of ā€˜rainforestā€™. The one above is working much better and can even be configured from the UI. Iā€™m then keying off of it for the usage stats which have been accurate.

1 Like

I cannot find the integration in HACSā€¦ The search always comes up emptyā€¦ Any ideas? Greatly appreciated thanks

The new one shows up like this for me in HACS:
image

1 Like

found it!
Thanks.

Is there a step by step configuration?
I cannot seem to configure or add to the energy tab in HAā€¦

more specifically i cannot get past:

 1. Select `Configure | Dashboards | Energy` to enter configuration mode

Edit:
after installing in HACS and restarting, the configuration appears in the INTEGRATIONS tab

Thanks in advance

Information on how to get the data to be recognized by the energy pane in home assistant would be amazing please.

I cannot find documentation on how to get the data to Home assistantā€™s Energy pane; any help would be greatly appreciated.
Thanks!

** edit: once setup.
go to Settings in the HA front end
go to Dashboards
find ā€œEnergyā€ click on it
follow steps in the HACS setup instructions.
wait a while for data to come in

After upgrading to the new OS, Im virtualized using VMWare, I am receiving the below errors. It was working great for 4 days.

Any thoughts?

Well, redownloaded v1.2.0 then restarted home assistant and everything is back. Super weird.

Hi Dustin,

Did you see any errors before you saw this one? This error pops up when the device isnā€™t connected to Home Assistant.

This could happen if either the HA is unable to open the serial port, or it could be the read thread crashed somehow in which case I would hope it logged an error.

Funny, I too have done something very much like this with the control software that Iā€™ve been developing over the years running on Google Apps Script. I like to be extra conservative, so I assume that if the five-minute price is a new maximum for the hour, that it will probably get worse and use that price for decisionmaking.

  var weighted5MinutePrice = (weightedHourPrice * minute + fivePrice * (60.0 - minute)) / 60.0; // Use 5 minute price heavily at start of hour, little at end
  var estimatedHourPrice = Math.max(weighted5MinutePrice, weightedHourPrice);