Skip to content

Instantly share code, notes, and snippets.

@flaviut
Last active August 22, 2024 18:14
Show Gist options
  • Save flaviut/93a1212c7b165c7674693a45ad52c512 to your computer and use it in GitHub Desktop.
Save flaviut/93a1212c7b165c7674693a45ad52c512 to your computer and use it in GitHub Desktop.
Setting up Emporia Vue 2 with ESPHome
@stratus-ss
Copy link

thanks @cdavis289 and @flaviut I appreciate what you both do to help this project!

@hiveai
Copy link

hiveai commented Jul 28, 2022

What is the recommended config for an unused input on the emporia vue2? I have some unused inputs that are showing values that are jumping all around (e.g. 0W->8W->24W->0W). How can I configure these Emporia inputs as unused and zero them out?

@flaviut
Copy link
Author

flaviut commented Jul 28, 2022

@hiveai delete their lines in the config and remove the places they're referenced from

@hiveai
Copy link

hiveai commented Jul 29, 2022

@flaviut and other contributors: Thanks for this great project and documentation! I have the vue2 flashed with custom ESPHome code and it working.
Is there a pointer to the recommended way to integrate the data into the energy dashboard in home assistant? I can bring up the device under ESPHome and see the power usage, but I'm not clear on how to configure Home Assistant to use this as a data source for energy monitoring.

@cdavis289
Copy link

Settings -> Dashboards -> Energy -> Electricity Grid (left side) -> Add Consumption or Add device

Select Emporia Vue Circuit Daily Energy Entities or Total Daily Energy.

I like to add each circuit to the consumption. Home assistant will stack the entities in the bar chart so you can get a visual of which circuit uses the most energy. You can also add them to the devices to see a comparison. Just depends on your preference.

@hiveai
Copy link

hiveai commented Jul 29, 2022

@cdavis289 Thanks! That's the info I needed. Looking up in the other comments I see that some folks are using MQTT for integration. Is that in addition to adding devices to the energy dashboard, or instead of the energy dashboard integration. What does MQTT integration of the ESPHome Vue2 get you? I apologize for these basic questions, but looking at the documentation and previous Comments/Q&A it's not clear to me.

@flaviut
Copy link
Author

flaviut commented Jul 29, 2022 via email

@dcorwin8222
Copy link

dcorwin8222 commented Jul 31, 2022 via email

@flaviut
Copy link
Author

flaviut commented Jul 31, 2022

@Jens5395
Copy link

Jens5395 commented Aug 5, 2022

If I upload the bare stub that is generated when a new device is added to ESPHome, should the Emporia connect to wifi? I can't upload the full configuration because it won't compile on the pi4 so I was hoping to maybe do the full configuration over the air once the Emporia is connected to the network. Right now I am dead in the water :(

@flaviut
Copy link
Author

flaviut commented Aug 5, 2022 via email

@Jens5395
Copy link

Jens5395 commented Aug 6, 2022

What's a 'regular computer'? LOL
Anyway, things have progressed substantially from my earlier post. The stub uploads and programs just fine and if you supply enough juice, the emporia does connect to the wifi network. I had to hook up line power to the emporia to make it run.
I tried everything I could think of to upload the required configuration but of course because of the lack of the required tool chain, that got me nowhere :(.
I have now set up an ubuntu laptop with ESPHome and ESPHome dashboard (no Home Assistant) and I got the configuration to compile! now my problem is 'how do I get the magic file that compiled onto the emporia which is wifi connected to the emporia'.. Unfortunately the upload via wifi fails and the ESPHome program will not recognize my serial port to do a wired transfer.
I am also working on some network issues because even though Ubiquity reports the empora to be on line, I can not ping it (although pings might not be allowed in ESPHome.
More research is required!

@flaviut
Copy link
Author

flaviut commented Aug 6, 2022

I'm pretty sure something weird is going on with your wifi, ping works fine for me:

$ ping emporiavue2.lan
PING emporiavue2.lan (192.168.86.144) 56(84) bytes of data.
64 bytes from emporiavue2.lan (192.168.86.144): icmp_seq=1 ttl=255 time=114 ms
64 bytes from emporiavue2.lan (192.168.86.144): icmp_seq=2 ttl=255 time=17.5 ms
64 bytes from emporiavue2.lan (192.168.86.144): icmp_seq=3 ttl=255 time=55.1 ms

anyway, now that you've compiled the file, you can transfer the .bin file over to the Pi, where presumably you had a working serial connection. Something like esptool.py --port /dev/ttyUSB0 write_flash 0x0 emporiavue2.bin should work.

@Jens5395
Copy link

Jens5395 commented Aug 6, 2022

Unfortunately, I am giving up for now.
I am now able to send a configuration from my secondary (non pi4) computer to the emporia but I am now getting a butt load of linking errors during the compile which I do not know how to deal with.
Note that I DO NOT HAVE the full Home Assistant installed on this computer. I only installed ESPHome and ESPHome dashboard. I suspect that some of te stuff that is being complained about relates to the HA not being installed.
Here is a shortened version that shows the beginning of the compile followed by a tiny portion of the linking errors (everything after the line that starts with "linking...." is an error message:

INFO Reading configuration config/emporia-01.yaml...
INFO Detected timezone 'America/Vancouver'
INFO Generating C++ source...
INFO Compiling app...
Processing emporia-01 (board: esp32dev; framework: espidf; platform: platformio/espressif32 @ 3.5.0)

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • framework-espidf @ 3.40302.0 (4.3.2)
  • tool-cmake @ 3.16.4
  • tool-ninja @ 1.7.1
  • toolchain-riscv32-esp @ 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch2
  • toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch2
    Reading CMake configuration...
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    No dependencies
    Linking .pioenvs/emporia-01/firmware.elf
    /home/jens/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/emporia-01/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection17send_sensor_stateEPNS_6sensor6SensorEf+0xc): undefined reference to esphome::sensor::Sensor::has_state() const' /home/jens/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/emporia-01/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0x10): undefined reference to esphome::sensor::Sensor::get_unit_of_measurementabi:cxx11'
    /home/jens/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pioenvs/emporia-01/src/esphome/components/api/api_connection.o:(.literal._ZN7esphome3api13APIConnection16send_sensor_infoEPNS_6sensor6SensorE+0x14): undefined reference to `esphome::sensor::Sensor::get_accuracy_decimals()'

@Jens5395
Copy link

Jens5395 commented Aug 7, 2022

Final entry:

For reasons unknown to me, the Emporia configuration compiled, was installed wireless and seems to function. There was a computer reboot involved so that might have fixed whatever was causing the compile errors.
To sum it up, a pi4 64 bit HA server configuration can not compile the Emporia Vue 2 configuration via ESPHome. It can however generate a configuration stub that, once uploaded to the emporia with a wired connection, will allow the emporia to connect to the network via wifi.
Now that the Emporia is on line, the Emporia configuration can be built. This is done, in my case, on a Ubuntu machine that runs an Intel processor and has the required tool chains available.
I installed ESPHome and ESPHome dashboard on my computer (the one wit the Intel processor). Note that there was only ESPHome installed and no Home Assistant files/system. I started up ESPHome, went to the dashboard (btw, you can also do this without the dashboard and I think I read that the dashboard only works on Linux) and generated a new stub for the Emporia. I then copied the configuration as shown in the article here into the stub, over-writing the temporary stub (it was just a place holder). I adjusted the wifi parameters for my setup. There are a couple of gotcha's here. My normal esphome configuration files use !secrets for the ssid and password. This will not work because we are compiling on a computer that does not have these HA options available. The ssid and password must be hard coded into the configuration. I also had to set up static IP parameters in the configuration in order to make this work .... although I can't recall the exact reason. All my esphome devices have static IP's set up in the router so hardcoding a static IP in the configuration might not be required. YMMV.
So, we have an Emporia device that is on the network and we have a configuration file set up on the Intel computer. All that is required now is to install the new configuration to the Emporia.
If all goes as planned (and not like in my case), the configuration will be compiled, uploaded to the Emporia that is on line already and when finished, the Emporia will reboot and spew out all kinds of data which will be captured in the Home Assistant system running on the Pi4.
When you set up the hard coded credentials, please note that the SSIDS field is case sensitive. I new this was so for the password but did not realize that this was the case for the SSID. That error took me WAY too long to find!
I hope that this might help future HA builders to set up an Emporia device without all the crap I went through .....

@Jens5395
Copy link

Jens5395 commented Aug 7, 2022

The instructions for the Emporia indicate that it doesn't matter which of the three 200A circuits you plug into. I am in North America so there are two 200A clamps and it does indeed matter how they are connected to the Emporia. With the configuration script shown in this article, one needs to use inputs A and B.
Yes I know they are called A and B in the configuration but I didn't make the connection ....
While the instructions allude to the fact that you need to keep the legs sorted, I would like to stress that it is important not only for the current clamps but also how you hook up power to the Emporia. If the power leads to the emporia do not not match which 200A clamp is on what leg, readings might be wrong or you might have no readings at all. The black Emporia power wire needs to be on the same power distribution leg that has current clamp A on it. The red power wire needs to be on the same power leg as the clamp that feeds input B.

@Jens5395
Copy link

Jens5395 commented Aug 7, 2022

How does HA know when to reset daily energy numbers? My new install doesn't seem to reset at midnight.

@flaviut
Copy link
Author

flaviut commented Aug 7, 2022 via email

@flaviut
Copy link
Author

flaviut commented Aug 7, 2022 via email

@clowrey
Copy link

clowrey commented Aug 8, 2022

Thanks for all the work getting this working!! I spent about 5 hours thinking there was some way I could get it to compile on a raspberry pi 4 with 4gb ram- including switching to the 32bit version, but it still wont work.. So in the end I relented and am now running home assistant on a 7 year old i3 intel NUC and it works great!! I definitely recommend anyone wanting to use this currently in a standalone installation to just buy a used intel NUC for < $100 on ebay and be done with it... Going to try get it working with three phase inputs some time soon, not sure how hard/easy that will be.

EDIT > looks like it works with three phase just by adding in phase C in the config file! awesome!

@Jens5395
Copy link

Jens5395 commented Aug 8, 2022

I spent way too many hours on this ... but in the end, my method works great and I still have my original Pi4 running HA.

@clowrey
Copy link

clowrey commented Aug 8, 2022

I spent way too many hours on this ... but in the end, my method works great and I still have my original Pi4 running HA.

But can you change the ESPhome settings from the RPI4? that is my main reason, I anticipate needing to re-compile and update, and will have remote systems running this etc..

Edit > I'm not saying one method is better than the other, just saying for me this is overall easier and more maintainable, at least until we can compile it on ARM..

@Jens5395
Copy link

Jens5395 commented Aug 8, 2022

No, I would not be able to change the configuration from the Pi4 .... that would require a recompile which can't be done from the Pi4.
I installed ESPHome and the dashboard on one of my laptops. It just sits there ready for use. If I need to recompile, I just start up ESPHome, go to the dashboard, load te configuration file, tweak it and send it back to the Emporia - no muss, no fuss, I just have to remember to do it via Chrome instead of my normal browser (Thunderbird).
I recompiled a whole bunch of times as I was setting everything up so yes, you absolutely need to be able to recompile and send te result to the Emporia. I am still working out a couple of issues and expect that I am not finished configuring things.
BTW, I did not try generating the .bin file on my laptop, transfer it to the pi and then send it to the Emporia. That should (in theory) work but it's an extra step that is not really required.

@Jens5395
Copy link

Jens5395 commented Aug 9, 2022

Does anybody else have issues with 'daily energy' never resetting at the end of the day?
I did need to set my own sntp server (network doesn't allow traffic to the outside) but that didn't help. Looking at the logs from the Emporia, every message has the correct time in front of it.
Let me clarify this a bit - if I look at the 'energy' dashboard, the daily energy is correct. I have an 'entities' card set up in one of my dashboard views and it shows individual circuits and individual daily power usage (and total daily power usage). It is those totals sensors that do not reset.
Platfom 'Total Daily Energy Sensor' states:

# Enable time component to reset energy at midnight
time:
  - platform: sntp
    id: my_time

From what I can tell, the time platform is working as every single status message from the Emporia has the correct time stamp .... but maybe that time component is different from the time that shows up in the logs - how do I check if id: my_time is correct? my_time is not an entity or a helper so how can I verify it?

@mgulick
Copy link

mgulick commented Aug 9, 2022

Does anybody else have issues with 'daily energy' never resetting at the end of the day?

My daily energy value also did not reset at first. I don't know exactly what I did to fix it. It may have started working on its own at some point after a few days or maybe a week. I do remember that I changed the time platform from sntp to:

time:
  - platform: homeassistant
    id: homeassistant_time

This is working fine for me and is syncing time via home assistant. I have my emporia vue 2 on an isolated VLAN which doesn't have internet access, so sntp probably wasn't working (my DHCP server hands out local ntp server info, but I think most devices ignore that).

@Jens5395
Copy link

Jens5395 commented Aug 9, 2022

Thanks for that mgulick. I tried that this morning but this gives me a compile error which is likely due to me having to compile the Emporia configuration on a computer other than the computer running HA.
It is good to know I am not the only person that has/had daily reset issues.

*** [.pioenvs/emporia-01/src/esphome/components/sntp/sntp_component.o] Source `src/esphome/components/sntp/sntp_component.cpp' not found, needed by target `.pioenvs/emporia-01/src/esphome/components/sntp/sntp_component.o'.

@stephenjamieson
Copy link

Is there another location, discord or an issue somewhere, that these things can be discussed. I'm honestly watching this gist in case there are changes or issues with the integration itself.

@clowrey
Copy link

clowrey commented Aug 9, 2022

You could just watch the Integration source repository that is linked to in the example configuration. Not sure where else to discuss issues as there is no issue tracker?

changes or issues with the integration itself.

@mgulick
Copy link

mgulick commented Aug 9, 2022

@Jens5395, I would frequently have compile errors when rebuilding after making changes to the configuration. Cleaning the build artifacts usually resolved the issue. It looks like this option is called "Clean Build Files" from the ESPHome dashboard (https://esphome.io/guides/getting_started_hassio.html) and esphome clean <config> from the ESPHome CLI (https://esphome.io/guides/cli.html#clean-command).

@Jens5395
Copy link

Jens5395 commented Aug 9, 2022

Ha!!!! That did the trick, it compiled! Now to see if it fixes things at midnight ....
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment