Add more PrusaLink sensors (#80424)

* Add more PrusaLink sensors

* Disable prusalink target temperatures by default, add prusa to brands

* Disable prusalink z-height by default

* Remove uneccessary Prusa from brands

* Move target temperatures to the telemetry section of the sensor

* Fix entity naming for prusalink

* Add tests for new prusalink sensors

* Test fixes, fix rebase errors

* Clean up deprecated unit usage

* Add translations for entity names

* Fix tests for translations

---------

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Lucas 2023-04-22 15:04:10 +02:00 committed by GitHub
parent b76551cf35
commit 48a2fe9e7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 3 deletions

View file

@ -15,7 +15,7 @@ from homeassistant.components.sensor import (
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import PERCENTAGE, UnitOfTemperature
from homeassistant.const import PERCENTAGE, UnitOfLength, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
@ -81,6 +81,45 @@ SENSORS: dict[str, tuple[PrusaLinkSensorEntityDescription, ...]] = {
value_fn=lambda data: cast(float, data["telemetry"]["temp-nozzle"]),
entity_registry_enabled_default=False,
),
PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.temp-bed.target",
translation_key="heatbed_target_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: cast(float, data["temperature"]["bed"]["target"]),
entity_registry_enabled_default=False,
),
PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.temp-nozzle.target",
translation_key="nozzle_target_temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: cast(float, data["temperature"]["tool0"]["target"]),
entity_registry_enabled_default=False,
),
PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.z-height",
translation_key="z_height",
native_unit_of_measurement=UnitOfLength.MILLIMETERS,
device_class=SensorDeviceClass.DISTANCE,
state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda data: cast(float, data["telemetry"]["z-height"]),
entity_registry_enabled_default=False,
),
PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.print-speed",
translation_key="print_speed",
native_unit_of_measurement=PERCENTAGE,
value_fn=lambda data: cast(float, data["telemetry"]["print-speed"]),
),
PrusaLinkSensorEntityDescription[PrinterInfo](
key="printer.telemetry.material",
translation_key="material",
icon="mdi:palette-swatch-variant",
value_fn=lambda data: cast(str, data["telemetry"]["material"]),
),
),
"job": (
PrusaLinkSensorEntityDescription[JobInfo](