mirror of
https://github.com/Ladebeze66/tuya_project.git
synced 2025-12-15 19:36:55 +01:00
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script pour contrôler le volet du salon (ouvrir/fermer/arrêter)
|
|
À 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, control_shutter, report_for_streamdeck
|
|
|
|
# ID et nom de l'appareil
|
|
DEVICE_ID = "bfc74a089fe0a9a50d2eeg"
|
|
DEVICE_NAME = "volet salon"
|
|
|
|
def main():
|
|
"""Fonction principale pour contrôler le volet du salon"""
|
|
# 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()
|
|
|
|
# Si le volet est arrêté, l'ouvrir
|
|
# Si le volet est en mouvement, l'arrêter
|
|
current_state = status.get('dps', {}).get('1', 'stop')
|
|
|
|
if current_state == "stop":
|
|
# Si arrêté, on ouvre
|
|
action = "up" # Utilise "forward" en interne
|
|
else:
|
|
# Si en mouvement, on arrête
|
|
action = "stop"
|
|
|
|
# Exécuter l'action et obtenir le résultat
|
|
result = control_shutter(device, action)
|
|
|
|
# Rapport pour StreamDeck
|
|
report_for_streamdeck(result, DEVICE_NAME, action)
|
|
|
|
if __name__ == "__main__":
|
|
main() |