sz cover l support
This commit is contained in:
82
pyscript/hmip_wrc6_schlafzimmer.py
Normal file
82
pyscript/hmip_wrc6_schlafzimmer.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# =============================================================================
|
||||
# Homematic 6x Multischalter – Rollosteuerung
|
||||
# =============================================================================
|
||||
# Datei ablegen unter: config/pyscript/rollo_multischalter.py
|
||||
#
|
||||
# Konfiguration:
|
||||
# DEVICE_ADDRESS → Homematic-Adresse des Multischalters (aus HA-Gerätebeschreibung)
|
||||
# COVER_ENTITY → Entity-ID des Rollos in Home Assistant
|
||||
# SUBTYPE_LEFT → subtype-Wert der linken Taste (aus Event auslesen)
|
||||
# SUBTYPE_RIGHT → subtype-Wert der rechten Taste (aus Event auslesen)
|
||||
#
|
||||
# Tastenbelegung:
|
||||
# Linke Taste – kurzer Druck → Hochfahren / Stopp (Wechsel)
|
||||
# Linke Taste – langer Druck → Position 70 %
|
||||
# Rechte Taste – kurzer Druck → Runterfahren / Stopp (Wechsel)
|
||||
# Rechte Taste – langer Druck → Position 20 %
|
||||
# =============================================================================
|
||||
|
||||
# ── Anpassen ──────────────────────────────────────────────────────────────────
|
||||
DEVICE_ADDRESS = "000B5A4992908E" # Homematic-Geräteadresse ← anpassen!
|
||||
COVER_ENTITY = "cover.shelly_c4a2f1" # Entity-ID des Rollos
|
||||
SUBTYPE_LEFT = 1 # subtype linke Taste ← ggf. anpassen
|
||||
SUBTYPE_RIGHT = 2 # subtype rechte Taste ← ggf. anpassen
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
def _is_moving(entity_id: str) -> bool:
|
||||
"""Gibt True zurück, wenn das Rollo laut HA gerade fährt."""
|
||||
current_state = state.get(entity_id)
|
||||
if current_state is None:
|
||||
return False
|
||||
return current_state in ("opening", "closing")
|
||||
|
||||
|
||||
@event_trigger("homematic.keypress")
|
||||
def handle_keypress(**kwargs):
|
||||
"""Wertet Homematic-Keypressereignisse aus."""
|
||||
address = kwargs.get("address", "")
|
||||
subtype = kwargs.get("subtype")
|
||||
action = kwargs.get("type", "") # "press_short" | "press_long"
|
||||
|
||||
# Nur Events für unseren Schalter verarbeiten
|
||||
if address != DEVICE_ADDRESS:
|
||||
return
|
||||
|
||||
if subtype == SUBTYPE_LEFT:
|
||||
if action == "press_short":
|
||||
_toggle_up(COVER_ENTITY)
|
||||
elif action == "press_long":
|
||||
_set_position(COVER_ENTITY, 70)
|
||||
|
||||
elif subtype == SUBTYPE_RIGHT:
|
||||
if action == "press_short":
|
||||
_toggle_down(COVER_ENTITY)
|
||||
elif action == "press_long":
|
||||
_set_position(COVER_ENTITY, 20)
|
||||
|
||||
|
||||
def _toggle_up(entity_id: str):
|
||||
"""Kurzer Druck links: Hochfahren – oder Stopp, wenn das Rollo fährt."""
|
||||
if _is_moving(entity_id):
|
||||
log.info(f"[Rollo] Stopp (war in Bewegung) → {entity_id}")
|
||||
cover.stop_cover(entity_id=entity_id)
|
||||
else:
|
||||
log.info(f"[Rollo] Hochfahren → {entity_id}")
|
||||
cover.open_cover(entity_id=entity_id)
|
||||
|
||||
|
||||
def _toggle_down(entity_id: str):
|
||||
"""Kurzer Druck rechts: Runterfahren – oder Stopp, wenn das Rollo fährt."""
|
||||
if _is_moving(entity_id):
|
||||
log.info(f"[Rollo] Stopp (war in Bewegung) → {entity_id}")
|
||||
cover.stop_cover(entity_id=entity_id)
|
||||
else:
|
||||
log.info(f"[Rollo] Runterfahren → {entity_id}")
|
||||
cover.close_cover(entity_id=entity_id)
|
||||
|
||||
|
||||
def _set_position(entity_id: str, position: int):
|
||||
"""Fährt das Rollo auf eine bestimmte Position (0 = ganz zu, 100 = ganz auf)."""
|
||||
log.info(f"[Rollo] Zielposition {position}% → {entity_id}")
|
||||
cover.set_cover_position(entity_id=entity_id, position=position)
|
||||
Reference in New Issue
Block a user