mirror of
https://github.com/Ladebeze66/tuya_project.git
synced 2025-12-15 19:36:55 +01:00
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script pour basculer l'état de la sirène intelligente (activée/désactivée)
|
|
À 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 = "bf4054de281cb6ada8actg"
|
|
DEVICE_NAME = "Sirène intelligente"
|
|
|
|
def main():
|
|
"""Fonction principale pour basculer l'état de la sirène"""
|
|
# 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 127 indique l'état de l'alarme
|
|
current_state = status.get('dps', {}).get('127', False)
|
|
|
|
# Basculer l'état (inverse de l'état actuel)
|
|
new_state = not current_state
|
|
result = device.set_value('127', new_state)
|
|
|
|
# Rapport pour StreamDeck
|
|
report_for_streamdeck(result is not None, DEVICE_NAME, new_state)
|
|
|
|
if __name__ == "__main__":
|
|
main() |