Skip to content

Commit e410313

Browse files
authored
Add sensors for Tuya cat toilet (#155245)
1 parent d9d4cc9 commit e410313

File tree

6 files changed

+241
-0
lines changed

6 files changed

+241
-0
lines changed

homeassistant/components/tuya/binary_sensor.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,24 @@ class TuyaBinarySensorEntityDescription(BinarySensorEntityDescription):
222222
on_value={"AQAB"},
223223
),
224224
),
225+
DeviceCategory.MSP: (
226+
TuyaBinarySensorEntityDescription(
227+
key=f"{DPCode.FAULT}_full_fault",
228+
dpcode=DPCode.FAULT,
229+
device_class=BinarySensorDeviceClass.PROBLEM,
230+
entity_category=EntityCategory.DIAGNOSTIC,
231+
bitmap_key="full_fault",
232+
translation_key="bag_full",
233+
),
234+
TuyaBinarySensorEntityDescription(
235+
key=f"{DPCode.FAULT}_box_out",
236+
dpcode=DPCode.FAULT,
237+
device_class=BinarySensorDeviceClass.PROBLEM,
238+
entity_category=EntityCategory.DIAGNOSTIC,
239+
bitmap_key="box_out",
240+
translation_key="cover_off",
241+
),
242+
),
225243
DeviceCategory.PIR: (
226244
TuyaBinarySensorEntityDescription(
227245
key=DPCode.PIR,

homeassistant/components/tuya/const.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ class DPCode(StrEnum):
714714
ECO2 = "eco2"
715715
EDGE_BRUSH = "edge_brush"
716716
ELECTRICITY_LEFT = "electricity_left"
717+
EXCRETION_TIME_DAY = "excretion_time_day"
718+
EXCRETION_TIMES_DAY = "excretion_times_day"
717719
FAN_BEEP = "fan_beep" # Sound
718720
FAN_COOL = "fan_cool" # Cool wind
719721
FAN_DIRECTION = "fan_direction" # Fan direction

homeassistant/components/tuya/sensor.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,15 @@ class TuyaSensorEntityDescription(SensorEntityDescription):
760760
device_class=SensorDeviceClass.WEIGHT,
761761
state_class=SensorStateClass.MEASUREMENT,
762762
),
763+
TuyaSensorEntityDescription(
764+
key=DPCode.EXCRETION_TIME_DAY,
765+
translation_key="excretion_time_day",
766+
device_class=SensorDeviceClass.DURATION,
767+
),
768+
TuyaSensorEntityDescription(
769+
key=DPCode.EXCRETION_TIMES_DAY,
770+
translation_key="excretion_times_day",
771+
),
763772
),
764773
DeviceCategory.MZJ: (
765774
TuyaSensorEntityDescription(

homeassistant/components/tuya/strings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@
2727
},
2828
"entity": {
2929
"binary_sensor": {
30+
"bag_full": {
31+
"name": "Bag full"
32+
},
3033
"carbon_dioxide": {
3134
"name": "Carbon dioxide"
3235
},
3336
"carbon_monoxide": {
3437
"name": "Carbon monoxide"
3538
},
39+
"cover_off": {
40+
"name": "Cover off"
41+
},
3642
"defrost": {
3743
"name": "Defrost"
3844
},
@@ -620,6 +626,12 @@
620626
"duster_cloth_life": {
621627
"name": "Duster cloth lifetime"
622628
},
629+
"excretion_time_day": {
630+
"name": "Excretion time (day)"
631+
},
632+
"excretion_times_day": {
633+
"name": "Excretion times (day)"
634+
},
623635
"feels_like_temperature": {
624636
"name": "Feels like"
625637
},

tests/components/tuya/snapshots/test_binary_sensor.ambr

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,104 @@
831831
'state': 'unavailable',
832832
})
833833
# ---
834+
# name: test_platform_setup_and_discovery[binary_sensor.kattenbak_bag_full-entry]
835+
EntityRegistryEntrySnapshot({
836+
'aliases': set({
837+
}),
838+
'area_id': None,
839+
'capabilities': None,
840+
'config_entry_id': <ANY>,
841+
'config_subentry_id': <ANY>,
842+
'device_class': None,
843+
'device_id': <ANY>,
844+
'disabled_by': None,
845+
'domain': 'binary_sensor',
846+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
847+
'entity_id': 'binary_sensor.kattenbak_bag_full',
848+
'has_entity_name': True,
849+
'hidden_by': None,
850+
'icon': None,
851+
'id': <ANY>,
852+
'labels': set({
853+
}),
854+
'name': None,
855+
'options': dict({
856+
}),
857+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
858+
'original_icon': None,
859+
'original_name': 'Bag full',
860+
'platform': 'tuya',
861+
'previous_unique_id': None,
862+
'suggested_object_id': None,
863+
'supported_features': 0,
864+
'translation_key': 'bag_full',
865+
'unique_id': 'tuya.yohkwjjdjlzludd3psmfault_full_fault',
866+
'unit_of_measurement': None,
867+
})
868+
# ---
869+
# name: test_platform_setup_and_discovery[binary_sensor.kattenbak_bag_full-state]
870+
StateSnapshot({
871+
'attributes': ReadOnlyDict({
872+
'device_class': 'problem',
873+
'friendly_name': 'Kattenbak Bag full',
874+
}),
875+
'context': <ANY>,
876+
'entity_id': 'binary_sensor.kattenbak_bag_full',
877+
'last_changed': <ANY>,
878+
'last_reported': <ANY>,
879+
'last_updated': <ANY>,
880+
'state': 'off',
881+
})
882+
# ---
883+
# name: test_platform_setup_and_discovery[binary_sensor.kattenbak_cover_off-entry]
884+
EntityRegistryEntrySnapshot({
885+
'aliases': set({
886+
}),
887+
'area_id': None,
888+
'capabilities': None,
889+
'config_entry_id': <ANY>,
890+
'config_subentry_id': <ANY>,
891+
'device_class': None,
892+
'device_id': <ANY>,
893+
'disabled_by': None,
894+
'domain': 'binary_sensor',
895+
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
896+
'entity_id': 'binary_sensor.kattenbak_cover_off',
897+
'has_entity_name': True,
898+
'hidden_by': None,
899+
'icon': None,
900+
'id': <ANY>,
901+
'labels': set({
902+
}),
903+
'name': None,
904+
'options': dict({
905+
}),
906+
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
907+
'original_icon': None,
908+
'original_name': 'Cover off',
909+
'platform': 'tuya',
910+
'previous_unique_id': None,
911+
'suggested_object_id': None,
912+
'supported_features': 0,
913+
'translation_key': 'cover_off',
914+
'unique_id': 'tuya.yohkwjjdjlzludd3psmfault_box_out',
915+
'unit_of_measurement': None,
916+
})
917+
# ---
918+
# name: test_platform_setup_and_discovery[binary_sensor.kattenbak_cover_off-state]
919+
StateSnapshot({
920+
'attributes': ReadOnlyDict({
921+
'device_class': 'problem',
922+
'friendly_name': 'Kattenbak Cover off',
923+
}),
924+
'context': <ANY>,
925+
'entity_id': 'binary_sensor.kattenbak_cover_off',
926+
'last_changed': <ANY>,
927+
'last_reported': <ANY>,
928+
'last_updated': <ANY>,
929+
'state': 'off',
930+
})
931+
# ---
834932
# name: test_platform_setup_and_discovery[binary_sensor.mesh_gateway_problem-entry]
835933
EntityRegistryEntrySnapshot({
836934
'aliases': set({

tests/components/tuya/snapshots/test_sensor.ambr

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9844,6 +9844,108 @@
98449844
'state': '0.0',
98459845
})
98469846
# ---
9847+
# name: test_platform_setup_and_discovery[sensor.kattenbak_excretion_time_day-entry]
9848+
EntityRegistryEntrySnapshot({
9849+
'aliases': set({
9850+
}),
9851+
'area_id': None,
9852+
'capabilities': None,
9853+
'config_entry_id': <ANY>,
9854+
'config_subentry_id': <ANY>,
9855+
'device_class': None,
9856+
'device_id': <ANY>,
9857+
'disabled_by': None,
9858+
'domain': 'sensor',
9859+
'entity_category': None,
9860+
'entity_id': 'sensor.kattenbak_excretion_time_day',
9861+
'has_entity_name': True,
9862+
'hidden_by': None,
9863+
'icon': None,
9864+
'id': <ANY>,
9865+
'labels': set({
9866+
}),
9867+
'name': None,
9868+
'options': dict({
9869+
'sensor': dict({
9870+
'suggested_display_precision': 2,
9871+
}),
9872+
}),
9873+
'original_device_class': <SensorDeviceClass.DURATION: 'duration'>,
9874+
'original_icon': None,
9875+
'original_name': 'Excretion time (day)',
9876+
'platform': 'tuya',
9877+
'previous_unique_id': None,
9878+
'suggested_object_id': None,
9879+
'supported_features': 0,
9880+
'translation_key': 'excretion_time_day',
9881+
'unique_id': 'tuya.yohkwjjdjlzludd3psmexcretion_time_day',
9882+
'unit_of_measurement': 's',
9883+
})
9884+
# ---
9885+
# name: test_platform_setup_and_discovery[sensor.kattenbak_excretion_time_day-state]
9886+
StateSnapshot({
9887+
'attributes': ReadOnlyDict({
9888+
'device_class': 'duration',
9889+
'friendly_name': 'Kattenbak Excretion time (day)',
9890+
'unit_of_measurement': 's',
9891+
}),
9892+
'context': <ANY>,
9893+
'entity_id': 'sensor.kattenbak_excretion_time_day',
9894+
'last_changed': <ANY>,
9895+
'last_reported': <ANY>,
9896+
'last_updated': <ANY>,
9897+
'state': '35.0',
9898+
})
9899+
# ---
9900+
# name: test_platform_setup_and_discovery[sensor.kattenbak_excretion_times_day-entry]
9901+
EntityRegistryEntrySnapshot({
9902+
'aliases': set({
9903+
}),
9904+
'area_id': None,
9905+
'capabilities': None,
9906+
'config_entry_id': <ANY>,
9907+
'config_subentry_id': <ANY>,
9908+
'device_class': None,
9909+
'device_id': <ANY>,
9910+
'disabled_by': None,
9911+
'domain': 'sensor',
9912+
'entity_category': None,
9913+
'entity_id': 'sensor.kattenbak_excretion_times_day',
9914+
'has_entity_name': True,
9915+
'hidden_by': None,
9916+
'icon': None,
9917+
'id': <ANY>,
9918+
'labels': set({
9919+
}),
9920+
'name': None,
9921+
'options': dict({
9922+
}),
9923+
'original_device_class': None,
9924+
'original_icon': None,
9925+
'original_name': 'Excretion times (day)',
9926+
'platform': 'tuya',
9927+
'previous_unique_id': None,
9928+
'suggested_object_id': None,
9929+
'supported_features': 0,
9930+
'translation_key': 'excretion_times_day',
9931+
'unique_id': 'tuya.yohkwjjdjlzludd3psmexcretion_times_day',
9932+
'unit_of_measurement': 'times',
9933+
})
9934+
# ---
9935+
# name: test_platform_setup_and_discovery[sensor.kattenbak_excretion_times_day-state]
9936+
StateSnapshot({
9937+
'attributes': ReadOnlyDict({
9938+
'friendly_name': 'Kattenbak Excretion times (day)',
9939+
'unit_of_measurement': 'times',
9940+
}),
9941+
'context': <ANY>,
9942+
'entity_id': 'sensor.kattenbak_excretion_times_day',
9943+
'last_changed': <ANY>,
9944+
'last_reported': <ANY>,
9945+
'last_updated': <ANY>,
9946+
'state': '1.0',
9947+
})
9948+
# ---
98479949
# name: test_platform_setup_and_discovery[sensor.keller_current-entry]
98489950
EntityRegistryEntrySnapshot({
98499951
'aliases': set({

0 commit comments

Comments
 (0)