From 969322e14a4db0a8edce8d9192e56b60b8f671c5 Mon Sep 17 00:00:00 2001 From: Alexei Chetroi Date: Thu, 24 Oct 2019 12:23:02 -0400 Subject: [PATCH] Fixes/zha ieee tail (#28160) * Fix ZHA entity_id assignment. * Update tests. --- homeassistant/components/zha/entity.py | 2 +- tests/components/zha/common.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/zha/entity.py b/homeassistant/components/zha/entity.py index 00c3942358e..c11cd405a99 100644 --- a/homeassistant/components/zha/entity.py +++ b/homeassistant/components/zha/entity.py @@ -40,7 +40,7 @@ class ZhaEntity(RestoreEntity, LogMixin, entity.Entity): self._unique_id = unique_id if not skip_entity_id: ieee = zha_device.ieee - ieeetail = "".join(["%02x" % (o,) for o in ieee[-4:]]) + ieeetail = "".join([f"{o:02x}" for o in ieee[:4]]) self.entity_id = "{}.{}_{}_{}_{}{}".format( self._domain, slugify(zha_device.manufacturer), diff --git a/tests/components/zha/common.py b/tests/components/zha/common.py index 5f9172749b0..788faaaec73 100644 --- a/tests/components/zha/common.py +++ b/tests/components/zha/common.py @@ -168,7 +168,7 @@ def make_entity_id(domain, device, cluster, use_suffix=True): machine so that we can test state changes. """ ieee = device.ieee - ieeetail = "".join(["%02x" % (o,) for o in ieee[-4:]]) + ieeetail = "".join([f"{o:02x}" for o in ieee[:4]]) entity_id = "{}.{}_{}_{}_{}{}".format( domain, slugify(device.manufacturer),