mirror of
https://github.com/Ladebeze66/tuya_project.git
synced 2025-12-15 19:36:55 +01:00
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script pour basculer l'état de l'écran gauche (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 = "bfc369d2ca89602058xajc"
|
|
DEVICE_NAME = "ecran gauche"
|
|
|
|
# Le commutateur principal est sur le DPS 1
|
|
SWITCH_ID = "1"
|
|
|
|
def main():
|
|
"""Fonction principale pour basculer l'état de l'écran"""
|
|
# 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() |