mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add entity translations to Juicenet (#95487)
This commit is contained in:
parent
ad091479ea
commit
77ebf8a8e5
@ -14,6 +14,8 @@ from .const import DOMAIN
|
|||||||
class JuiceNetDevice(CoordinatorEntity):
|
class JuiceNetDevice(CoordinatorEntity):
|
||||||
"""Represent a base JuiceNet device."""
|
"""Represent a base JuiceNet device."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, device: Charger, key: str, coordinator: DataUpdateCoordinator
|
self, device: Charger, key: str, coordinator: DataUpdateCoordinator
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -37,7 +37,7 @@ class JuiceNetNumberEntityDescription(
|
|||||||
|
|
||||||
NUMBER_TYPES: tuple[JuiceNetNumberEntityDescription, ...] = (
|
NUMBER_TYPES: tuple[JuiceNetNumberEntityDescription, ...] = (
|
||||||
JuiceNetNumberEntityDescription(
|
JuiceNetNumberEntityDescription(
|
||||||
name="Amperage Limit",
|
translation_key="amperage_limit",
|
||||||
key="current_charging_amperage_limit",
|
key="current_charging_amperage_limit",
|
||||||
native_min_value=6,
|
native_min_value=6,
|
||||||
native_max_value_key="max_charging_amperage",
|
native_max_value_key="max_charging_amperage",
|
||||||
@ -80,8 +80,6 @@ class JuiceNetNumber(JuiceNetDevice, NumberEntity):
|
|||||||
super().__init__(device, description.key, coordinator)
|
super().__init__(device, description.key, coordinator)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
|
|
||||||
self._attr_name = f"{self.device.name} {description.name}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> float | None:
|
def native_value(self) -> float | None:
|
||||||
"""Return the value of the entity."""
|
"""Return the value of the entity."""
|
||||||
|
@ -29,40 +29,36 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
name="Temperature",
|
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="voltage",
|
key="voltage",
|
||||||
name="Voltage",
|
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="amps",
|
key="amps",
|
||||||
name="Amps",
|
|
||||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="watts",
|
key="watts",
|
||||||
name="Watts",
|
|
||||||
native_unit_of_measurement=UnitOfPower.WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="charge_time",
|
key="charge_time",
|
||||||
name="Charge time",
|
translation_key="charge_time",
|
||||||
native_unit_of_measurement=UnitOfTime.SECONDS,
|
native_unit_of_measurement=UnitOfTime.SECONDS,
|
||||||
icon="mdi:timer-outline",
|
icon="mdi:timer-outline",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="energy_added",
|
key="energy_added",
|
||||||
name="Energy added",
|
translation_key="energy_added",
|
||||||
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
|
||||||
device_class=SensorDeviceClass.ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
@ -97,7 +93,6 @@ class JuiceNetSensorDevice(JuiceNetDevice, SensorEntity):
|
|||||||
"""Initialise the sensor."""
|
"""Initialise the sensor."""
|
||||||
super().__init__(device, description.key, coordinator)
|
super().__init__(device, description.key, coordinator)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_name = f"{self.device.name} {description.name}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
@ -17,5 +17,25 @@
|
|||||||
"title": "Connect to JuiceNet"
|
"title": "Connect to JuiceNet"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"number": {
|
||||||
|
"amperage_limit": {
|
||||||
|
"name": "Amperage limit"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"charge_time": {
|
||||||
|
"name": "Charge time"
|
||||||
|
},
|
||||||
|
"energy_added": {
|
||||||
|
"name": "Energy added"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"switch": {
|
||||||
|
"charge_now": {
|
||||||
|
"name": "Charge now"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,12 @@ async def async_setup_entry(
|
|||||||
class JuiceNetChargeNowSwitch(JuiceNetDevice, SwitchEntity):
|
class JuiceNetChargeNowSwitch(JuiceNetDevice, SwitchEntity):
|
||||||
"""Implementation of a JuiceNet switch."""
|
"""Implementation of a JuiceNet switch."""
|
||||||
|
|
||||||
|
_attr_translation_key = "charge_now"
|
||||||
|
|
||||||
def __init__(self, device, coordinator):
|
def __init__(self, device, coordinator):
|
||||||
"""Initialise the switch."""
|
"""Initialise the switch."""
|
||||||
super().__init__(device, "charge_now", coordinator)
|
super().__init__(device, "charge_now", coordinator)
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return f"{self.device.name} Charge Now"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if switch is on."""
|
"""Return true if switch is on."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user