Skip to content

Commit

Permalink
✨ add button for litter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezza34000 committed Dec 18, 2024
1 parent c9f546f commit c53a03d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
32 changes: 31 additions & 1 deletion custom_components/petkit/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import TYPE_CHECKING

from pypetkitapi.command import FeederCommand, LBAction, LBCommand, LitterCommand
from pypetkitapi.const import D3, D4H, D4S, D4SH, DEVICES_FEEDER, DEVICES_LITTER_BOX, T4
from pypetkitapi.const import D3, D4H, D4S, D4SH, DEVICES_FEEDER, DEVICES_LITTER_BOX, T4, T3, T6
from pypetkitapi.feeder_container import Feeder
from pypetkitapi.litter_container import Litter
from pypetkitapi.water_fountain_container import WaterFountain
Expand Down Expand Up @@ -155,6 +155,36 @@ class PetKitButtonDesc(PetKitDescSensorBase, ButtonEntityDescription):
only_for_types=DEVICES_LITTER_BOX,
is_available=lambda device: device.state.work_state is not None,
),
PetKitButtonDesc(
key="Deodorize",
translation_key="deodorize",
action=lambda api, device: api.send_api_request(
device.id,
LitterCommand.CONTROL_DEVICE,
{LBAction.START: LBCommand.ODOR_REMOVAL},
),
only_for_types=DEVICES_LITTER_BOX,
),
PetKitButtonDesc(
key="Reset odor eliminator",
translation_key="reset_odor_eliminator",
action=lambda api, device: api.send_api_request(
device.id,
LitterCommand.CONTROL_DEVICE,
{LBAction.START: LBCommand.RESET_DEODOR},
),
only_for_types=[T3],
),
PetKitButtonDesc(
key="Reset odor eliminator",
translation_key="reset_odor_eliminator",
action=lambda api, device: api.send_api_request(
device.id,
LitterCommand.CONTROL_DEVICE,
{LBAction.START: LBCommand.RESET_MAX_DEODOR},
),
only_for_types=[T4, T6],
),
],
WaterFountain: [
# PetKitButtonDesc(
Expand Down
6 changes: 6 additions & 0 deletions custom_components/petkit/icons.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
},
"start_scoop": {
"default": "mdi:broom"
},
"deodorize": {
"default": "mdi:spray"
},
"reset_odor_eliminator": {
"default": "mdi:scent"
}
},
"number": {
Expand Down
6 changes: 6 additions & 0 deletions custom_components/petkit/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
},
"start_scoop": {
"name": "Scoop"
},
"deodorize": {
"name": "Deodorize"
},
"reset_odor_eliminator": {
"name": "Reset odor eliminator"
}
},
"number": {
Expand Down

0 comments on commit c53a03d

Please sign in to comment.