# Home Assistant

> Shows how to connect evcc and Home Assistant, ideally with the ha-evcc integration or manually via REST API and MQTT, to visualise data and automate charging.

[Home Assistant](https://www.home-assistant.io) collects and visualises data from your smart home and offers extensive automation capabilities. evcc specialises in smart charging and heating. Both systems complement each other and can be connected in different ways.

> **Note**
>
> evcc can also be installed as a Home Assistant App. You can find the instructions [here](/en/installation/home-assistant).

## Visualise & Automate

evcc comes with many controls for smart charging and heating but can’t cover every use case. Integrating with Home Assistant gives you more flexibility. Here are some examples:

* Visualise measurements in dashboards
* Create charging plans based on calendar events
* Switch charging modes based on presence
* …

### Home Assistant evcc Integration (Recommended)

The [ha-evcc](https://github.com/marq24/ha-evcc) integration by [marq24](https://github.com/marq24) brings evcc data and functions directly into Home Assistant. This works regardless of whether you run evcc as a Home Assistant app or not. The only requirement is that Home Assistant and evcc are reachable on the same network.

The integration provides all relevant evcc entities: measurements, settings, charging points, and vehicles. After installation, you get a comprehensive list of entities that you can use in dashboards and automations.

**Installation via HACS:**

1. Open [HACS](https://hacs.xyz/) in Home Assistant and search for “evcc”.
2. Install the entry **evcc☀️🚘- Solar Charging** by marq24.
3. Restart Home Assistant.
4. Go to **Settings → Devices & Services → Add Integration**, search for “evcc”, and enter the URL of your evcc instance.

For additional installation options and details, see the [GitHub repository](https://github.com/marq24/ha-evcc).

For dashboards, the [hass-evcc-card](https://github.com/mkshb/hass-evcc-card) provides a Lovelace card that shows the evcc overview in Home Assistant.

### Manual Integration

Alternatively, you can manually integrate evcc data into Home Assistant via the REST API or MQTT.

#### REST API

evcc offers a [REST API](/integrations/rest-api). [This guide](https://github.com/marq24/ha-evcc/blob/main/HA_AS_EVCC_SOURCE.md) by [marq24](https://github.com/marq24) describes the integration with Home Assistant in detail.

#### MQTT

You need an MQTT broker (e.g. [Mosquitto](https://mosquitto.org/), also available as a Home Assistant app).

Configure the broker connection in evcc under **Configuration → MQTT**. The same broker and topic must be configured in Home Assistant so that both systems can exchange data.

You can use a tool like [MQTT Explorer](http://mqtt-explorer.com) to verify that topics are arriving correctly. A guide on setting up MQTT sensors in Home Assistant is available in the [blog by Alkly (German)](https://alkly.de/mqtt-mit-home-assistant-fuer-anfaenger).

The available topics are documented in the [MQTT API](/en/integrations/mqtt-api).

## Using Home Assistant Entities

evcc can connect directly to Home Assistant and use its entities (sensors, switches, numbers) as data sources. This allows you to integrate devices into evcc that are not natively supported, e.g. Zigbee smart plugs, sensors from other integrations, or DIY solutions. As long as the data is available as a Home Assistant entity, evcc can work with it.

### Supported Device Types

* **[Meters](/en/meters#home-assistant)** (grid, solar, battery, …) with power, energy, currents, voltages, SoC
* **[Chargers](/en/chargers#home-assistant-charger)** with status, enable/disable, and maximum charging current
* **[Smart switches](/en/smartswitches#home-assistant-switch)** with simple on/off control (for smart plugs, relays)
* **[Vehicles](/en/vehicles#home-assistant)** with SoC, range, status, odometer; optionally scripts for start/stop
* **[Notifications](/en/notifications)** under **Configuration → Notifications** you can send evcc messages via Home Assistant

### Setup

Home Assistant devices are added like any other device in the configuration UI.

1. Go to **Configuration** and add a device, e.g. **Add additional meter**.
2. Select “Home Assistant” as the manufacturer.
3. Pick your instance. Instances in the local network are discovered automatically. If the list stays empty, e.g. because Home Assistant runs in a different subnet, enter the address manually (`http://homeassistant.local:8123`).
4. Authorise the access. Home Assistant opens in a new tab where you log in and confirm the request. The token is stored by your evcc instance and renewed automatically.
5. Assign an entity to each field, e.g. “Power”. You get autocomplete with the entities of your instance, and only entities that fit the field are offered.
6. **Validate & save** checks whether the entities can be read.

> **Note**
>
> If you’re running evcc inside Home Assistant as an [App](/en/installation/home-assistant), pick the `http://supervisor/core` instance in step 3. It’s authorised already, so step 4 is skipped.

[]()

### Entity Values

Each field expects a certain kind of value. An entity reporting `unknown` or `unavailable` counts as temporarily not available and is read again on the next update.

#### Numbers

Power, energy, current and SoC fields need a plain number as state, e.g. `1234`. A state such as `1234 W` can’t be read, the unit belongs into the entity’s `unit_of_measurement` attribute. `W`/`kW` and `Wh`/`kWh`/`MWh` are converted automatically. To invert the sign, prepend `-` to the entity name (`-sensor.inverter_power`).

#### On/Off

The enabled state of a charger, a smart switch and similar fields accept `on`, `true`, `1`, `active` and `yes`, as well as their counterparts `off`, `false`, `0`, `inactive` and `no`.

[]()

#### Charge Status

Chargers and vehicles need a status entity that reports whether the vehicle is disconnected, connected or charging. These states are understood out of the box:

| Status | Meaning      | States                                                                                         |
| ------ | ------------ | ---------------------------------------------------------------------------------------------- |
| **A**  | disconnected | `a`, `disconnected`, `not_plugged`                                                             |
| **B**  | connected    | `b`, `connected`, `plugged`, `starting`, `stopped`, `paused`, `complete`, `charging_completed` |
| **C**  | charging     | `c`, `charging`                                                                                |

Many integrations use their own wording. If the entity reports a state that isn’t in the table, the log shows the raw value together with the entity name. Add that value to the matching **States for status A/B/C** field in the advanced options of the device. Multiple values are separated by commas, upper and lower case don’t matter.

```yaml
statusB: charging_stopped, charging_error
statusC: instant_charging
```

A `binary_sensor` as status entity also needs an explicit mapping, e.g. `statusA: off` and `statusC: on`.

## Further Resources (Videos)

Videos are in German.

* [smart home & more: evcc Basic Installation and Configuration](https://youtu.be/aPq8k2MronY)
* [smart home & more: Step by Step - Setting up MQTT Sensor using MQTT Explorer](https://youtu.be/0QQ3y8fgRVA)
* [smart home & more: Efficient Energy Dashboard for Home Assistant](https://youtu.be/V3p5-16U_oU)