# OpenEVSE Home Assistant Integration

**URL:** <https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059>\
**Category:** OpenEVSE\
**Tags:** homeassistant\
**Created:** [30 March 2018 23:53 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059 "2018-03-30T23:53:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [30 March 2018 23:53 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/1 "2018-03-30T23:53:34Z")

</div>

> [@Significant OpenEVSE WiFi 2.0 Firmware Update. Call for beta testers](https://community.openenergymonitor.org/t/significant-openevse-wifi-2-0-firmware-update-call-for-beta-testers/4751/7):
>
> I’ve had the OpenEVSE for a few years now, and I had added the ESP8266 to it and gotten it configured at one time, but never really used that functionality. Now, I am working with some home automation stuff with [hass.io](http://hass.io) and I see they have an OpenEVSE connection so I want to update my OpenEVSE.

For completeness, here’s the Home Assistant OpenEVSE sensor component. Let me know how you get on if you mange to test this:

> **[OpenEVSE](https://www.home-assistant.io/integrations/openevse/)**
>
> Instructions on how to integrate a WiFi-equipped OpenEVSE Charging station with Home Assistant

---

<div class="post-metadata">

**Author:** ![jakekooser](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jakekooser](https://community.openenergymonitor.org/u/jakekooser)\
**Post date:** [31 March 2018 09:26 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/2 "2018-03-31T09:26:10Z")

</div>

I tried to implement that in my configuration.yaml file but it probably belongs in sensors.yaml because nothing showed up. I ran out of time to test, and now I’m in Munich waiting for my connecting flight.

Jake

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [31 March 2018 12:03 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/3 "2018-03-31T12:03:34Z")

</div>

> [@Significant OpenEVSE WiFi 2.0 Firmware Update. Call for beta testers](https://community.openenergymonitor.org/t/significant-openevse-wifi-2-0-firmware-update-call-for-beta-testers/4751/16):
>
> I tried to implement that in my configuration.yaml file but it probably belongs in sensors.yaml because nothin

I’m pretty sure you can added it to either file. The yaml syntax can be quite picky. See my openenergymonitor example where I added sensor info to `confuguration,yaml`. Probably not best practice but works for simple setups:

> <https://github.com/openenergymonitor/oem_home-assistant/blob/master/configuration.yaml#L54>

---

<div class="post-metadata">

**Author:** ![jakekooser](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jakekooser](https://community.openenergymonitor.org/u/jakekooser)\
**Post date:** [4 May 2018 16:26 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/4 "2018-05-04T16:26:32Z")

</div>

Hi Glyn,

I managed to get one of my OpenEVSE units working with the new firmware, I have Hassio loaded in docker, I installed emoncms with docker, and I have the OpenEVSE posting to emoncms. Not going to lie, I feel pretty accomplished right now.

However, what I really want to do is ‘see’ if the car is connected to the OpenEVSE as a condition for presence detection if I can. I can get empty icons by using your configuration example above, but I don’t have those parameters set up in my emoncms, and I’m not even sure if ‘status’ exists.

Any pointers?

---

<div class="post-metadata">

**Author:** ![jakekooser](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jakekooser](https://community.openenergymonitor.org/u/jakekooser)\
**Post date:** [5 May 2018 00:59 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/5 "2018-05-05T00:59:26Z")

</div>

I have managed to get values in the icons now. I’ve been trying to convert the temperature to F, which I can see in emoncms, but not in hassio. Also, my car finished charging just about the same time I made the tweaks for the current reading, so I’m not sure if it’s correct or not.

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [14 April 2019 12:58 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/6 "2019-04-14T12:58:37Z")

</div>

Nice work @jakekooser, that sounds really great 👍

It would be cool if you could share your .yaml setup and some screenshots to show off your setup.

I’ve finally got round to testing the OpenEVSE Home Assistant integration myself, however I’ve not been able to get it to work. I’ve entered the following into my config.yaml file, after a restart the metrics do not display and there are no errors in the logfile, any ideas?

```auto
  - platform: openevse
    host: 192.168.XX.XX
    monitored_variables:
      - status
      - usage_session
      - charge_time

```

---

<div class="post-metadata">

**Author:** ![jakekooser](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jakekooser](https://community.openenergymonitor.org/u/jakekooser)\
**Post date:** [15 April 2019 03:03 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/7 "2019-04-15T03:03:51Z")

</div>

Hi Glyn,

I am not sure if I ever got it working the way I wanted to with the IP address. I do know I enabled MQTT and just ended up connecting that to my MQTT server and it’s working fine.

This is what I have in my sensors.yaml file - I separated it out from the main configuration.yaml to save space.

```
### Smart car charging amps

- platform: mqtt

name: OpenEVSE amps

state_topic: "car/charging_amps"

unit_of_measurement: 'amps'

### Smart car connection status

- platform: mqtt

name: OpenEVSE status

state_topic: "car/status"

### OpenEVSE total KWh

- platform: mqtt

name: OpenEVSE KWh

state_topic: "openevse/kwh"

```

I use node-red to process the reading I get from the OpenEVSE like so:

 ![image.png](https://community.openenergymonitor.org/uploads/default/original/2X/3/37fe65b772125327affcf9416890a7d6ff9f7e9b.png)

I use a state-machine node to process the connection status from the EVSE to tell me on my phone (VIA MQTT message) if the car is charging, connected, or disconnected like so:

 ![image.png](https://community.openenergymonitor.org/uploads/default/original/2X/d/d5fb144d2b0570b441a14dfaa6bbf0df1347de3d.png)

 ![image.png](https://community.openenergymonitor.org/uploads/default/original/2X/f/fb4aa84d1c80a65ce23c09a26cf1185be16648ba.png)

And that allows me to see a graph on a Lovelace history-graph card, and display the charging status and current as entities

![image.png](https://community.openenergymonitor.org/uploads/default/original/2X/6/6705558bab24c07827dccb3df996f6ddc9d74d72.png)

Here’s what the graph looks like, I just came back from a dinner party and plugged the car in.

![image.png](https://community.openenergymonitor.org/uploads/default/original/2X/1/19202690054af41a64b8b3dc02ddb4205479dcaf.png)

For me, it was easiest just to jump in with MQTT, since I really didn’t have much understanding of the Open Energy Monitor stuff. I still don’t really have a perfect grasp of MQTT, but it allowed me to get the information I wanted to see easily enough.

Hope this helps!

Jake

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [15 April 2019 14:22 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/8 "2019-04-15T14:22:52Z")

</div>

Thanks, I agree MQTT is the best way to do this. I’ve just seen an open issue on HA github discussion the openevse component:

[https://github.com/home-assistant/home-assistant/issues/12954](https://github.com/home-assistant/home-assistant/issues/12954)

User **[TonyApuzzo](https://github.com/TonyApuzzo)** has developed a MQTT based solution which looks very good:

[![](https://user-images.githubusercontent.com/341037/54160537-6f128f00-4415-11e9-9c8d-a70af3c42078.png) ](https://user-images.githubusercontent.com/341037/54160537-6f128f00-4415-11e9-9c8d-a70af3c42078.png)

---

<div class="post-metadata">

**Author:** ![jakekooser](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/e0b2c6/32.png) [@jakekooser](https://community.openenergymonitor.org/u/jakekooser)\
**Post date:** [15 April 2019 14:40 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/9 "2019-04-15T14:40:01Z")

</div>

That looks pretty nice as well. I haven’t really needed any more information than my setup gathers. I really need to sort out a node-red automation to remind me if the car is not plugged in.

---

<div class="post-metadata">

**Author:** ![glyn.hudson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/glyn.hudson/32/35003_2.png) [@glyn.hudson](https://community.openenergymonitor.org/u/glyn.hudson)\
**Post date:** [25 March 2021 02:23 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/10 "2021-03-25T02:23:45Z")

</div>

The core Home Assistant OpenEVSE integration is now working again and compatible with all OpenEVSE WiFi since about 2017 V2.x, V3.x and V4.x 👏

A few tweets are still needed e.g truncate energy readings! But the basic data is updating as sensors in HA

 ![Screenshot 2021-03-25 02.07.07](https://community.openenergymonitor.org/uploads/default/original/3X/a/1/a118b49ba52832b9d0e9f78f08b1b402954d950f.png)

To enable it just add the following to your HA `configuration.yaml` and change the IP address to match your unit.

```auto
  - platform: openevse
    host: 192.168.86.242
    monitored_variables:
      - status
      - charge_time
      - rtc_temp
      - ir_temp
      - ambient_temp
      - usage_session
      - usage_total

```

Sensors will then appear in HA and can be put into UI cards in the usual way.

The integration is basic at the moment, but overtime more functions will be added e.g control.

If anyone wants to help with this effort here are some dev threads:

> <https://github.com/home-assistant/core/issues/12954>
>
> \*\*Home Assistant release (\`hass --version\`):\*\*
> 
> hassio version 1.2.1
> homeassi…stant version 0.64.3
> 
> \*\*Python release (\`python3 --version\`):\*\*
> 
> cannot get python version - command not found
> \*\*Component/platform:\*\*
> 
> openevse
> \*\*Description of problem:\*\*
> 
> I have been struggling to get the openevse component to work - Running the latest release of Home Assistant. Even did a clean install again today. The component doesn't discover the openevse.
> 
> \*\*Expected:\*\*
> 
> Expect the sensors to become available and display in homepage. Instead there is an error logged for each monitored variable. 
> 
> sample from my configuration.yaml:
> \`\`\`yaml
> - platform: openevse
> host: 172.18.21.217
> monitored\_variables:
> - status
> - charge\_time
> - rtc\_temp
> - ir\_temp
> - ambient\_temp
> - usage\_session
> - usage\_total
> \`\`\`
> \*\*Traceback (if applicable):\*\*
> \`\`\`
> openevse: Error on device update!
> Traceback (most recent call last):
> File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity\_platform.py", line 197, in \_async\_add\_entity
> yield from entity.async\_device\_update(warning=False)
> File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 327, in async\_device\_update
> yield from self.hass.async\_add\_job(self.update)
> File "/usr/lib/python3.6/asyncio/futures.py", line 332, in \_\_iter\_\_
> yield self # This tells Task to wait for completion.
> File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in \_wakeup
> future.result()
> File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
> raise self.\_exception
> File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
> result = self.fn(\*self.args, \*\*self.kwargs)
> File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/openevse.py", line 85, in update
> self.\_state = self.charger.getStatus()
> File "/usr/lib/python3.6/site-packages/openevsewifi/\_\_init\_\_.py", line 42, in getStatus
> status = self.sendCommand(command)
> File "/usr/lib/python3.6/site-packages/openevsewifi/\_\_init\_\_.py", line 37, in sendCommand
> return response.group(1).split()
> AttributeError: 'NoneType' object has no attribute 'group'
> \`\`\`

> <https://github.com/home-assistant/core/pull/38892>
>
> The latest version of openevsewifi fixes some of the outstanding issues
> with th…e component.
> 
> Signed-off-by: Dennis Gilmore \<dennis@ausil.us\>
> 
> \<!--
> You are amazing! Thanks for contributing to our project!
> Please, DO NOT DELETE ANY TEXT from this template! (unless instructed).
> \--\>
> \## Breaking change
> \<!--
> If your PR contains a breaking change for existing users, it is important
> to tell them what breaks, how to make it work again and why we did this.
> This piece of text is published with the release notes, so it helps if you
> write it towards our users, not us.
> Note: Remove this section if this PR is NOT a breaking change.
> \--\>
> 
> 
> \## Proposed change
> \<!--
> Describe the big picture of your changes here to communicate to the
> maintainers why we should accept this pull request. If it fixes a bug
> or resolves a feature request, be sure to link to that issue in the
> additional information section.
> \--\>
> 
> 
> \## Type of change
> \<!--
> What type of change does your PR introduce to Home Assistant?
> NOTE: Please, check only 1! box!
> If your PR requires multiple boxes to be checked, you'll most likely need to
> split it into multiple PRs. This makes things easier and faster to code review.
> \--\>
> 
> \- \[x\] Dependency upgrade
> \- \[\] Bugfix (non-breaking change which fixes an issue)
> \- \[\] New integration (thank you!)
> \- \[\] New feature (which adds functionality to an existing integration)
> \- \[\] Breaking change (fix/feature causing existing functionality to break)
> \- \[\] Code quality improvements to existing code or addition of tests
> 
> \## Example entry for \`configuration.yaml\`:
> \<!--
> Supplying a configuration snippet, makes it easier for a maintainer to test
> your PR. Furthermore, for new integrations, it gives an impression of how
> the configuration would look like.
> Note: Remove this section if this PR does not have an example entry.
> \--\>
> 
> \`\`\`yaml
> \# Example configuration.yaml
> 
> \`\`\`
> 
> \## Additional information
> \<!--
> Details are important, and help maintainers processing your PR.
> Please be sure to fill out additional details, if applicable.
> \--\>
> 
> \- This PR fixes or closes issue: fixes #
> \- This PR is related to issue: 12954
> \- Link to documentation pull request: 
> 
> \## Checklist
> \<!--
> Put an \`x\` in the boxes that apply. You can also fill these out after
> creating the PR. If you're unsure about any of them, don't hesitate to ask.
> We're here to help! This is simply a reminder of what we are going to look
> for before merging your code.
> \--\>
> 
> \- \[\] The code change is tested and works locally.
> \- \[\] Local tests pass. \*\*Your PR cannot be merged unless tests pass\*\*
> \- \[\] There is no commented out code in this PR.
> \- \[\] I have followed the \[development checklist\]\[dev-checklist\]
> \- \[\] The code has been formatted using Black (\`black --fast homeassistant tests\`)
> \- \[\] Tests have been added to verify that the new code works.
> 
> If user exposed functionality or configuration variables are added/changed:
> 
> \- \[\] Documentation added/updated for \[www.home-assistant.io\]\[docs-repository\]
> 
> If the code communicates with devices, web services, or third-party tools:
> 
> \- \[\] The \[manifest file\]\[manifest-docs\] has all fields filled out correctly.  
> Updated and included derived files by running: \`python3 -m script.hassfest\`.
> \- \[\] New or updated dependencies have been added to \`requirements\_all.txt\`.  
> Updated by running \`python3 -m script.gen\_requirements\_all\`.
> \- \[\] Untested files have been added to \`.coveragerc\`.
> 
> The integration reached or maintains the following \[Integration Quality Scale\]\[quality-scale\]:
> \<!--
> The Integration Quality Scale scores an integration on the code quality
> and user experience. Each level of the quality scale consists of a list
> of requirements. We highly recommend getting your integration scored!
> \--\>
> 
> \- \[\] No score or internal
> \- \[\] 🥈 Silver
> \- \[\] 🥇 Gold
> \- \[\] 🏆 Platinum
> 
> \<!--
> This project is very active and we have a high turnover of pull requests.
> 
> Unfortunately, the number of incoming pull requests is higher than what our
> reviewers can review and merge so there is a long backlog of pull requests
> waiting for review. You can help here!
>   
> By reviewing another pull request, you will help raise the code quality of
> that pull request and the final review will be faster. This way the general
> pace of pull request reviews will go up and your wait time will go down.
>   
> When picking a pull request to review, try to choose one that hasn't yet
> been reviewed.
> 
> Thanks for helping out!
> \--\>
> 
> To help with the load of incoming pull requests:
> 
> \- \[\] I have reviewed two other \[open pull requests\]\[prs\] in this repository.
> 
> \[prs\]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-asc+-review%3Aapproved
> 
> \<!--
> Thank you for contributing \<3
> 
> Below, some useful links you could explore:
> \--\>
> \[dev-checklist\]: https://developers.home-assistant.io/docs/en/development\_checklist.html
> \[manifest-docs\]: https://developers.home-assistant.io/docs/en/creating\_integration\_manifest.html
> \[quality-scale\]: https://developers.home-assistant.io/docs/en/next/integration\_quality\_scale\_index.html
> \[docs-repository\]: https://github.com/home-assistant/home-assistant.io

* * *

An alternative which could be used in conjunction is to embed the OpenEVSE UI inside a HA card e.g

 ![Screenshot 2021-03-25 02.22.40](https://community.openenergymonitor.org/uploads/default/original/3X/7/0/703bcb702e6df8caca8ea037813ec2a04f79492f.png) ![Screenshot 2021-03-25 02.22.08](https://community.openenergymonitor.org/uploads/default/original/3X/7/e/7ee86aae0ee5fd0a67904601339b6f512d3937ae.png)

---

<div class="post-metadata">

**Author:** ![sd\_dracula](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@sd\_dracula](https://community.openenergymonitor.org/u/sd_dracula)\
**Post date:** [7 September 2021 15:43 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/11 "2021-09-07T15:43:59Z")

</div>

Not working for me, keep getting authentication error, how do you add the username/password when creating the integration? FW 4.1.0 and latest HA

---

<div class="post-metadata">

**Author:** ![sd\_dracula](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@sd\_dracula](https://community.openenergymonitor.org/u/sd_dracula)\
**Post date:** [7 September 2021 15:53 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/12 "2021-09-07T15:53:33Z")

</div>

> [@glyn.hudson](#):
>
> User **[TonyApuzzo](https://github.com/TonyApuzzo)** has developed a MQTT based solution which looks very good:
> 
> [![](https://user-images.githubusercontent.com/341037/54160537-6f128f00-4415-11e9-9c8d-a70af3c42078.png) ](https://user-images.githubusercontent.com/341037/54160537-6f128f00-4415-11e9-9c8d-a70af3c42078.png)

Ooh this exactly what I need, where I can find this?

---

<div class="post-metadata">

**Author:** ![Robert.Wall](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/robert.wall/32/38246_2.png) [@Robert.Wall](https://community.openenergymonitor.org/u/Robert.Wall)\
**Post date:** [8 September 2021 15:27 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/14 "2021-09-08T15:27:02Z")

</div>

> [@glyn.hudson](#):
>
> User **[TonyApuzzo](https://github.com/TonyApuzzo)** has developed

Try clicking that link - in blue. (I haven’t checked, but it might go to somewhere helpful.)

---

<div class="post-metadata">

**Author:** ![sd\_dracula](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@sd\_dracula](https://community.openenergymonitor.org/u/sd_dracula)\
**Post date:** [8 September 2021 19:02 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/15 "2021-09-08T19:02:05Z")

</div>

Yup I eventually found the config file hidden in his github, messing with it now 😄

---

<div class="post-metadata">

**Author:** ![sd\_dracula](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@sd\_dracula](https://community.openenergymonitor.org/u/sd_dracula)\
**Post date:** [8 September 2021 19:42 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/16 "2021-09-08T19:42:15Z")

</div>

Looks like that code is ancient in terms of Home Assistant, rest\_cmd no longer exists and I have replaced it with rest\_command like so:

```auto
rest_command:
  openevse_rapi:
    method: post
    authentication: digest
    username: !secret OPENEVSE_USERNAME
    password: !secret OPENEVSE_PASSWORD
    url: "{{ url | default('http://' ~ host ~ '/r?json=1&rapi=' ~ rapi, true) }}"

```

But `authentication: digest` is not recognized so I have removed it.  
Basically just errors:

```auto
2021-09-08 20:38:27 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'value_json' is undefined when rendering '{{- value_json.ret -}}'
2021-09-08 20:38:38 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'host' is undefined when rendering '{{ url | default('http://' ~ host ~ '/r?json=1&rapi=' ~ rapi, true) }}'
2021-09-08 20:38:38 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'rapi' is undefined when rendering '{{ url | default('http://' ~ host ~ '/r?json=1&rapi=' ~ rapi, true) }}'
2021-09-08 20:38:54 WARNING (MainThread) [homeassistant.components.rest.sensor] Empty reply found when expecting JSON data

```

I assume this worked ages ago but not since HA is updated so frequently.

---

<div class="post-metadata">

**Author:** ![mattbruman](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/mattbruman/32/19065_2.png) [@mattbruman](https://community.openenergymonitor.org/u/mattbruman)\
**Post date:** [9 September 2021 16:16 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/17 "2021-09-09T16:16:39Z")

</div>

I’m working on getting this to work too since the native integration is so limited.

> <https://github.com/TonyApuzzo/home-assistant-config/issues/6>
>
> Followed everything but I am getting this error when trying to reboot HA
> rest\_c…md folder is in custom\_components
> 
> Package openevse setup failed. Component rest\_cmd Integration 'rest\_cmd' not found.
> Invalid config for \[input\_select\]: \[values\] is an invalid option for \[input\_select\]. Check: input\_select-\>input\_select-\>openevse\_service\_level-\>values. (See ?, line ?).

Also the integration needs to be updated to the new rules on energy meters so it can easily be added to the Energy Dashboard. And ca we get the ability to turn on and off the schedule so we can charge on demand?

---

<div class="post-metadata">

**Author:** ![sd\_dracula](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@sd\_dracula](https://community.openenergymonitor.org/u/sd_dracula)\
**Post date:** [9 September 2021 16:41 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/18 "2021-09-09T16:41:37Z")

</div>

Yes there are many changes, I am going through them one by one but it’s hit and miss due to the intermittent wifi connection of the evse ☹  
Would be nice if someone else can confirm if it works ok, here is the updated code:

```auto
# ---
# #
# # Control an OpenEVSE Electric Car Charging Station.
# #
# # There are unfortunately quite a few pre-requisites needed to work with
# # OpenEVSE.
# #
# ## REQUIREMENTS ##
# #
# # Version 2.9.1 of OpenEVSE WiFi module, both MQTT and REST APIs are
# # used because each provides different capabilities.
# #
# # You must have MQTT setup in Home Assistant.
# #
# # Required custom components:
# # input_number (allows dynamic adjustment of min/max values)
# # input_select (allows label/value to be separately set)
# # rest_command (supports HTTP basic authentication required by OpenEVSE)
# #
# # Required secrets
# # See '../secrets-example.yaml' for required secrets
# #
# # You must configure the OpenEVSE wifi control panel Services Tab:
# # - Enable MQTT: Checked
# # - Host: Your hassio IP address where the MQTT broker is running
# # - Port: MQTT broker port (1883)
# # - Username: MQTT username for OpenEVSE (e.g. "openevse")
# # - Password: MQTT password for OpenEVSE
# # - Base-topic: openevse (or edit secrets)
# # - Voltage-topic: Unused
# #
# # Optional Solar PV divert (this is poorly tested as I don't have a PV setup)
# # - Enable Solar PV divert: checked
# # - Feed: openevse_solar
# #
# # For RAPI Details, see:
# # https://github.com/OpenEVSE/open_evse/blob/stable/firmware/open_evse/rapi_proc.h
# #

# # RAPI Service
# # When calling this, set service data for either the full URL in `url`
# # or set both `host` and `rapi` variables. `url` has precedence
# # This requires a rest_cmd that supports http basic auth
rest_command:
  openevse_rapi:
    method: post
    username: !secret OPENEVSE_USERNAME
    password: !secret OPENEVSE_PASSWORD
    url: "{{ url | default('http://' ~ host ~ '/r?json=1&rapi=' ~ rapi, true) }}"

# # Sensors
sensor:

  #Get OpenEVSE min/max current via REST
  - platform: rest
    name: "OpenEVSE RAPI $GC"
    resource: !secret OPENEVSE_REST_GET_CURRENT_CAPACITY_RANGE
    force_update: no
    authentication: basic
    username: !secret OPENEVSE_USERNAME
    password: !secret OPENEVSE_PASSWORD
    headers:
        User-Agent: Home Assistant
        Content-Type: application/json
    json_attributes: ['cmd', 'ret']
    value_template: >-
      {{ value_json.ret }}      

  # Get OpenEVSE Current Settings via REST
  - platform: rest
    name: "OpenEVSE RAPI $GE"
    resource: !secret OPENEVSE_R_GE
    force_update: no
    authentication: basic
    username: !secret OPENEVSE_USERNAME
    password: !secret OPENEVSE_PASSWORD
    headers:
        User-Agent: Home Assistant
        Content-Type: application/json
    json_attributes: ['cmd', 'ret']
    value_template: >-
      {{ value_json.ret }}
      
  - platform: rest
    name: "OpenEVSE RAPI $GG"
    resource: !secret OPENEVSE_REST_GET_CHARGING_CURRENT_AND_VOLTAGE
    force_update: yes
    authentication: basic
    username: !secret OPENEVSE_USERNAME
    password: !secret OPENEVSE_PASSWORD
    headers:
        User-Agent: Home Assistant
        Content-Type: application/json
    json_attributes: ['cmd', 'ret']
    value_template: >-
      {{ value_json.ret }}

  - platform: rest
    name: "OpenEVSE Status"
    resource: !secret OPENEVSE_R_STATUS
    force_update: no
    authentication: basic
    username: !secret OPENEVSE_USERNAME
    password: !secret OPENEVSE_PASSWORD
    headers:
        User-Agent: Home Assistant
        Content-Type: application/json
    json_attributes:
      - "mode"
      - "wifi_client_connected"
      - "srssi"
      - "ipaddress"
      - "emoncms_connected"
      - "packets_sent"
      - "packets_success"
      - "mqtt_connected"
      - "ohm_hour"
      - "free_heap"
      - "comm_sent"
      - "comm_success"
      - "amp"
      - "pilot"
      - "temp1"
      - "temp2"
      - "temp3"
      - "state"
      - "elapsed"
      - "wattsec"
      - "watthour"
      - "gfcicount"
      - "nogndcount"
      - "stuckcount"
      - "divertmode"
      - "solar"
      - "grid_ie"
      - "charge_rate"
      - "divert_update"
    value_template: >-
      {{- value_json.state -}}

  # The RAPI REST Sensor is very unreliable, so filter it
  - platform: filter
    name: "OpenEVSE Session Energy"
    entity_id: sensor.openevse_session_energy_raw
    filters:
      - filter: outlier
        window_size: 6
        radius: 0.5

  # Template Sensors
  - platform: template
    sensors:
      openevse_session_energy_raw:
        friendly_name: "OpenEVSE Session Energy (unfiltered)"
        icon_template: mdi:gauge
        device_class: energy
        unit_of_measurement: 'kWh'
        value_template: >-
          {% set wattsec = state_attr('sensor.openevse_status', 'wattsec') | float(-1) %}
          {% if wattsec >= 0 %}
            {{ (wattsec / 3600000)|round(2) }}
          {% else %}
            unknown
          {% endif %}

      # Charging current from REST API
      openevse_current_now_rest:
        unique_id: openevse_current_now_rest
        friendly_name: "OpenEVSE Current Now (REST)"
        icon_template: mdi:current-ac
        device_class: current
        unit_of_measurement: 'A'
        value_template: >-
          {{- states('sensor.openevse_rapi_gg') |
              regex_replace('^\$OK ([0-9]+) (-?[0-9]+).*', '\\1') | float(0) / 1000 -}}

      # Combine both MQTT and REST sensors since neither ends up being super reliable
      openevse_current_now:
        unique_id: openevse_current_now
        friendly_name: "OpenEVSE Current Now"
        icon_template: mdi:current-ac
        device_class: current
        unit_of_measurement: 'A'
        value_template: >-
          {{-
            ([
              state_attr('sensor.openevse_status','charge_rate') | float(0),
              states('sensor.openevse_current_now_mqtt') | float(0)
            ] | max)
          -}}

      # Combine both MQTT and REST sensors since neither ends up being super reliable
      openevse_pilot:
        unique_id: openevse_pilot
        friendly_name: "OpenEVSE Pilot"
        icon_template: mdi:current-ac
        device_class: current
        unit_of_measurement: 'A'
        value_template: >-
          {{-
            ([
              state_attr('sensor.openevse_status','pilot') | float(0),
              states('sensor.openevse_pilot_mqtt') | float(0)
            ] | max)
          -}}

      openevse_pilot_rest:
        friendly_name: "OpenEVSE Pilot (REST)"
        icon_template: mdi:current-ac
        device_class: current
        unit_of_measurement: 'A'
        value_template: "{{ state_attr('sensor.openevse_status', 'pilot') | float(-1) }}" 

      openevse_state:
        friendly_name: "OpenEVSE State"
        icon_template: >-
          {%- if state_attr('sensor.openevse_status', 'state') | regex_match('^[01]$') -%}
            mdi:power-plug-off
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^2$') -%}
            mdi:car-electric
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^3$') -%}
            mdi:battery-charging
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^([456789]|10)$') -%}
            mdi:battery-alert
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^254$') -%}
            mdi:sleep
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^255$') -%}
            mdi:power-off
          {%- else -%}
            mdi:battery-unknown
          {%- endif -%}
        value_template: >-
          {%- if state_attr('sensor.openevse_status', 'state') | regex_match('^[01]$') -%}
            Not Connected
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^2$') -%}
            Connected
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^3$') -%}
            Charging
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^([456789]|10)$') -%}
            Error ({{- state_attr('sensor.openevse_status', 'state') -}})
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^254$') -%}
            Sleeping
          {%- elif state_attr('sensor.openevse_status', 'state') | regex_match('^255$') -%}
            Disabled
          {%- else -%}
            Unknown ({{- state_attr('sensor.openevse_status', 'state') -}})
          {%- endif -%}
    

  - platform: mqtt
    name: "OpenEVSE Temp 2"
    state_topic: !secret OPENEVSE_T_TEMP2
    unit_of_measurement: '°F'
    device_class: temperature
    value_template: >-
      {%- macro C2F(temperature) -%}
        {% set tmp = (((temperature *9) /50.0) + 32) %}
        {{- "%0.2f" % tmp -}}
      {%- endmacro -%}
      {{- C2F(value|float)|float -}}

  - platform: mqtt
    name: "OpenEVSE Current Now (MQTT)"
    icon: mdi:current-ac
    state_topic: !secret OPENEVSE_T_AMP
    device_class: current
    unit_of_measurement: "A"
    value_template: >-
      {{- (value|float / 1000.0) | round(1) -}}

  - platform: mqtt
    name: "OpenEVSE Pilot (MQTT)"
    icon: mdi:current-ac
    state_topic: !secret OPENEVSE_T_PILOT
    device_class: current
    unit_of_measurement: "A"
    value_template: >-
      {{- value|int -}}

  - platform: mqtt
    name: "OpenEVSE Total Energy"
    unique_id: openevse_total_energy_01
    icon: mdi:gauge-full
    state_topic: !secret OPENEVSE_T_WH
    state_class: total_increasing
    device_class: energy
    unit_of_measurement: kWh
    value_template: >-
      {{- value|float / 1000 | round(2) -}}

# Switches
switch:
  - platform: template
    switches:
      openevse_enable:
        friendly_name: "OpenEVSE Enable"
        turn_off:
          - service: rest_command.openevse_rapi
            data:
              url: !secret OPENEVSE_REST_DISABLE
        turn_on:
          - service: rest_command.openevse_rapi
            data:
              url: !secret OPENEVSE_REST_ENABLE
        icon_template: >-
          {%- if state_attr('sensor.openevse_status', 'state') | regex_match('^[0123]$') -%}
            mdi:power-on
          {%- else -%}
            mdi:power-off
          {%- endif -%}
        value_template: >-
          {{- state_attr('sensor.openevse_status', 'state') | regex_match('^[0123]$') -}}

      openevse_divertmode:
        friendly_name: "OpenEVSE Eco Divert"
        turn_off:
          - service: mqtt.publish
            data:
              topic: !secret OPENEVSE_T_DIVERT
              retain: true
              payload: 1
        turn_on:
          - service: mqtt.publish
            data:
              topic: !secret OPENEVSE_T_DIVERT
              retain: true
              payload: 2
        icon_template: >-
          {%- if state_attr('sensor.openevse_status', 'divertmode') | regex_match('^2$') -%}
            mdi:solar-power
          {%- else -%}
            mdi:power-off
          {%- endif -%}
        value_template: >-
          {{- state_attr('sensor.openevse_status', 'divertmode') | regex_match('^2$') -}}
      
input_boolean:
  # When true causes pilot current changes to be persisted into the OpenEVSE
  # firmware (otherwise saving pilot current is temporary) when this is OFF
  # then the volatile parameter is sent when changing the current
  openevse_save_current:
    name: "OpenEVSE Persist Current"
    initial: on
    icon: mdi:sync

input_number:
  openevse_pilot:
    name: "OpenEVSE Current"
    unit_of_measurement: "A"
    min: 10
    max: 32
    initial: 16
    step: 1

# Requires use of custom input_select component

input_select:  
  openevse_service_level:
    name: OpenEVSE Service Level
    options:
      - "A"
      - "1"
      - "2"
    icon: mdi:target

script:
  set_openevse_max_current:
    icon: mdi:content-save
    alias: OpenEVSE Set Pilot
    sequence:
      - service: rest_command.openevse_rapi
        data:
          host: !secret OPENEVSE_HOST
          rapi: "{{ '$SC ' ~ (states('input_number.openevse_pilot')|int) ~ (' V' if not is_state('input_boolean.openevse_save_current', 'on')) }}"

automation openevse:
  - alias: Update OpenEVSE Min/Max Current
    id: update_openevse_min_max_current
    trigger:
      platform: state
      entity_id: sensor.openevse_rapi_gc
    condition:
      condition: template
      value_template: >-
        {{ state_attr('sensor.openevse_rapi_gc', 'ret') | regex_match('^\$OK [0-9]+ +[0-9]+') }}
    action:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.openevse_pilot
          # Restrict the min to 6A - 10A
          min: >-
            {%- set ret = state_attr('sensor.openevse_rapi_gc', 'ret') -%}
            {%- set rgx = '(?<=^\$OK) +([0-9]+) +([0-9]+)' -%}
            {%- set v = ret | regex_findall_index(rgx) -%}
            {{- [10, [6, v[0]|int]|max] | min -}}
          # Restrict the max to 32A even if L2 returns >32A
          max: >-
            {%- set ret = state_attr('sensor.openevse_rapi_gc', 'ret') -%}
            {%- set rgx = '(?<=^\$OK )([0-9]+) +([0-9]+)' -%}
            {%- set v = ret | regex_findall_index(rgx) -%}
            {{- [32, v[1]|int]|min -}}

  - id: update_input_number_openevse_pilot
    alias: Update input_number OpenEVSE Current
    description: >-
      Reflect changes made to pilot current on OpenEVSE back to the input_number
      slider position.
    trigger:
      platform: state
      entity_id: sensor.openevse_pilot
    condition:
      condition: template
      value_template: >-
        {{
           (states('sensor.openevse_pilot')|int >= state_attr('input_number.openevse_pilot', 'min')|int)
           and
           (states('sensor.openevse_pilot')|int <= state_attr('input_number.openevse_pilot', 'max')|int)
        }}
    action:
      - service: input_number.set_value
        data:
          entity_id: input_number.openevse_pilot
          value: "{{ states('sensor.openevse_pilot')|int }}"
    
  - alias: Update OpenEVSE Service Level
    id: update_openevse_service_level
    description: >-
      Reflect changes made to service level on the OpenEVSE back to Home Assistant.
    trigger:
      platform: mqtt
      topic: !secret OPENEVSE_T_ISL
    action:
      service: input_select.select_option
      data_template:
        entity_id: input_select.openevse_service_level
        option: >-
          {%- for option in state_attr("input_select.openevse_service_level", "options") -%}
            {%- if trigger.payload == option -%}
              {{- state_attr("input_select.openevse_service_level", 'options')[loop.index - 1] -}}
            {%- endif -%}
          {%- endfor -%}

  - alias: Set OpenEVSE Service Level
    id: set_openevse_service_level
    trigger:
      platform: state
      entity_id: input_select.openevse_service_level
    action:
      service: rest_command.openevse_rapi
      data_template:
        host: !secret OPENEVSE_HOST
        rapi: >-
          {%- for option in state_attr("input_select.openevse_service_level", "options") -%}
            {%- if is_state("input_select.openevse_service_level", option) -%}
              {{- '$SL+' ~ state_attr("input_select.openevse_service_level", 'options')[loop.index - 1] -}}
            {%- endif -%}
          {%- endfor -%}

```

---

<div class="post-metadata">

**Author:** ![jeremypoulter](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/jeremypoulter/32/1006_2.png) [@jeremypoulter](https://community.openenergymonitor.org/u/jeremypoulter)\
**Post date:** [9 September 2021 17:01 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/19 "2021-09-09T17:01:29Z")

</div>

FYI I would strongly advise against using RAPI as it is deprecated in the v4 firmware.

If you are missing anything thing from the WiFi API raise a ticket [in the repo](https://github.com/OpenEVSE/ESP32_WiFi_V4.x) and it can probably be added.

You also should make use of the WebSocket as you will get much faster feedback and don’t have to poll the WiFi module all the time.

Also, also you can auto discover OpenEVSE units via mDNS or MQTT. Although this may need more of a ‘proper’ integration, I haven’t looked in to the details of Home Assistant yet.

---

<div class="post-metadata">

**Author:** ![sd\_dracula](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/s/2bfe46/32.png) [@sd\_dracula](https://community.openenergymonitor.org/u/sd_dracula)\
**Post date:** [9 September 2021 17:12 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/20 "2021-09-09T17:12:40Z")

</div>

Basically looking for these

 ![image](https://community.openenergymonitor.org/uploads/default/original/3X/a/3/a3b21ff0557e4befa65a1e511271487a2016f086.png)  
So if anyone knows how to convert from RAPI to HTTP feel free to share 🙂

---

<div class="post-metadata">

**Author:** ![jeremypoulter](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/jeremypoulter/32/1006_2.png) [@jeremypoulter](https://community.openenergymonitor.org/u/jeremypoulter)\
**Post date:** [9 September 2021 20:45 UTC](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059/21 "2021-09-09T20:45:06Z")

</div>

I have started doing some documentation of the [v4 API](https://openevse.stoplight.io/docs/openevse-wifi-v4/YXBpOjk5MTEz-open-evse-wi-fi-api) which might help you, there are also some [examples of the API calls](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/tree/master/test), but in short:

- status can be retrieved from the `/status` endpoint as you are doing, and as I mentioned could be updated via `/ws` websocket
- `OpenEVSE Enable` should be implemented using the [`/override`](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/blob/master/test/basic.http#L142:L170) endpoint
- `OpenEVSE Eco divert` should use set the [`charge_mode`](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/blob/master/test/config.http#L66:L80) config
- `OpenEVSE Current` should use the [`/claims`](https://github.com/OpenEVSE/ESP32_WiFi_V4.x/blob/jeremypoulter/issue9/test/claims.http) endpoint, although there is a bug in the current release that I have fixed on the `jeremypoulter/issue9` branch

[Next page](https://community.openenergymonitor.org/t/openevse-home-assistant-integration/7059.md?page=2)
