Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting online state #583

Open
toorisrael opened this issue Jan 14, 2025 · 5 comments
Open

Getting online state #583

toorisrael opened this issue Jan 14, 2025 · 5 comments
Labels
zigbee/bt Support for ZigBee and Bluetooth Tuya devices and gateways

Comments

@toorisrael
Copy link

Hi.
Is there a way I can locally get zigbee smart plug online/offline state?
I've got internet router, zigbee gateway, home servers etc connected to UPS, what I wanna achieve is getting info if there is power outage. But even if smart plug is disconnected from power source, gateway is returning cached device status.

@uzlonewolf
Copy link
Collaborator

I don't think so. One of the power saving features of Zigbee is it only transmits when changing states, so the gateway has no way of knowing when a plug drops offline. If it's been offline for a while you might see the CID disappear from the list returned by gw.subdev_query().

@uzlonewolf uzlonewolf added the zigbee/bt Support for ZigBee and Bluetooth Tuya devices and gateways label Jan 14, 2025
@toorisrael
Copy link
Author

But somehow tuya api knows device is offline

@jasonacox
Copy link
Owner

I think you will see that for any device that fails to report in to the Tuya Cloud. I don't know what "offline" duration actually activates that. Or are you talking about something else?

@uzlonewolf
Copy link
Collaborator

In that case gw.subdev_query() should return the online/offline status.

@toorisrael
Copy link
Author

It seems subdev_query doesn't work correctly with my gatewary (lidl/silvercest). If I understand it correctly, it should return list of all devices paired with gateway, but it returns only one or none:

gw = tinytuya.Device(config.gatewayid, address=None, local_key=config.localkey, persist=True, version=3.3)
print(gw.subdev_query())

{'dps': {'101': -10}, 'cid': 'a4c1384c4a22880d', 't': 1737100622}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zigbee/bt Support for ZigBee and Bluetooth Tuya devices and gateways
Projects
None yet
Development

No branches or pull requests

3 participants