Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wimb0 authored Feb 11, 2025
1 parent 9b333f7 commit c7ea92f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions custom_components/saj_modbus/sensor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
"""Sensor Platform Device for SAJ R5 Inverter Modbus."""

from __future__ import annotations
from datetime import datetime
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.components.sensor import SensorEntity
import logging
from typing import Optional

from homeassistant.const import CONF_NAME
from homeassistant.core import callback
import homeassistant.util.dt as dt_util

from .const import (
ATTR_MANUFACTURER,
Expand All @@ -25,6 +21,7 @@


async def async_setup_entry(hass, entry, async_add_entities):
"""Set up entry for hub."""
hub_name = entry.data[CONF_NAME]
hub = hass.data[DOMAIN][hub_name]["hub"]

Expand Down Expand Up @@ -79,12 +76,13 @@ def name(self):
return f"{self._platform_name} {self.entity_description.name}"

@property
def unique_id(self) -> Optional[str]:
def unique_id(self) -> str | None:
"""Return unique ID fro sensor."""
return f"{self._platform_name}_{self.entity_description.key}"

@property
def native_value(self):
"""Return the state of the sensor."""
"""Return the native value of the sensor."""
return (
self.coordinator.data[self.entity_description.key]
if self.entity_description.key in self.coordinator.data
Expand Down

0 comments on commit c7ea92f

Please sign in to comment.