Skip to content

Commit

Permalink
Get updated attribute values
Browse files Browse the repository at this point in the history
Make sure to get the attribute values again after each command to get
the updated attribute cache.
  • Loading branch information
agners committed Sep 16, 2024
1 parent f378cb6 commit 61a1106
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ def subUpdate(path: TypedAttributePath, transaction: SubscriptionTransaction):
sub.SetAttributeUpdateCallback(subUpdate)

try:
data = sub.GetAttributes()
req = Clusters.OnOff.Commands.On()
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=req)

await asyncio.wait_for(event.wait(), timeout=11)

data = sub.GetAttributes()
if (data[1][Clusters.OnOff][Clusters.OnOff.Attributes.OnOff] != 1):
raise ValueError("Current On/Off state should be 1")

Expand All @@ -232,6 +232,7 @@ def subUpdate(path: TypedAttributePath, transaction: SubscriptionTransaction):

await asyncio.wait_for(event.wait(), timeout=11)

data = sub.GetAttributes()
if (data[1][Clusters.OnOff][Clusters.OnOff.Attributes.OnOff] != 0):
raise ValueError("Current On/Off state should be 0")

Expand All @@ -254,13 +255,12 @@ def subUpdate(path: TypedAttributePath, transaction: SubscriptionTransaction):
sub.SetAttributeUpdateCallback(subUpdate)

try:
data = sub.GetAttributes()

req = Clusters.OnOff.Commands.On()
await devCtrl.SendCommand(nodeid=NODE_ID, endpoint=1, payload=req)

await asyncio.wait_for(event.wait(), timeout=11)

data = sub.GetAttributes()
cluster: Clusters.OnOff = data[1][Clusters.OnOff]
if (not cluster.onOff):
raise ValueError("Current On/Off state should be True")
Expand All @@ -272,6 +272,7 @@ def subUpdate(path: TypedAttributePath, transaction: SubscriptionTransaction):

await asyncio.wait_for(event.wait(), timeout=11)

data = sub.GetAttributes()
cluster: Clusters.OnOff = data[1][Clusters.OnOff]
if (cluster.onOff):
raise ValueError("Current On/Off state should be False")
Expand All @@ -298,7 +299,6 @@ async def TestSubscribeZeroMinInterval(cls, devCtrl):
logger.info("Test Subscription With MinInterval of 0")
sub = await devCtrl.ReadAttribute(nodeid=NODE_ID,
attributes=[Clusters.OnOff, Clusters.LevelControl], reportInterval=(0, 60))
data = sub.GetAttributes()

logger.info("Sending off command")

Expand All @@ -315,6 +315,7 @@ async def TestSubscribeZeroMinInterval(cls, devCtrl):

logger.info("Checking read back value is indeed 254")

data = sub.GetAttributes()
if (data[1][Clusters.LevelControl][Clusters.LevelControl.Attributes.CurrentLevel] != 254):
raise ValueError("Current Level should have been 254")

Expand Down

0 comments on commit 61a1106

Please sign in to comment.