Fix wirelesstag switch arm/disarm (#59515)

This commit is contained in:
Sergiy Maysak 2021-11-11 03:21:29 +02:00 committed by Paulus Schoutsen
parent 9cb4a5ca39
commit 04e1dc3a10

View File

@ -73,16 +73,14 @@ class WirelessTagPlatform:
def arm(self, switch):
"""Arm entity sensor monitoring."""
func_name = f"arm_{switch.sensor_type}"
arm_func = getattr(self.api, func_name)
if arm_func is not None:
func_name = f"arm_{switch.entity_description.key}"
if (arm_func := getattr(self.api, func_name)) is not None:
arm_func(switch.tag_id, switch.tag_manager_mac)
def disarm(self, switch):
"""Disarm entity sensor monitoring."""
func_name = f"disarm_{switch.sensor_type}"
disarm_func = getattr(self.api, func_name)
if disarm_func is not None:
func_name = f"disarm_{switch.entity_description.key}"
if (disarm_func := getattr(self.api, func_name)) is not None:
disarm_func(switch.tag_id, switch.tag_manager_mac)
def start_monitoring(self):