Add mochad component (#3970)

This commit adds a new component for communicating with mochad[1] a
socket interface for the CM15A and CM19A USB X10 controllers. This
commit leverages the pymochad library to interface with a mochad socket
either on a local or remote machine. Mochad is added as as a generic
platform because it supports multiple different classes of device,
however in this patch only the switch device implemented as a starting
point. Future patches will include other devices types. (although
that's dependent on someone gaining access to those)

[1] https://sourceforge.net/projects/mochad/
This commit is contained in:
Matthew Treinish 2016-10-25 00:49:49 -04:00 committed by Paulus Schoutsen
parent 23f54b07c7
commit 0ff500ca25
7 changed files with 272 additions and 0 deletions

View file

@ -2,6 +2,7 @@
from collections import OrderedDict
from datetime import timedelta
import os
import re
from urllib.parse import urlparse
from socket import _GLOBAL_DEFAULT_TIMEOUT
@ -336,6 +337,14 @@ def url(value: Any) -> str:
raise vol.Invalid('invalid url')
def x10_address(value):
"""Validate an x10 address."""
regex = re.compile(r'([A-Pa-p]{1})(?:[2-9]|1[0-6]?)$')
if not regex.match(value):
raise vol.Invalid('Invalid X10 Address')
return str(value).lower()
def ordered_dict(value_validator, key_validator=match_all):
"""Validate an ordered dict validator that maintains ordering.