Untitled

 avatar
user_3431143
plain_text
a year ago
876 B
1
Indexable
Never
import time
from devices import DeviceScanner, DeviceStateTracker
from notifier import WebhookNotifier


def main():
    # Initialize device scanner, device state tracker, and notifier
    scanner = DeviceScanner(ip_range="192.168.0.0/24")
    state_tracker = DeviceStateTracker()
    notifier = WebhookNotifier(url="https://webhook.site/898bae18-a5de-4100-8acb-1db15a02081e")

    # Scan the network and update device states
    scanner.scan()
    state_tracker.update_states(scanner.devices)

    # Send initial device state to notifier
    notifier.notify(state_tracker.get_all_devices())

    # Start continuous scanning loop
    while True:
        time.sleep(60)
        scanner.scan()
        changed_devices = state_tracker.update_states(scanner.devices)
        if changed_devices:
            notifier.notify(changed_devices)


if __name__ == "__main__":
    main()