Created
January 3, 2023 10:35
-
-
Save farshidtz/79a7d18a8b2241d9de7604e283f88a90 to your computer and use it in GitHub Desktop.
Simple Matter on/off handler in Python. See https://stackoverflow.com/a/74992066/3041544
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from chip.server import ( | |
GetLibraryHandle, | |
PostAttributeChangeCallback, | |
) | |
CLUSTER_ONOFF = 6 | |
ATTR_ONOFF = 0 | |
@PostAttributeChangeCallback | |
def attributeChangeCallback(endpoint: int, clusterId: int, attributeId: int, xx_type: int, size: int, value: bytes): | |
if endpoint == 1: | |
if clusterId == CLUSTER_ONOFF and attributeId == ATTR_ONOFF: | |
if value and value[0] == 1: | |
print(">>> on <<<") | |
else: | |
print(">>> off <<<") | |
chipLib = GetLibraryHandle(attributeChangeCallback) | |
input('Press any key to exit') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment