Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use none as sensor state when no alarm or timer is set #839

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions custom_components/google_home/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity import Entity, EntityCategory
Expand Down Expand Up @@ -202,7 +201,7 @@ def state(self) -> str | None:
if next_alarm
and next_alarm.status
not in (GoogleHomeAlarmStatus.INACTIVE, GoogleHomeAlarmStatus.MISSED)
else STATE_UNAVAILABLE
else None
)

@property
Expand Down Expand Up @@ -282,11 +281,7 @@ def state(self) -> str | None:
if not device:
return None
timer = device.get_next_timer()
return (
timer.local_time_iso
if timer and timer.local_time_iso
else STATE_UNAVAILABLE
)
return timer.local_time_iso if timer and timer.local_time_iso else None

@property
def extra_state_attributes(self) -> TimersAttributes:
Expand Down