diff --git a/README.md b/README.md index ec53054..689c74d 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,8 @@ See [here](https://github.com/widewing/ha-toyota-na) for North America. |
Name
| Description | | ------------------------------------ | ------------------------------------------------------------------------ | | `sensor.corolla` | Static data about your car. | -| `sensor.corolla_hvac` | EV battery information | +| `sensor.corolla_ev_battery_status` | EV battery information | +| `sensor.corolla_ev_remaining_charge` | EV battery remaining charge (in per cent of full capacity) | | `sensor.corolla_fuel_tank` | Fuel tank information. | | `sensor.corolla_hvac` | HVAC sensor showing current and target temperature, including other data | | `sensor.corolla_odometer` | Odometer information. | diff --git a/custom_components/toyota/const.py b/custom_components/toyota/const.py index bf72d12..2fd4b9c 100644 --- a/custom_components/toyota/const.py +++ b/custom_components/toyota/const.py @@ -60,6 +60,7 @@ # ICONS ICON_BATTERY = "mdi:car-battery" +ICON_EV_BATTERY = "mdi:battery" ICON_CAR = "mdi:car-info" ICON_CAR_DOOR = "mdi:car-door" ICON_CAR_DOOR_LOCK = "mdi:car-door-lock" diff --git a/custom_components/toyota/sensor.py b/custom_components/toyota/sensor.py index 6329647..0421600 100644 --- a/custom_components/toyota/sensor.py +++ b/custom_components/toyota/sensor.py @@ -20,6 +20,7 @@ ICON_BATTERY, ICON_CAR, ICON_EV, + ICON_EV_BATTERY, ICON_FUEL, ICON_ODOMETER, ICON_RANGE, @@ -62,6 +63,9 @@ async def async_setup_entry(hass, config_entry, async_add_devices): if vehicle.energy.chargeinfo: sensors.append(ToyotaEVSensor(coordinator, index, "EV battery status")) + sensors.append( + ToyotaEVBatterySensor(coordinator, index, "EV remaining charge") + ) sensors.extend( [ @@ -208,9 +212,6 @@ def extra_state_attributes(self): "Remaining_time": self.coordinator.data[self.index].energy.chargeinfo.get( "remaining_time", None ), - "Remaining_amount": self.coordinator.data[self.index].energy.chargeinfo.get( - "remaining_amount", None - ), } return attribute @@ -222,6 +223,22 @@ def state(self): return self.coordinator.data[self.index].energy.chargeinfo.get("status", None) +class ToyotaEVBatterySensor(ToyotaBaseEntity): + """Class for EV battery sensor.""" + + _attr_icon = ICON_EV_BATTERY + _attr_device_class = SensorDeviceClass.BATTERY + _attr_unit_of_measurement = PERCENTAGE + + @property + def state(self) -> StateType: + """Return remaining charge of the EV battery.""" + level = self.coordinator.data[self.index].energy.chargeinfo.get( + "remaining_amount", None + ) + return round(level, 0) if level else None + + class ToyotaHVACSensor(ToyotaBaseEntity): """Class for hvac temperature sensor"""