Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
biofects authored Sep 3, 2024
1 parent 1340a25 commit a7d5124
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions custom_components/simple_sticky_note/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.components.input_text import DOMAIN as INPUT_TEXT_DOMAIN

from .const import DOMAIN, CONF_NOTE_TEXT

async def async_setup_entry(
Expand All @@ -27,7 +26,6 @@ async def async_setup_entry(

class SimpleStickNoteSensor(SensorEntity):
"""Representation of a Simple Sticky Note sensor."""

def __init__(self, hass, input_text_entity_id):
"""Initialize the sensor."""
self.hass = hass
Expand All @@ -38,10 +36,10 @@ def __init__(self, hass, input_text_entity_id):
@property
def state(self):
"""Return the state of the sensor."""
return self.hass.states.get(self._input_text_entity_id).state
entity_state = self.hass.states.get(self._input_text_entity_id)
return entity_state.state if entity_state else None

async def async_update(self) -> None:
"""Fetch new state data for the sensor."""
# The state is updated automatically when the input_text entity changes
pass

0 comments on commit a7d5124

Please sign in to comment.