Skip to content

Commit

Permalink
fix: Change time_period_str to parse_duration
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgoette committed Oct 19, 2022
1 parent c3d644d commit b2f2ebb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/babybuddy/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dataclasses import dataclass, field
from typing import Final

import homeassistant.util.dt as dt_util
from homeassistant.components.select import SelectEntityDescription
from homeassistant.components.sensor import (
SensorDeviceClass,
Expand All @@ -13,7 +14,6 @@
)
from homeassistant.components.switch import SwitchEntityDescription
from homeassistant.const import ATTR_TIME, TIME_MINUTES
from homeassistant.helpers.config_validation import time_period_str

DOMAIN: Final = "babybuddy"

Expand Down Expand Up @@ -138,7 +138,7 @@ class BabyBuddyEntityDescription(SensorEntityDescription, SwitchEntityDescriptio
native_unit_of_measurement=TIME_MINUTES,
state_class=SensorStateClass.MEASUREMENT,
state_key=lambda value: int(
time_period_str(value[ATTR_DURATION]).total_seconds() / 60
dt_util.parse_duration(value[ATTR_DURATION]).total_seconds() / 60
),
),
BabyBuddyEntityDescription(
Expand All @@ -160,7 +160,7 @@ class BabyBuddyEntityDescription(SensorEntityDescription, SwitchEntityDescriptio
native_unit_of_measurement=TIME_MINUTES,
state_class=SensorStateClass.MEASUREMENT,
state_key=lambda value: int(
time_period_str(value[ATTR_DURATION]).total_seconds() / 60
dt_util.parse_duration(value[ATTR_DURATION]).total_seconds() / 60
),
),
BabyBuddyEntityDescription(
Expand Down

0 comments on commit b2f2ebb

Please sign in to comment.