Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit d3f8d89

Browse files
committed
Merge branch 'pr/34'
Conflicts: netdisco/const.py
2 parents a18c896 + b7613de commit d3f8d89

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

netdisco/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
SABNZBD = 'sabnzbd'
1313
KODI = 'kodi'
1414
HOME_ASSISTANT = "home_assistant"
15+
MYSTROM = 'mystrom'

netdisco/discoverables/mystrom.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Discover myStrom devices."""
2+
from . import MDNSDiscoverable
3+
4+
5+
# pylint: disable=too-few-public-methods
6+
class Discoverable(MDNSDiscoverable):
7+
"""Add support for discovering myStrom switches."""
8+
9+
def __init__(self, nd):
10+
super(Discoverable, self).__init__(nd, '_hap._tcp.local.')
11+
12+
def info_from_entry(self, entry):
13+
"""Return the most important info from mDNS entries."""
14+
return (entry.properties.get(b'md').decode('utf-8'),
15+
'http://{}'.format(self.ip_from_host(entry.server)),
16+
entry.properties.get(b'id').decode('utf-8'))
17+
18+
def get_info(self):
19+
"""Get details from myStrom devices."""
20+
return [self.info_from_entry(entry) for entry in self.get_entries()]

0 commit comments

Comments
 (0)