Skip to content

debuging with debugpy #474

@kwittwer

Description

@kwittwer

Hi, I'm trying to debaug the coede in the container itself but not abele zu establish connection.
I added debugpy to the packages and to the script
import appdaemon.plugins.hass.hassapi as hass
`import appdaemon.plugins.hass.hassapi as hass
import datetime
import debugpy

Debugger aktivieren, aber NICHT warten

class HelloWorld(hass.Hass):
"""Beispiel AppDaemon App"""

def initialize(self):
    """Wird beim Start der App aufgerufen"""
    debugpy.listen(("0.0.0.0", 5678))
    self.log("Debugger läuft auf Port 5678...")
    debugpy.wait_for_client()  # Warte auf Verbindung
    
    self.log("Hello World App gestartet!")
    self.log("Hello World App gestartet!fafafe")
    
    # Beispiel: Callback bei Zeitpunkt
    runtime = datetime.time(20, 0, 0)
    self.run_daily(self.abends_callback, runtime)
    
    # Beispiel: Callback bei State-Änderung
    self.listen_state(self.licht_callback, "light.wohnzimmer")
    
    # Beispiel: Event Listener
    self.listen_event(self.button_pressed, "deconz_event")

def abends_callback(self, kwargs):
    """Wird täglich um 20:00 aufgerufen"""
    self.log("Es ist 20 Uhr!")
    self.call_service("light/turn_on", entity_id="light.wohnzimmer")

def licht_callback(self, entity, attribute, old, new, kwargs):
    """Wird bei Änderung des Lichtstatus aufgerufen"""
    self.log(f"Licht Status geändert von {old} zu {new}")

def button_pressed(self, event_name, data, kwargs):
    """Wird bei Button-Event aufgerufen"""
    self.log(f"Button Event: {data}")`

the launch file is like that
{ "version": "0.2.0", "configurations": [ { "name": "AppDaemon Debugger", "type": "debugpy", "request": "attach", "connect": { "host": "localhost", "port": 5678 } } ] }
I guess the Port is closed. Is there any remote port that can be used for that? How can i add an additional port to be exposed?

Thank you for your Help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions