openevse_esp32_firmware icon indicating copy to clipboard operation
openevse_esp32_firmware copied to clipboard

Home Assistant intergration

Open jeremypoulter opened this issue 2 years ago • 34 comments

The current Home Assistant integration is a bit outdated and with the new features in both OpenEVSE and Home assistant we can do better:

  • Auto discovery
  • Setup via Home Assistant UI
  • Real time updates via web socket
  • Support energy API
  • Use newer OpenEVSE APIs

Sensors

  • Current
  • Voltage
  • Power?
  • Session Energy
  • Total Energy
  • Status
  • Temps
  • Vehicle connected
  • Rssi

Actions

  • Max current
  • Charge current
  • Manual Override
  • Schedule
  • Divert mode

https://developers.home-assistant.io/docs/creating_component_index

jeremypoulter avatar Sep 10 '21 00:09 jeremypoulter

Is there any ETA for updating integration? Trying to accomplish charging current regulation in home assistant by whole home usage (limited home electricity input) for a while now.

andriuskr avatar Sep 11 '21 03:09 andriuskr

Probably not going to be till next month, but no promises...

jeremypoulter avatar Sep 12 '21 12:09 jeremypoulter

check this out for the time being:

https://gist.github.com/TonyApuzzo/c0fe22458d4dae0effb47b951b464484#file-openevse2-yaml

doppiaemme avatar Sep 13 '21 14:09 doppiaemme

https://github.com/cathiele/homeassistant-goecharger

jeremypoulter avatar Oct 09 '21 00:10 jeremypoulter

https://github.com/tmjo/charger-card

jeremypoulter avatar Oct 09 '21 00:10 jeremypoulter

Hi @jeremypoulter, I'm very interested in collaborating with you to help get this out, as much as my limited time / skillset will allow. I don't have much python experience, but have managed to create a simple Home Assistant integration in the past.

OpenEVSE seems to align well with Home Assistant's ethos (full local control) so I would expect this to be a popular integration.

Do you have a WIP fork yet we could collaborate on?

I'm also curious if you have thoughts on how to accomplish these two items. I believe this may require updates to the OpenEVSE wifi firmware?

  • Auto Discovery
  • Real time updates via web socket

drobtravels avatar Oct 28 '21 21:10 drobtravels

Sorry, I have not progressed more than creating the ticket and doing a bit of research. Would be great to get some assistance on this however.

Auto Discovery

This should be fairly simple via mDNS, Home Assistant already supports this as a discovery type. To make it a little simpler we may need to add a few records to help filter the devices, similar to what I have done in EmonESP.

Real time updates via web socket

Everything that is sent over MQTT is also sent to a websocket to update the web UI so all that is needed should be in place already.

Also note I am working on documentation of the API via #245 / https://openevse.stoplight.io/docs/openevse-wifi-v4

jeremypoulter avatar Oct 28 '21 22:10 jeremypoulter

As I had looked it up, I added the required mDNS tweaks, #260

jeremypoulter avatar Oct 28 '21 23:10 jeremypoulter

I've been working on this a bit myself: https://github.com/firstof9/openevse

firstof9 avatar Oct 31 '21 01:10 firstof9

I've been working on this a bit myself: https://github.com/firstof9/openevse

This integration is great! Exactly what I was looking for. It would be great if you could add an option to use mqtt in the config flow as well!

omriasta avatar Nov 10 '21 18:11 omriasta

It would be great if you could add an option to use mqtt in the config flow as well!

MQTT has it's own integration you can use.

This is specifically geared towards using the HTTP API as much as possible.

firstof9 avatar Nov 10 '21 19:11 firstof9

It would be great if you could add an option to use mqtt in the config flow as well!

MQTT has it's own integration you can use.

This is specifically geared towards using the HTTP API as much as possible.

Yep, I have MQTT setup as well. Was thinking of having them combined all in one integration where one could select if they setup using http or mqtt. My specific setup is I have 2 units, one is on the local network and the other is remote but publishing to my mqtt broker.... I guess big picture if we want to replace the current integration, having both options combined into one would be great for all uses.

omriasta avatar Nov 10 '21 19:11 omriasta

Please open a feature request (on my repo), I'll see what I can do, I can't test mqtt right now due to openevse not connecting to my broker for some unknown reason.

firstof9 avatar Nov 10 '21 19:11 firstof9

@firstof9 are you using a secure connection for MQTT? could be certificates is so, but do need to do work on reporting failures. Maybe open another issue and we can discuss there?

jeremypoulter avatar Nov 13 '21 10:11 jeremypoulter

Just putting in my 2 cents since I had originally said I would work on this. Personally I won't be able to use a Home Assistant integration with the new API until #272 is resolved.

For now I'm using the gist referenced above. Unfortunately its not reliable due to #135

drobtravels avatar Dec 10 '21 03:12 drobtravels

Trying to get to both of those, hopefully soon

jeremypoulter avatar Dec 10 '21 11:12 jeremypoulter

@jeremypoulter have you considered using ESPHome? It would probably mean a big rewrite but it brings so much out of the box that I thought I'd leave the suggestion here.

ruimarinho avatar Dec 22 '21 22:12 ruimarinho

ESPHome wouldn't really fit for this kind of hardware/project.

firstof9 avatar Dec 22 '21 22:12 firstof9

I have started to use the integration from @firstof9 (thanks) - I see that there are still some stuff to be implemented, like the ability to set the charge mode or even the manual override. But there is one thing that surprises me, which is that the only way to get the Level min and max current is through a RAPI command. This information should be provided with the level, as it is the basis to show a proper menu to manually select the current. Right now @firstof9 is hardcoding values up to 48A, which is over what a regular charger would support in Level 2 configuration in Europe.

@jeremypoulter any plan on providing this information through the API?

Many thanks to you all for your fantastic software.

jcsogo avatar Dec 28 '21 08:12 jcsogo

I am currently working on that as part of #140

jeremypoulter avatar Dec 28 '21 09:12 jeremypoulter

I see that there are still some stuff to be implemented, like the ability to set the charge mode or even the manual override.

It's still a work in progress, as more API stuff get's fleshed out the move function I can give the integration.

firstof9 avatar Dec 28 '21 13:12 firstof9

Fully MQTT doesn't seem possible at the moment due to RAPI deprivation and no MQTT equivalent for the HTTP API.

rbray89 avatar Mar 07 '22 12:03 rbray89

Fully MQTT doesn't seem possible at the moment due to RAPI deprivation and no MQTT equivalent for the HTTP API.

MQTT API is now available since this PR has been merged which should be equivalent to HTTP API https://github.com/OpenEVSE/ESP32_WiFi_V4.x/pull/379. Big thanks to @KipK

Se docs: https://github.com/OpenEVSE/ESP32_WiFi_V4.x/blob/master/docs/mqtt.md

glynhudson avatar Aug 04 '22 15:08 glynhudson

I've been working on this a bit myself: https://github.com/firstof9/openevse

Nice work! That's a really nice integration. The only thing that's missing is the ability to set a schedule and the ability to manually start / stop a charge.

glynhudson avatar Aug 04 '22 15:08 glynhudson

set a schedule

This will likely be setup as a service call in Home Assistant.

the ability to manually start / stop a charge.

Are you referring to the override on that? If so, this will likely be a service call in Home Assistant as well.

firstof9 avatar Aug 04 '22 15:08 firstof9

About MQTT, I've just added a PR adding /schedule /schedule/set /schedule/clear

There should have everything needed to completely control OpenEvse from Mqtt without any need of RAPI. If you see something missing on some use case , please share

You can use /claim to manually start / stop, set charge current . It already has bigger priority than timers. /override has highest priority, but there should be few need to use it anymore.

KipK avatar Aug 04 '22 16:08 KipK

Home Assistant really should be using the HTTP API, you should probably only use MQTT for control when you can not use HTTP as MQTT really isn't designed for one&to-one comms (it is much better at broadcasting one-to-many events) and although you can do it you will get much more reliable results when using HTTP particularly around error handling.

jeremypoulter avatar Aug 05 '22 02:08 jeremypoulter

Not completely agree but it's a matter of taste. With QoS and Last Will, it's quiet resilient. With many different devices/sensors/actuators using different protocols ( zwave, ZigBee, http, some binary proprietary stuff,etc ), I kinda like to unify everything over MQTT. You make me remind I've wanted to add an error topic too 😊

I don't use home-assistant here, but an equivalent solution ( Jeedom ). With many different devices without Mqtt, it would need different addons for each protocol here.

KipK avatar Aug 05 '22 07:08 KipK

There's a 3rd feature I'm still working on as well for Home Assistant, auto discovery, but I can't seem to find any mDNS for OpenEVSE.

firstof9 avatar Aug 05 '22 14:08 firstof9