File: findEnphaseWithBonjour.py

package info (click to toggle)
python-envoy-utils 0.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 136 kB
  • sloc: python: 120; makefile: 4
file content (20 lines) | stat: -rwxr-xr-x 649 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from zeroconf import ServiceBrowser, Zeroconf

class EnphaseEnvoyListener:
    def add_service(self, zeroconf, type, name):
        info = zeroconf.get_service_info(type, name)
        print("Service %s added, service info: %s" % (name, info))

    def remove_service(self, zeroconf, type, name):
        print("Service %s removed" % (name,))

    def update_service(self, zeroconf, type, name):
        print("Service %s updated" % (name,))

zeroconf = Zeroconf()
listener = EnphaseEnvoyListener()
browser = ServiceBrowser(zeroconf, "_enphase-envoy._tcp.local.", listener)
try:
    input("Press enter to exit...\n\n")
finally:
    zeroconf.close()