3 """Most basic definition of a smart device: it must have a name and a
4 MAC address and may have some optional keywords. All devices have
5 these whether they are lights, outlets, thermostats, etc..."""
8 from typing import List, Optional
14 """Most basic definition of a smart device: it must have a name and a
15 MAC address and may have some optional keywords. All devices have
16 these whether they are lights, outlets, thermostats, etc..."""
22 keywords: Optional[str] = "",
26 self.keywords = keywords
27 self.arper = arper.Arper()
28 if keywords is not None:
29 self.kws: List[str] = keywords.split(' ')
33 def get_name(self) -> str:
36 def get_mac(self) -> str:
39 def get_ip(self) -> Optional[str]:
40 return self.arper.get_ip_by_mac(self.mac)
42 def has_static_ip(self) -> bool:
44 m = re.search(r'static:([\d\.]+)', kw)
47 assert self.get_ip() == ip
51 # Add command -> URL logic here.
53 def get_keywords(self) -> Optional[List[str]]:
56 def has_keyword(self, keyword: str) -> bool:
62 def get_on_limit_seconds(self) -> Optional[int]:
64 m = re.search(r"timeout:(\d+)", kw)
66 return int(m.group(1)) * 60