mirror of
https://github.com/Ladebeze66/tuya_project.git
synced 2025-12-15 19:36:55 +01:00
37 lines
986 B
Python
37 lines
986 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script pour basculer l'état du PC (allumé/éteint)
|
|
À utiliser avec StreamDeck
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Ajouter le répertoire parent au path pour les imports
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
|
|
from common.utils import connect_device, toggle_device, report_for_streamdeck
|
|
|
|
# ID et nom de l'appareil
|
|
DEVICE_ID = "bfe57aa0e61a9b529bzrff"
|
|
DEVICE_NAME = "PC"
|
|
|
|
# Commutateur principal
|
|
SWITCH_ID = "1"
|
|
|
|
def main():
|
|
"""Fonction principale pour basculer l'état du PC"""
|
|
# Connexion à l'appareil
|
|
device = connect_device(DEVICE_ID)
|
|
if not device:
|
|
report_for_streamdeck(False, DEVICE_NAME)
|
|
return
|
|
|
|
# Basculer l'état et obtenir le nouvel état
|
|
new_state = toggle_device(device, SWITCH_ID)
|
|
|
|
# Rapport pour StreamDeck
|
|
report_for_streamdeck(new_state is not None, DEVICE_NAME, new_state)
|
|
|
|
if __name__ == "__main__":
|
|
main() |