Skip to content

Commit

Permalink
feat: Allow diaper change without type
Browse files Browse the repository at this point in the history
  • Loading branch information
jcgoette committed Jun 5, 2022
1 parent 5d18d1d commit 740e929
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 5 additions & 4 deletions custom_components/babybuddy/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def update_entities() -> None:
"add_diaper_change",
{
vol.Optional(ATTR_TIME): vol.Any(cv.datetime, cv.time),
vol.Required(ATTR_TYPE, default=DEFAULT_DIAPER_TYPE): vol.In(DIAPER_TYPES),
vol.Optional(ATTR_TYPE): vol.In(DIAPER_TYPES),
vol.Optional(ATTR_COLOR): vol.In(DIAPER_COLORS),
vol.Optional(ATTR_AMOUNT): cv.positive_int,
vol.Optional(ATTR_NOTES): cv.string,
Expand Down Expand Up @@ -228,7 +228,7 @@ async def async_add_bmi(

async def async_add_diaper_change(
self,
type: str,
type: str | None = None,
time: datetime | time | None = None,
color: str | None = None,
amount: int | None = None,
Expand All @@ -240,8 +240,6 @@ async def async_add_diaper_change(
return
data = {
ATTR_CHILD: self.child[ATTR_ID],
ATTR_WET: type == "Wet and Solid" or type.lower() == ATTR_WET,
ATTR_SOLID: type == "Wet and Solid" or type.lower() == ATTR_SOLID,
}
if time:
try:
Expand All @@ -250,6 +248,9 @@ async def async_add_diaper_change(
except ValidationError as err:
_LOGGER.error(err)
return
if type:
data[ATTR_WET] = type == "Wet and Solid" or type.lower() == ATTR_WET
data[ATTR_SOLID] = type == "Wet and Solid" or type.lower() == ATTR_SOLID
if color:
data[ATTR_COLOR] = color.lower()
if amount:
Expand Down
2 changes: 0 additions & 2 deletions custom_components/babybuddy/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ add_diaper_change:
type:
name: Diaper type
description: Type of diaper change
required: true
default: wet
selector:
select:
options:
Expand Down

0 comments on commit 740e929

Please sign in to comment.