mirror of
https://github.com/Ladebeze66/tuya_project.git
synced 2025-12-15 19:36:55 +01:00
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script pour basculer l'état du bureau dino (allumé/éteint) sans affecter le saber
|
|
À 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, report_for_streamdeck
|
|
|
|
# ID et nom de l'appareil
|
|
DEVICE_ID = "820180048cce4e2aecc7"
|
|
DEVICE_NAME = "Bureau Dino"
|
|
|
|
# Le commutateur principal est sur le DPS 1
|
|
SWITCH_ID = "1"
|
|
|
|
def main():
|
|
"""Fonction principale pour basculer l'état du bureau dino sans affecter le saber"""
|
|
# Connexion à l'appareil
|
|
device = connect_device(DEVICE_ID)
|
|
if not device:
|
|
report_for_streamdeck(False, DEVICE_NAME)
|
|
return
|
|
|
|
# Obtenir l'état actuel
|
|
status = device.status()
|
|
|
|
# Pour ce type d'appareil, le DPS 1 contrôle l'alimentation principale
|
|
current_state = status.get('dps', {}).get(SWITCH_ID, False)
|
|
|
|
# Basculer l'état (inverse de l'état actuel)
|
|
new_state = not current_state
|
|
result = device.set_value(SWITCH_ID, new_state)
|
|
|
|
# Rapport pour StreamDeck
|
|
report_for_streamdeck(result is not None, DEVICE_NAME, new_state)
|
|
|
|
if __name__ == "__main__":
|
|
main() |