Skip to content

Commit fc8703a

Browse files
lbouejoostlekMartinHjelmare
authored
Matter DoorLock attributes (home-assistant#151418)
Co-authored-by: Joost Lekkerkerker <[email protected]> Co-authored-by: Martin Hjelmare <[email protected]>
1 parent 80517c7 commit fc8703a

File tree

7 files changed

+437
-3
lines changed

7 files changed

+437
-3
lines changed

homeassistant/components/matter/icons.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@
148148
},
149149
"evse_charging_switch": {
150150
"default": "mdi:ev-station"
151+
},
152+
"privacy_mode_button": {
153+
"default": "mdi:shield-lock"
151154
}
152155
}
153156
}

homeassistant/components/matter/number.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ async def async_set_native_value(self, value: float) -> None:
8080
sendvalue = int(value)
8181
if value_convert := self.entity_description.ha_to_device:
8282
sendvalue = value_convert(value)
83-
await self.write_attribute(
84-
value=sendvalue,
85-
)
83+
await self.write_attribute(value=sendvalue)
8684

8785
@callback
8886
def _update_from_device(self) -> None:
@@ -437,4 +435,35 @@ def _update_from_device(self) -> None:
437435
custom_clusters.InovelliCluster.Attributes.LEDIndicatorIntensityOn,
438436
),
439437
),
438+
MatterDiscoverySchema(
439+
platform=Platform.NUMBER,
440+
entity_description=MatterNumberEntityDescription(
441+
key="DoorLockWrongCodeEntryLimit",
442+
entity_category=EntityCategory.CONFIG,
443+
translation_key="wrong_code_entry_limit",
444+
native_max_value=255,
445+
native_min_value=1,
446+
native_step=1,
447+
mode=NumberMode.BOX,
448+
),
449+
entity_class=MatterNumber,
450+
required_attributes=(clusters.DoorLock.Attributes.WrongCodeEntryLimit,),
451+
),
452+
MatterDiscoverySchema(
453+
platform=Platform.NUMBER,
454+
entity_description=MatterNumberEntityDescription(
455+
key="DoorLockUserCodeTemporaryDisableTime",
456+
entity_category=EntityCategory.CONFIG,
457+
translation_key="user_code_temporary_disable_time",
458+
native_max_value=255,
459+
native_min_value=1,
460+
native_step=1,
461+
native_unit_of_measurement=UnitOfTime.SECONDS,
462+
mode=NumberMode.BOX,
463+
),
464+
entity_class=MatterNumber,
465+
required_attributes=(
466+
clusters.DoorLock.Attributes.UserCodeTemporaryDisableTime,
467+
),
468+
),
440469
]

homeassistant/components/matter/strings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@
198198
"pump_setpoint": {
199199
"name": "Setpoint"
200200
},
201+
"user_code_temporary_disable_time": {
202+
"name": "User code temporary disable time"
203+
},
201204
"temperature_offset": {
202205
"name": "Temperature offset"
203206
},
@@ -218,6 +221,9 @@
218221
},
219222
"valve_configuration_and_control_default_open_duration": {
220223
"name": "Default open duration"
224+
},
225+
"wrong_code_entry_limit": {
226+
"name": "Wrong code limit"
221227
}
222228
},
223229
"light": {
@@ -513,6 +519,9 @@
513519
},
514520
"evse_charging_switch": {
515521
"name": "Enable charging"
522+
},
523+
"privacy_mode_button": {
524+
"name": "Privacy mode button"
516525
}
517526
},
518527
"vacuum": {

homeassistant/components/matter/switch.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,18 @@ def _update_from_device(self) -> None:
263263
),
264264
vendor_id=(4874,),
265265
),
266+
MatterDiscoverySchema(
267+
platform=Platform.SWITCH,
268+
entity_description=MatterNumericSwitchEntityDescription(
269+
key="DoorLockEnablePrivacyModeButton",
270+
entity_category=EntityCategory.CONFIG,
271+
translation_key="privacy_mode_button",
272+
device_to_ha=bool,
273+
ha_to_device=int,
274+
),
275+
entity_class=MatterNumericSwitch,
276+
required_attributes=(clusters.DoorLock.Attributes.EnablePrivacyModeButton,),
277+
),
266278
MatterDiscoverySchema(
267279
platform=Platform.SWITCH,
268280
entity_description=MatterGenericCommandSwitchEntityDescription(

tests/components/matter/snapshots/test_number.ambr

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,121 @@
518518
'state': '60',
519519
})
520520
# ---
521+
# name: test_numbers[door_lock][number.mock_door_lock_user_code_temporary_disable_time-entry]
522+
EntityRegistryEntrySnapshot({
523+
'aliases': set({
524+
}),
525+
'area_id': None,
526+
'capabilities': dict({
527+
'max': 255,
528+
'min': 1,
529+
'mode': <NumberMode.BOX: 'box'>,
530+
'step': 1,
531+
}),
532+
'config_entry_id': <ANY>,
533+
'config_subentry_id': <ANY>,
534+
'device_class': None,
535+
'device_id': <ANY>,
536+
'disabled_by': None,
537+
'domain': 'number',
538+
'entity_category': <EntityCategory.CONFIG: 'config'>,
539+
'entity_id': 'number.mock_door_lock_user_code_temporary_disable_time',
540+
'has_entity_name': True,
541+
'hidden_by': None,
542+
'icon': None,
543+
'id': <ANY>,
544+
'labels': set({
545+
}),
546+
'name': None,
547+
'options': dict({
548+
}),
549+
'original_device_class': None,
550+
'original_icon': None,
551+
'original_name': 'User code temporary disable time',
552+
'platform': 'matter',
553+
'previous_unique_id': None,
554+
'suggested_object_id': None,
555+
'supported_features': 0,
556+
'translation_key': 'user_code_temporary_disable_time',
557+
'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-DoorLockUserCodeTemporaryDisableTime-257-49',
558+
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
559+
})
560+
# ---
561+
# name: test_numbers[door_lock][number.mock_door_lock_user_code_temporary_disable_time-state]
562+
StateSnapshot({
563+
'attributes': ReadOnlyDict({
564+
'friendly_name': 'Mock Door Lock User code temporary disable time',
565+
'max': 255,
566+
'min': 1,
567+
'mode': <NumberMode.BOX: 'box'>,
568+
'step': 1,
569+
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
570+
}),
571+
'context': <ANY>,
572+
'entity_id': 'number.mock_door_lock_user_code_temporary_disable_time',
573+
'last_changed': <ANY>,
574+
'last_reported': <ANY>,
575+
'last_updated': <ANY>,
576+
'state': '10',
577+
})
578+
# ---
579+
# name: test_numbers[door_lock][number.mock_door_lock_wrong_code_limit-entry]
580+
EntityRegistryEntrySnapshot({
581+
'aliases': set({
582+
}),
583+
'area_id': None,
584+
'capabilities': dict({
585+
'max': 255,
586+
'min': 1,
587+
'mode': <NumberMode.BOX: 'box'>,
588+
'step': 1,
589+
}),
590+
'config_entry_id': <ANY>,
591+
'config_subentry_id': <ANY>,
592+
'device_class': None,
593+
'device_id': <ANY>,
594+
'disabled_by': None,
595+
'domain': 'number',
596+
'entity_category': <EntityCategory.CONFIG: 'config'>,
597+
'entity_id': 'number.mock_door_lock_wrong_code_limit',
598+
'has_entity_name': True,
599+
'hidden_by': None,
600+
'icon': None,
601+
'id': <ANY>,
602+
'labels': set({
603+
}),
604+
'name': None,
605+
'options': dict({
606+
}),
607+
'original_device_class': None,
608+
'original_icon': None,
609+
'original_name': 'Wrong code limit',
610+
'platform': 'matter',
611+
'previous_unique_id': None,
612+
'suggested_object_id': None,
613+
'supported_features': 0,
614+
'translation_key': 'wrong_code_entry_limit',
615+
'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-DoorLockWrongCodeEntryLimit-257-48',
616+
'unit_of_measurement': None,
617+
})
618+
# ---
619+
# name: test_numbers[door_lock][number.mock_door_lock_wrong_code_limit-state]
620+
StateSnapshot({
621+
'attributes': ReadOnlyDict({
622+
'friendly_name': 'Mock Door Lock Wrong code limit',
623+
'max': 255,
624+
'min': 1,
625+
'mode': <NumberMode.BOX: 'box'>,
626+
'step': 1,
627+
}),
628+
'context': <ANY>,
629+
'entity_id': 'number.mock_door_lock_wrong_code_limit',
630+
'last_changed': <ANY>,
631+
'last_reported': <ANY>,
632+
'last_updated': <ANY>,
633+
'state': '3',
634+
})
635+
# ---
521636
# name: test_numbers[door_lock_with_unbolt][number.mock_door_lock_autorelock_time-entry]
522637
EntityRegistryEntrySnapshot({
523638
'aliases': set({
@@ -576,6 +691,121 @@
576691
'state': '60',
577692
})
578693
# ---
694+
# name: test_numbers[door_lock_with_unbolt][number.mock_door_lock_user_code_temporary_disable_time-entry]
695+
EntityRegistryEntrySnapshot({
696+
'aliases': set({
697+
}),
698+
'area_id': None,
699+
'capabilities': dict({
700+
'max': 255,
701+
'min': 1,
702+
'mode': <NumberMode.BOX: 'box'>,
703+
'step': 1,
704+
}),
705+
'config_entry_id': <ANY>,
706+
'config_subentry_id': <ANY>,
707+
'device_class': None,
708+
'device_id': <ANY>,
709+
'disabled_by': None,
710+
'domain': 'number',
711+
'entity_category': <EntityCategory.CONFIG: 'config'>,
712+
'entity_id': 'number.mock_door_lock_user_code_temporary_disable_time',
713+
'has_entity_name': True,
714+
'hidden_by': None,
715+
'icon': None,
716+
'id': <ANY>,
717+
'labels': set({
718+
}),
719+
'name': None,
720+
'options': dict({
721+
}),
722+
'original_device_class': None,
723+
'original_icon': None,
724+
'original_name': 'User code temporary disable time',
725+
'platform': 'matter',
726+
'previous_unique_id': None,
727+
'suggested_object_id': None,
728+
'supported_features': 0,
729+
'translation_key': 'user_code_temporary_disable_time',
730+
'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-DoorLockUserCodeTemporaryDisableTime-257-49',
731+
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
732+
})
733+
# ---
734+
# name: test_numbers[door_lock_with_unbolt][number.mock_door_lock_user_code_temporary_disable_time-state]
735+
StateSnapshot({
736+
'attributes': ReadOnlyDict({
737+
'friendly_name': 'Mock Door Lock User code temporary disable time',
738+
'max': 255,
739+
'min': 1,
740+
'mode': <NumberMode.BOX: 'box'>,
741+
'step': 1,
742+
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
743+
}),
744+
'context': <ANY>,
745+
'entity_id': 'number.mock_door_lock_user_code_temporary_disable_time',
746+
'last_changed': <ANY>,
747+
'last_reported': <ANY>,
748+
'last_updated': <ANY>,
749+
'state': '10',
750+
})
751+
# ---
752+
# name: test_numbers[door_lock_with_unbolt][number.mock_door_lock_wrong_code_limit-entry]
753+
EntityRegistryEntrySnapshot({
754+
'aliases': set({
755+
}),
756+
'area_id': None,
757+
'capabilities': dict({
758+
'max': 255,
759+
'min': 1,
760+
'mode': <NumberMode.BOX: 'box'>,
761+
'step': 1,
762+
}),
763+
'config_entry_id': <ANY>,
764+
'config_subentry_id': <ANY>,
765+
'device_class': None,
766+
'device_id': <ANY>,
767+
'disabled_by': None,
768+
'domain': 'number',
769+
'entity_category': <EntityCategory.CONFIG: 'config'>,
770+
'entity_id': 'number.mock_door_lock_wrong_code_limit',
771+
'has_entity_name': True,
772+
'hidden_by': None,
773+
'icon': None,
774+
'id': <ANY>,
775+
'labels': set({
776+
}),
777+
'name': None,
778+
'options': dict({
779+
}),
780+
'original_device_class': None,
781+
'original_icon': None,
782+
'original_name': 'Wrong code limit',
783+
'platform': 'matter',
784+
'previous_unique_id': None,
785+
'suggested_object_id': None,
786+
'supported_features': 0,
787+
'translation_key': 'wrong_code_entry_limit',
788+
'unique_id': '00000000000004D2-0000000000000001-MatterNodeDevice-1-DoorLockWrongCodeEntryLimit-257-48',
789+
'unit_of_measurement': None,
790+
})
791+
# ---
792+
# name: test_numbers[door_lock_with_unbolt][number.mock_door_lock_wrong_code_limit-state]
793+
StateSnapshot({
794+
'attributes': ReadOnlyDict({
795+
'friendly_name': 'Mock Door Lock Wrong code limit',
796+
'max': 255,
797+
'min': 1,
798+
'mode': <NumberMode.BOX: 'box'>,
799+
'step': 1,
800+
}),
801+
'context': <ANY>,
802+
'entity_id': 'number.mock_door_lock_wrong_code_limit',
803+
'last_changed': <ANY>,
804+
'last_reported': <ANY>,
805+
'last_updated': <ANY>,
806+
'state': '3',
807+
})
808+
# ---
579809
# name: test_numbers[eve_thermo][number.eve_thermo_temperature_offset-entry]
580810
EntityRegistryEntrySnapshot({
581811
'aliases': set({

0 commit comments

Comments
 (0)