Beispiel #1
0
@name:      PyHouse/src/Modules/families/Null/Null_device.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2014-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Aug 6, 2014
@summary:   Used when no valid family exists

"""

# Import system type stuff

# Import PyMh files
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Null_device ')


class API(object):
    """
    """

    def __init__(self, p_pyhouse_obj):
        self.m_pyhouse_obj = p_pyhouse_obj

    def Start(self):
        pass

    def SaveXml(self, p_xml):
        return p_xml
Beispiel #2
0
@contact:   [email protected]
@copyright: (c) 2015-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Jun 28, 2015
@Summary:

"""


# Import system type stuff
import xml.etree.ElementTree as ET

# Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger("PyHouse.Communication  ")


class Utility(object):
    def read_xml(self, p_pyhouse_obj):
        """Read all the information.
        """
        self.m_count = 0
        l_dict = {}
        try:
            l_xml = p_pyhouse_obj.Xml.XmlRoot.find("ComputerDivision").find("CommunicationSection")
        except AttributeError as e_err:
            LOG.error("ERROR in read_xml() - {}".format(e_err))
        return l_dict

Beispiel #3
0
            HouseInformation, \
            HouseAPIs, \
            LocationData, \
            TwistedInformation, \
            XmlInformation
from Modules.Families.family import Utility as familyUtil, API as familyAPI
from Modules.Housing.house import API as housingAPI
from Modules.Computer import logging_pyh as Logger
#
#  Different logging setup to cause testing logs to come out in red on the console.
#
l_format = '\n [%(levelname)s] %(name)s: %(funcName)s %(lineno)s:\n\t%(message)s'
l_formatter = logging.Formatter(fmt = l_format)
l_handler = logging.StreamHandler(stream = sys.stderr)
l_handler.setFormatter(l_formatter)
LOG = Logger.getLogger('PyHouse')
LOG.addHandler(l_handler)


class XmlData(object):
    """
    Testing XML infrastructure
    """
    def __init__(self):
        self.root = None
        #
        self.house_div = None
        self.lighting_sect = None
        self.button_sect = None
        self.button = None
        self.controller_sect = None
Beispiel #4
0
@contact:   [email protected]
@copyright: (c) 2018-2018 by D. Brian Kimmel
@license:   MIT License
@note:      Created Jul 23, 2018
@Summary:

"""

__updated__ = '2018-07-23'

#  Import system type stuff

#  Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.State          ')


class State(object):
    UNKNOWN = 'unknown'
    OCCUPIED = 'occupied'
    VACANT = 'vacant'
    ON = 'on'
    OFF = 'off'
    MOTION = 'motion'
    STILL = 'still'
    OPEN = 'open'
    CLOSED = 'closed'

# ## END DBK
Beispiel #5
0
from Modules.Web import web_schedules
from Modules.Web import web_thermostats
#  from Modules.Web import web_houseSelect
from Modules.Computer import logging_pyh as Logger


#  Handy helper for finding external resources nearby.
modulepath = os.path.join(os.path.split(__file__)[0], '..')
webpath = os.path.join(os.path.split(__file__)[0])
csspath = os.path.join(webpath, 'css')
imagepath = os.path.join(webpath, 'images')
jspath = os.path.join(webpath, 'js')
templatepath = os.path.join(webpath, 'template')

g_debug = 0
LOG = Logger.getLogger('PyHouse.WebMainpage    ')


class FileNoListDir(static.File):

    def directoryListing(self):
        print("ERROR - web_mainpage.directoryListing() - Forbidden resource")
        #  return error.ForbiddenResource()


class FourOfour(athena.LiveElement):
    jsClass = u'mainPage.FourOfour'
    docFactory = loaders.xmlfile(os.path.join(templatepath, '404Element.html'))


class TheRoot(rend.Page):
Beispiel #6
0
@Summary:

"""

__updated__ = '2017-01-20'


# Import system type stuff
import os
from nevow import loaders
from nevow import athena

# Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.webCfgMenu  ')

# Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, 'template')


class ConfigMenuElement(athena.LiveElement):
    """
    """
    docFactory = loaders.xmlfile(os.path.join(templatepath, 'configMenuElement.html'))
    jsClass = u'configMenu.ConfigMenuWidget'

    def __init__(self, p_workspace_obj, p_params):
        self.m_workspace_obj = p_workspace_obj
        self.m_pyhouse_obj = p_workspace_obj.m_pyhouse_obj
Beispiel #7
0
Resources
    http://blog.vrplumber.com/b/2004/09/27/adding-user-authentication-to/

"""

#  Import system type stuff

#  Import PyMh files and modules.
from twisted.cred import checkers, credentials, error as credError, portal
from twisted.internet import defer, protocol
from twisted.protocols import basic
from zope.interface import Interface, implements
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.UserValidate   ')


class PyHouseRealm(object):
    """
    The realm is an interface which connects PyHouse's universe of �business objects� to the authentication system.

    """
    implements(portal.IRealm)

    def __init__(self, p_users):
        self.m_users = p_users

    def requestAvatar(self, p_avatarId, p_mind, *interfaces):
        """ The only method in the realm.
        This method will typically be called from "Portal.login". The avatarId is the one returned by a CredentialChecker.
Beispiel #8
0
@copyright: (c) 2015-2016 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Jun 4, 2015
@Summary:

"""

#  Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyMh files
from Modules.Core.data_objects import MqttBrokerData
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities.xml_tools import PutGetXML, XmlConfigTools

LOG = Logger.getLogger('PyHouse.Mqtt_Xml       ')
DIVISION = 'ComputerDivision'
SECTION = 'MqttSection'
BROKER = 'Broker'


class Xml(object):

    @staticmethod
    def _read_one_broker(p_xml):
        """
        @param p_xml: XML information for one Broker.
        @return: an IrrigationZone object filled in with data from the XML passed in
        """
        l_obj = MqttBrokerData()
        try:
Beispiel #9
0
@name:      PyHouse/src/Modules/Hvac/hvac_actions.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2015-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Sep 11, 2015
@Summary:

"""

# Import system type stuff

# Import PyMh files
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.HvacAction  ')


class API(object):
    """
    """
    @staticmethod
    def DoSchedule(p_pyhouse_obj, p_schedule_obj):
        pass

    @staticmethod
    def activate_zone(p_pyhouse_obj, p_zone_obj):
        pass


# ## END DBK
Beispiel #10
0
Once overridden the new role will "stick" by being written into the local XML file.
"""

#  Import system type stuff
import fnmatch  # Filename matching with shell patterns
import netifaces
import os
import platform

#  Import PyMh files and modules.
from Modules.Core.data_objects import NodeData, NodeInterfaceData
from Modules.Communication import ir_control
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities.uuid_tools import Uuid as toolUuid

LOG = Logger.getLogger('PyHouse.NodeLocal      ')


__all__ = ['NODE_NOTHING', 'NODE_LIGHTS',
           'NODE_PANDORA', 'NODE_CAMERA',
           'NODE_PIFACECAD', 'NODE_V6ROUTER',
           'API'
           ]


NODE_NOTHING = 0x0000  # a basic node with no special functions
NODE_LIGHTS = 0x0001  # Node has an attached controller for Lights (optionally other stuff)
NODE_PANDORA = 0x0002  # Node can use pianobar to receive Pandora streams
NODE_CAMERA = 0x0004  # Pi with attached camera (not USB camera)
NODE_PIFACECAD = 0x0008  #
NODE_V6ROUTER = 0x0010  # Iv6 Router node
Beispiel #11
0
# Import system type stuff
import os
from nevow import athena
from nevow import loaders

# Import PyMh files and modules.
# from Modules.Core.data_objects import WebData
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities import json_tools

# Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, 'template')

g_debug = 0
LOG = Logger.getLogger('PyHouse.webUpdate  ')


class UpdateElement(athena.LiveElement):
    """ a 'live' webs element.
    """
    docFactory = loaders.xmlfile(os.path.join(templatepath, 'updateElement.html'))
    jsClass = u'update.UpdateWidget'

    def __init__(self, p_workspace_obj, _p_params):
        self.m_workspace_obj = p_workspace_obj
        self.m_pyhouse_obj = p_workspace_obj.m_pyhouse_obj

    @athena.expose
    def getUpdateData(self):
        """ A JS client has requested all the webs information.
Beispiel #12
0
Instead of using callLater timers, it would be better to use deferred callbacks when data arrives.

"""

# Import system type stuff
import usb.core
import usb.util

# Import PyHouse modules
from Modules.Drivers.USB.Driver_USB_17DD_5500 import API as usb5500API
from Modules.Utilities.tools import PrintBytes
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities.debug_tools import PrettyFormatAny

LOG = Logger.getLogger('PyHouse.USBDriver_Open ')

# Timeouts for send/receive delays
RECEIVE_TIMEOUT = 0.3


class Utility(object):
    @staticmethod
    def format_names(p_USB_obj):
        """
        Printable Vendor, Product and controller name
        """
        l_ret = "{0:#04x}:{1:#04x} {2:}".format(p_USB_obj.Vendor,
                                                p_USB_obj.Product,
                                                p_USB_obj.Name)
        return l_ret
Beispiel #13
0
@summary:   Various XML functions and utility methods.

"""

#  Import system type stuff
from xml.etree import ElementTree as ET
import dateutil.parser as dparser
import datetime
import uuid

#  Import PyMh files
from Modules.Core.data_objects import CoordinateData
from Modules.Utilities import convert
from Modules.Utilities.uuid_tools import Uuid
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.XmlTools       ')


class XML(object):
    @staticmethod
    def get_element_field(p_xml, p_name):
        try:
            l_xml = p_xml.find(p_name).text
        except AttributeError:
            l_xml = None
        return l_xml

    @staticmethod
    def get_attribute_field(p_xml, p_name):
        """Attribute must be in the top element of the XML.
        """
Beispiel #14
0
This is for lighting type devices.

Lighting devices are a compound entry in the XML config file.
It is compound since a controller will contain Light entries, controller entries, interface entries etc.
"""

# Import system type stuff
from distutils.version import LooseVersion

# Import PyHouse files
from Modules.Utilities.device_tools import XML as deviceXML
from Modules.Utilities.xml_tools import PutGetXML, XmlConfigTools
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.LightingCore   ')


class API(object):

    @staticmethod
    def _read_device_v1_3(p_device_obj, p_entry_xml):
        """
        Read the XML file version 1.3 - convert to 1.4
        """
        p_device_obj.Comment = ''
        p_device_obj.DeviceFamily = PutGetXML.get_text_from_xml(p_entry_xml, 'ControllerFamily')
        p_device_obj.DeviceType = 1
        p_device_obj.DeviceSubType = 0
        p_device_obj.LightingType = PutGetXML.get_text_from_xml(p_entry_xml, 'LightingType')
        p_device_obj.RoomCoords = PutGetXML.get_coords_from_xml(p_entry_xml, 'Coords')
Beispiel #15
0
PyHouse.Computer.Web
            Logins
            Port
            SecurePort

"""

#  Import system type stuff

#  Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger
from Modules.Core.data_objects import LoginData, WebData
from Modules.Utilities.xml_tools import PutGetXML, XmlConfigTools
import xml.etree.ElementTree as ET
LOG = Logger.getLogger('PyHouse.WebXml         ')


class Xml(object):
    """
    """
    @staticmethod
    def _read_port(p_xml):
        """
        @param p_xml: is the web section
        @return: the Port Number
        """
        l_port = PutGetXML.get_int_from_xml(p_xml, 'WebPort', 8580)
        return l_port

    @staticmethod
Beispiel #16
0
Adds HVAC (Heating Ventilation Air Conditioning) to the Insteon suite.
Specifically developed for the Venstar 1-day programmable digital thermostat.
This contains an Insteon radio modem.

Models 2491T1E and 2491T7E = (2491TxE)

see: 2441xxx pdf guides

My Device seems to put out codes 6E thru 72
"""

#  Import system type stuff

#  Import PyMh files
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.InsteonHVAC    ')

FACTOR = 1.0  #  Multiplier to convert Thermostat units to Real World units
HALF = 0.5


class Util(object):
    """
    """

    def get_device_obj(self, p_pyhouse_obj, p_address):
        l_ret = self._find_addr(p_pyhouse_obj.House.Hvac.Thermostats, p_address)
        return l_ret


class ihvac_utility(object):
Beispiel #17
0
# Motion detection settings:
# Threshold (how much a pixel has to change by to be marked as "changed")
# Sensitivity (how many changed pixels before capturing an image)
# ForceCapture (whether to force an image to be captured every forceCaptureTime seconds)

# Import system type stuff
import StringIO
import subprocess
import os
import time
from datetime import datetime
# from PIL import Image

# Import PyMh files
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.SecurityCamera ')


FRAME_INTERVAL = 1000  # mili-seconds
MIN_PIXELS = 25
THRESHOLD = 10
SENSITIVITY = 20


forceCapture = True
forceCaptureTime = 60 * 60  # Once an hour

# File settings
saveWidth = 1280
saveHeight = 960
diskSpaceToReserve = 400 * 1024 * 1024  # Keep 400 mb free on disk
Beispiel #18
0
#  Import system type stuff
import copy
import datetime
from twisted.internet import defer
# from twisted.internet.endpoints import SSL4ClientEndpoint
# from twisted.internet.ssl import Certificate, optionsForClientTLS

#  Import PyMh files and modules.
from Modules.Core.data_objects import NodeData, MqttInformation, MqttJson
from Modules.Computer.Mqtt.mqtt_actions import Actions
from Modules.Computer.Mqtt.mqtt_protocol import PyHouseMqttFactory
from Modules.Computer.Mqtt.mqtt_xml import Xml as mqttXML
from Modules.Utilities import json_tools, xml_tools
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Mqtt_Client    ')

PEM_FILE = '/etc/pyhouse/ca_certs/rootCA.pem'


class Struct:
    def __init__(self, **args):
        self.__dict__.update(args)


class Util(object):
    """
    """
    def connect_to_one_broker_TCP(self, p_pyhouse_obj, p_broker):
        l_clientID = 'PyH-' + p_pyhouse_obj.Computer.Name
        l_host = p_broker.BrokerAddress
Beispiel #19
0
@note:      Created on Jun 30, 2015
@Summary:   Read/Write the Irrigation portions of the XML Configuration file.

This is a skeleton until we start the use of the data.  Things are just a placeholder for now.

"""

#  Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyMh files and modules.
from Modules.Core.data_objects import IrrigationSystemData, IrrigationZoneData
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities.xml_tools import PutGetXML, XmlConfigTools

LOG = Logger.getLogger('PyHouse.IrrigationXml  ')
DIVISION = 'HouseDivision'
SECTION = 'IrrigationSection'
SYSTEM = 'IrrigationSystem'
ZONE = 'Zone'


class Xml(object):
    """
    """

    @staticmethod
    def _read_one_zone(p_xml):
        """
        @param p_xml: XML information for one Zone.
        @return: an IrrigationZone object filled in with data from the XML passed in
Beispiel #20
0
__updated__ = '2018-07-16'

# Import system type stuff
import xml.etree.ElementTree as ET

# Import PyMh files
from Modules.Core.data_objects import UuidData, GarageDoorData, MotionSensorData, SecurityData
from Modules.Families.family_utils import FamUtil
from Modules.Housing.Security.pi_camera import API as cameraApi
from Modules.Core.Utilities.device_tools import XML as deviceXML
from Modules.Core.Utilities.uuid_tools import Uuid as UtilUuid
from Modules.Core.Utilities.xml_tools import PutGetXML
from Modules.Core.Utilities.debug_tools import PrettyFormatAny
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.Security       ')

# LOCATION = House.Security


class MqttActions(object):
    """
    """

    def __init__(self, p_pyhouse_obj):
        self.m_pyhouse_obj = p_pyhouse_obj

    def _get_field(self, p_message, p_field):
        try:
            l_ret = p_message[p_field]
        except KeyError:
Beispiel #21
0
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2015-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Aug 27, 2015
@Summary:

"""

# Import system type stuff

# Import PyMh files and modules.
from Modules.Rules.rules_xml import Xml as rulesXML
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.RulesXml       ')


class API(object):
    def __init__(self, p_pyhouse_obj):
        self.m_pyhouse_obj = p_pyhouse_obj

    def Start(self):
        l_count = 0
        LOG.info('{} Rules were loaded'.format(l_count))

    def Stop(self):
        pass

    def LoadXml(self, p_pyhouse_obj):
        """ Load the Mqtt xml info.
Beispiel #22
0
@date:       Created on Apr 27, 2016
@licencse:   MIT License
@summary:    Sync the nodes between all nodes.

"""

__updated__ = '2018-07-14'

#  Import system type stuff
import datetime

#  Import PyMh files and modules.
from Modules.Core.data_objects import NodeData
from Modules.Core.Utilities.debug_tools import PrettyFormatAny
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.NodeSync       ')

MINUTES = 60
HOURS = MINUTES * 60
INITIAL_DELAY = 15
REPEAT_DELAY = 4 * HOURS
TOPIC = 'computer/node/'


class NodeMessage():
    """
    """


class Util(object):
    """
Beispiel #23
0
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2014-2016 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Jul 29, 2014
@summary:   Read and write USB xml

"""

# Import system type stuff

# Import PyMh files
from Modules.Core.data_objects import SerialControllerData
from Modules.Utilities.xml_tools import PutGetXML
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.SerialXml      ')


class XML(object):
    """Read and write the interface information based in the interface type.
    """
    @staticmethod
    def read_interface_xml(p_controller_entry):
        l_serial = SerialControllerData()
        l_serial.BaudRate = PutGetXML.get_int_from_xml(p_controller_entry,
                                                       'BaudRate', 19200)
        l_serial.ByteSize = PutGetXML.get_int_from_xml(p_controller_entry,
                                                       'ByteSize', 8)
        l_serial.DsrDtr = PutGetXML.get_bool_from_xml(p_controller_entry,
                                                      'DsrDtr', False)
        l_serial.Parity = PutGetXML.get_text_from_xml(p_controller_entry,
Beispiel #24
0
import os
from nevow import athena
from nevow import loaders

#  Import PyMh files and modules.
from Modules.Core.data_objects import ScheduleBaseData
from Modules.Web.web_utils import JsonUnicode, GetJSONHouseInfo
from Modules.Computer import logging_pyh as Logger
from Modules.Scheduling import schedule

#  Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, 'template')

g_debug = 0
LOG = Logger.getLogger('PyHouse.webSchedule ')


class SchedulesElement(athena.LiveElement):
    """ a 'live' schedules element.
    """
    docFactory = loaders.xmlfile(os.path.join(templatepath, 'schedulesElement.html'))
    jsClass = u'schedules.SchedulesWidget'

    def __init__(self, p_workspace_obj, _p_params):
        self.m_workspace_obj = p_workspace_obj
        self.m_pyhouse_obj = p_workspace_obj.m_pyhouse_obj

    @athena.expose
    def getHouseData(self):
        l_house = GetJSONHouseInfo(self.m_pyhouse_obj)
Beispiel #25
0
    go to a Family_device module (or submodule).  There it gets translated to a controller
    specific emssage(s).  These Messages are then sent to a driver of the kind for that
    physical controller.  This is the driver for a serial controller.  It presents a serial
    interface reguardless of the electrical connection.

"""

#  Import system type stuff
import pyudev
from twisted.internet.protocol import Protocol
from twisted.internet.serialport import SerialPort

#  Import PyMh files
from Modules.Utilities.tools import PrintBytes
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.SerialDriver   ')
#  from Modules.Utilities.debug_tools import PrettyFormatAny


class FindPort(object):
    """
    """
    def __init__(self):
        #  l_devices = subprocess.call(['lsusb'])
        #  print l_devices
        l_context = pyudev.Context()
        for l_dev in l_context.list_devices(subsystem='tty'):
            if 'ID_VENDOR' not in l_dev:
                continue
            # print(l_dev.device_node)
            pass
Beispiel #26
0
@note:      Created on Jun 29, 2015
@Summary:

"""

__updated__ = '2018-02-13'

# Import system type stuff
import xml.etree.ElementTree as ET

# Import PyMh files
from Modules.Housing.Pool.pool_data import PoolData
from Modules.Core.Utilities.xml_tools import PutGetXML, XmlConfigTools
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Pool           ')


class Xml(object):

    @staticmethod
    def _read_base(p_pool_element):
        l_pool_obj = PoolData()
        XmlConfigTools.read_base_UUID_object_xml(l_pool_obj, p_pool_element)
        return l_pool_obj

    @staticmethod
    def _write_base(p_obj):
        l_entry = XmlConfigTools.write_base_UUID_object_xml('Pool', p_obj)
        return l_entry
Beispiel #27
0
@name:      PyHouse/src/Modules/Irrigation/irrigation_action.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2015-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Sep 3, 2015
@Summary:   Perform actions on the irrigation system.

"""

# Import system type stuff

# Import PyMh files
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.IrrigAction ')


class API(object):
    """
    """
    @staticmethod
    def DoSchedule(p_pyhouse_obj, p_schedule_obj):
        pass

    @staticmethod
    def activate_zone(p_pyhouse_obj, p_zone_obj):
        pass


# ## END DBK
Beispiel #28
0
"""

#  Import system type stuff
import random
from twisted.internet.protocol import Protocol, ReconnectingClientFactory
#  from twisted.internet import ssl
#  from twisted.internet.ssl import Certificate
from twisted.internet import error

#  Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger
from Modules.Computer.Mqtt.mqtt_util import EncodeDecode
#  from Modules.Utilities.tools import PrintBytes
#  from Modules.Utilities.debug_tools import PrettyFormatAny
LOG = Logger.getLogger('PyHouse.Mqtt_Protocol  ')
SUBSCRIBE = 'pyhouse/#'


class MQTTProtocol(Protocol):
    """
    This protocol is used for communication with the MQTT broker.
    """

    #  The first 4 bits of a MQTT packet are the packet type.
    _packetTypes = {0x00: "null", 0x01: "connect", 0x02: "connack",
                    0x03: "publish", 0x04: "puback", 0x05: "pubrec",
                    0x06: "pubrel", 0x07: "pubcomp", 0x08: "subscribe",
                    0x09: "suback", 0x0A: "unsubscribe", 0x0B: "unsuback",
                    0x0C: "pingreq", 0x0D: "pingresp", 0x0E: "disconnect"}
    m_buffer = bytearray()
Beispiel #29
0
"""
Created on Aug 23, 2014

@author: briank
"""

# Import system type stuff

# Import PyHouse Modules
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.NullDriver     ')


class API(object):

    def __init__(self, p_pyhouse_obj):
        self.m_pyhouse_obj = p_pyhouse_obj
        LOG.info(" Initializing Null Driver.")

    def Start(self, p_pyhouse_obj, p_controller_obj):
        self.m_pyhouse_obj = p_pyhouse_obj
        self.m_controller_obj = p_controller_obj

    def Stop(self):
        pass

    def Read(self):
        l_ret = ''
        return l_ret
Beispiel #30
0
@name:      PyHouse/src/Modules/Families/X10/X10_xml.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2014-2015 by D. Brian Kimmel
@note:      Created on Aug 6, 2014
@license:   MIT License
@summary:   This module is for Insteon/X10

"""

# Import system type stuff

# Import PyMh files
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.X10_xml      ')


class Xml(object):
    @staticmethod
    def ReadXml(p_device_obj, p_in_xml):
        pass

    @staticmethod
    def WriteXml(p_out_xml, p_device_obj):
        return p_out_xml


# ## END DBK
Beispiel #31
0
"""Ethernet_driver.py - Ethernet Driver module.

This will interface various PyHouse modules to an ethernet connected controller device.

This may be instanced as many times as there are serial devices to control.

This should also allow control of many different houses.
"""

# Import system type stuff

# Import PyHouse modules
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.USBDriver')


class API(object):
    def __init__(self, p_pyhouse_obj):
        self.m_pyhouse_obj = p_pyhouse_obj
        LOG.info(" Initializing Ethernet Driver.")

    def Start(self, p_pyhouse_obj, p_controller_obj):
        self.m_pyhouse_obj = p_pyhouse_obj
        self.m_controller_obj = p_controller_obj
        LOG.info("Starting Ethernet port.")
        return None

    def Stop(self):
        pass
Beispiel #32
0
@contact:   [email protected]
@copyright: (c) 2014-2016 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Sep 29, 2014
@Summary:

"""
#  Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyMh files and modules.
from Modules.Core.data_objects import InternetConnectionData
from Modules.Utilities.xml_tools import PutGetXML
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Internet_xml   ')


class Util(object):
    """
    This section is fairly well tested by the unit test module.
    """
    @staticmethod
    def _read_locates_xml(p_locater_sect_xml):
        l_dict = {}
        l_count = 0
        try:
            for l_xml in p_locater_sect_xml.iterfind('LocateUrl'):
                l_url = str(l_xml.text)
                l_dict[l_count] = l_url
                l_count += 1
Beispiel #33
0
import os
from nevow import athena
from nevow import loaders

#  Import PyMh files and modules.
from Modules.Core.data_objects import ThermostatData
from Modules.Web.web_utils import JsonUnicode, GetJSONHouseInfo
from Modules.Computer import logging_pyh as Logger
from Modules.Families.Insteon import Insteon_utils

#  Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, 'template')

g_debug = 0
LOG = Logger.getLogger('PyHouse.webThermost ')


class ThermostatsElement(athena.LiveElement):
    """ a 'live' thermostat element.
    """
    docFactory = loaders.xmlfile(
        os.path.join(templatepath, 'thermostatElement.html'))
    jsClass = u'thermostats.ThermostatsWidget'

    def __init__(self, p_workspace_obj, _p_params):
        self.m_workspace_obj = p_workspace_obj
        self.m_pyhouse_obj = p_workspace_obj.m_pyhouse_obj

    @athena.expose
    def getHouseData(self):
Beispiel #34
0
"""

#  Import system type stuff
import fnmatch  #  Filename matching with shell patterns
import netifaces
import os
import platform

#  Import PyMh files and modules.
from Modules.Core.data_objects import NodeData, NodeInterfaceData
from Modules.Communication import ir_control
from Modules.Computer import logging_pyh as Logger
#  from Modules.Utilities.debug_tools import PrettyFormatAny
#  from Modules.Utilities.debug_tools import PrettyFormatAny

LOG = Logger.getLogger('PyHouse.NodeLocal      ')


__all__ = ['NODE_NOTHING', 'NODE_LIGHTS',
           'NODE_PANDORA', 'NODE_CAMERA',
           'NODE_PIFACECAD', 'NODE_V6ROUTER',
           'API'
           ]


NODE_NOTHING = 0x0000  #  a basic node with no special functions
NODE_LIGHTS = 0x0001  #  Node has an attached controller for Lights (optionally other stuff)
NODE_PANDORA = 0x0002  #  Node can use pianobar to receive Pandora streams
NODE_CAMERA = 0x0004  #  Pi with attached camera (not USB camera)
NODE_PIFACECAD = 0x0008  #
NODE_V6ROUTER = 0x0010  #  Iv6 Router node
Beispiel #35
0
            Logins
            Port
            SecurePort
"""

__updated__ = '2018-01-27'

#  Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger
from Modules.Core.data_objects import LoginData, WebData
from Modules.Core.Utilities.uuid_tools import Uuid
from Modules.Core.Utilities.xml_tools import PutGetXML, XmlConfigTools
LOG = Logger.getLogger('PyHouse.WebXml         ')


class Xml(object):
    """
    """

    @staticmethod
    def _read_ports(p_xml):
        """
        @param p_xml: is the web section
        @return: the Port Number
        """
        l_port = PutGetXML.get_int_from_xml(p_xml, 'WebPort', 8580)
        l_secure = PutGetXML.get_int_from_xml(p_xml, 'SecurePort', 8580)
        l_socket = PutGetXML.get_int_from_xml(p_xml, 'SocketPort', 8580)
Beispiel #36
0
# Import system type stuff
try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

import subprocess
import os
import time
from datetime import datetime
# from PIL import Image

# Import PyMh files
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.SecurityCamera ')


FRAME_INTERVAL = 1000  # mili-seconds
MIN_PIXELS = 25
THRESHOLD = 10
SENSITIVITY = 20


forceCapture = True
forceCaptureTime = 60 * 60  # Once an hour

# File settings
saveWidth = 1280
saveHeight = 960
diskSpaceToReserve = 400 * 1024 * 1024  # Keep 400 mb free on disk
Beispiel #37
0
@summary:   Handle the location information for a house.

There is location information for the house.  This is for calculating the
time of sunrise and sunset.  Additional calculations may be added such
moon rise, tides, etc.
"""

#  Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyMh files
from Modules.Core.data_objects import LocationData, RiseSetData
from Modules.Core.Utilities.xml_tools import PutGetXML
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Location       ')


class Xml(object):
    """Use the internal data to read / write an updated XML config file.
    """

    @staticmethod
    def read_location_xml(p_pyhouse_obj):
        """
        @param p_house_xml: is the config file xml for a house.
        """
        l_obj = LocationData()
        l_obj.RiseSet = RiseSetData()
        p_pyhouse_obj.House.Location = l_obj
        try:
Beispiel #38
0
@name:      PyHouse/src/Modules/families/Null/Null_xml.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2014-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Aug 9, 2014
@summary:   This module is for communicating with invalid controllers.

"""

# Import system type stuff

# Import PyMh files
from Modules.Families.Null.Null_data import NullData
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Null_xml    ')

class Xml(object):

    @staticmethod
    def ReadXml(p_device_obj, _p_entry_xml):
        return p_device_obj

    @staticmethod
    def WriteXml(p_entry_xml, p_device_obj):
        pass

# ## END DBK
Beispiel #39
0
# Import system type stuff
import os
from nevow import athena
from nevow import loaders

# Import PyMh files and modules.
# from Modules.Core.data_objects import WebData
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities import json_tools

# Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, "template")

g_debug = 0
LOG = Logger.getLogger("PyHouse.webUpdate  ")


class UpdateElement(athena.LiveElement):
    """ a 'live' webs element.
    """

    docFactory = loaders.xmlfile(os.path.join(templatepath, "updateElement.html"))
    jsClass = u"update.UpdateWidget"

    def __init__(self, p_workspace_obj, _p_params):
        self.m_workspace_obj = p_workspace_obj
        self.m_pyhouse_obj = p_workspace_obj.m_pyhouse_obj

    @athena.expose
    def getUpdateData(self):
Beispiel #40
0
            HouseAPIs, \
            LocationData, \
            TwistedInformation, \
            XmlInformation, LightingData, UuidData
from Modules.Families.family import Utility as familyUtil, API as familyAPI
from Modules.Housing.house import API as housingAPI
# from Modules.Housing.house import Xml as housingXML
from Modules.Computer import logging_pyh as Logger
#
#  Different logging setup to cause testing logs to come out in red on the console.
#
l_format = '\n [%(levelname)s] %(name)s: %(funcName)s %(lineno)s:\n\t%(message)s'
l_formatter = logging.Formatter(fmt=l_format)
l_handler = logging.StreamHandler(stream=sys.stderr)
l_handler.setFormatter(l_formatter)
LOG = Logger.getLogger('PyHouse')
LOG.addHandler(l_handler)


class XmlData(object):
    """
    Testing XML infrastructure
    """
    def __init__(self):
        self.root = None
        #
        self.house_div = None
        self.lighting_sect = None
        self.button_sect = None
        self.button = None
        self.controller_sect = None
Beispiel #41
0
Reading the interface stuffs the interface XML data into the controller object.
"""

# Import system type stuff

# Import PyMh files
from Modules.Drivers.Ethernet.Ethernet_xml import XML as ethernetXML
from Modules.Drivers.Null.Null_xml import XML as nullXML
from Modules.Drivers.Serial.Serial_xml import XML as serialXML
from Modules.Drivers.USB.USB_xml import XML as usbXML
from Modules.Core.Utilities.xml_tools import stuff_new_attrs
from Modules.Computer import logging_pyh as Logging
# from Modules.Drivers import VALID_INTERFACES
# from Modules.Drivers import VALID_PROTOCOLS

LOG = Logging.getLogger('PyHouse.Interface      ')


class Xml(object):
    """Read and write the interface information based in the interface type.
    """

    @staticmethod
    def read_interface_xml(p_controller_obj, p_controller_xml):
        """Update the controller object by extracting the passed in XML.

        This is basically a dispatcher.

        @param p_controller_obj: This is the object we are going to stuff the interface info into.
        """
        if p_controller_obj.InterfaceType == 'Ethernet':
__updated__ = '2018-10-17'
__version_info__ = (18, 10, 1)
__version__ = '.'.join(map(str, __version_info__))

# Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyMh files and modules.
from Modules.Housing.Entertainment.entertainment_data import \
        EntertainmentData, \
        EntertainmentPluginData, \
        EntertainmentDeviceControl
from Modules.Core.Utilities.xml_tools import XmlConfigTools  # , PutGetXML
# from Modules.Core.Utilities.debug_tools import PrettyFormatAny
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.EntertainXML   ')


class XML:
    """
    """

    def LoadXml(self, p_pyhouse_obj):
        """ Read the entertainment section.
        Everything present in the XML must be read into the pyhouse_obj structure.

        SubSections not active will not be loaded or instantiated.

        If a subsection is available, load its module and let it read the xml for itself.

        @return: the Entertainment object of PyHouse_obj
Beispiel #43
0
@contact:   [email protected]
@copyright: (c) 2017-2018 by D. Brian Kimmel
@note:      Created on Jan 9, 2017
@license:   MIT License
@summary:

"""

__updated__ = '2018-03-26'

# Import system type stuff
import xml.etree.ElementTree as ET

# Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.Communication  ')


class Utility(object):

    def read_xml(self, p_pyhouse_obj):
        """Read all the information.
        """
        self.m_count = 0
        l_dict = {}
        try:
            _l_xml = p_pyhouse_obj.Xml.XmlRoot.find('ComputerDivision').find('CommunicationSection')
        except AttributeError as e_err:
            LOG.error('ERROR in read_xml() - {}'.format(e_err))
        return l_dict
Beispiel #44
0
Several other Insteon modules are included by this and are invisible to the other families.

This module loads the information about all the Insteon devices.

InsteonControllers
serial_port

"""

#  Import system type stuff

#  Import PyMh files
#  from Modules.Core.data_objects import NodeData
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.Insteon_Device ')


class Utility(object):
    """
    """
    @staticmethod
    def _is_insteon(p_obj):
        try:
            return p_obj.DeviceFamily == 'Insteon'
        except AttributeError:
            return False

    @staticmethod
    def _is_active(p_obj):
        try:
Beispiel #45
0
"""

#  Import system type stuff
import random
from twisted.internet.protocol import Protocol, ReconnectingClientFactory
#  from twisted.internet import ssl
#  from twisted.internet.ssl import Certificate
from twisted.internet import error

#  Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger
from Modules.Computer.Mqtt.mqtt_util import EncodeDecode
#  from Modules.Utilities.tools import PrintBytes
#  from Modules.Utilities.debug_tools import PrettyFormatAny
LOG = Logger.getLogger('PyHouse.Mqtt_Protocol  ')
SUBSCRIBE = 'pyhouse/#'


class MQTTProtocol(Protocol):
    """
    This protocol is used for communication with the MQTT broker.
    """

    #  The first 4 bits of a MQTT packet are the packet type.
    _packetTypes = {0x00: "null", 0x01: "connect", 0x02: "connack",
                    0x03: "publish", 0x04: "puback", 0x05: "pubrec",
                    0x06: "pubrel", 0x07: "pubcomp", 0x08: "subscribe",
                    0x09: "suback", 0x0A: "unsubscribe", 0x0B: "unsuback",
                    0x0C: "pingreq", 0x0D: "pingresp", 0x0E: "disconnect"}
    m_buffer = bytearray()
Beispiel #46
0
"""
@name:      PyHouse/src/Modules/Core/setup_windows.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2015-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Oct 21, 2015
@Summary:

This is not really used - here for symmetery in case someone feels like making a windows version

"""

#  Import system type stuff
import platform

#  Import PyMh files and modules.
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.WindowsSetup   ')


class Windows(object):
    """
    """

    def __init__(self):
        pass

#  ## END DBK
Beispiel #47
0
Some convert things like addresses '14.22.A5' to a int for ease of handling.

"""

#  Import system type stuff

#  Import PyMh files
from Modules.Core import conversions
from Modules.Families.Insteon.Insteon_data import InsteonData
from Modules.Families.Insteon.Insteon_constants import MESSAGE_LENGTH, NAK
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities.tools import PrintBytes
from Modules.Core.data_objects import DeviceData
from Modules.Utilities import device_tools

LOG = Logger.getLogger('PyHouse.Insteon_Utils  ')


class Util(object):

    @staticmethod
    def int2message(p_int, p_message, p_index = 3):
        """Place an Insteon address (int internally) into a message at a given offset.
        The message must exist and be long enough to include a 3 byte area for the address.
        """
        if p_int > 16777215 or p_int < 0:
            l_msg = 'ERROR - Insteon_utils - trying to convert {} to message byte string.'.format(p_int)
            LOG.error(l_msg)
            p_int = 0xBADBAD
        l_ix = 256 * 256
        l_int = p_int
Beispiel #48
0
Since PyHouse is always running (as a daemon) this module will get the IP-v4 address that is
assigned to our router by the ISP.
It will then take that IP address and update our Dynamic DNS provider(s) so we may browse to that
address from some external device and check on the status of the house.
"""

# Import system type stuff
from twisted.application import service

# Import PyMh files and modules.
from Modules.Computer.Internet.internet_xml import API as internetAPI
from Modules.Computer.Internet import inet_find_external_ip, inet_update_dyn_dns
from Modules.Computer import logging_pyh as Logger


LOG = Logger.getLogger('PyHouse.Internet       ')
INITIAL_DELAY = 5
REPEAT_DELAY = 2 * 60 * 60



class Utility(object):
    """
    """

    m_pyhouse_obj = None
    m_snarAPI = None
    m_freednsAPI = None


    def _start_internet_discovery(self, _p_pyhouse_obj):
Beispiel #49
0
from Modules.Core.Utilities.convert import long_to_str

__updated__ = '2018-02-10'

# Import system type stuff
import jsonpickle
from queue import Queue
import time
from twisted.web.client import Agent
from twisted.web.http_headers import Headers
from twisted.internet.defer import Deferred
from twisted.internet.protocol import Protocol

# Import PyMh files
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.Hue_Hub        ')

SEND_TIMEOUT = 0.8
mac = [ '00', '17', '88', '10', '22', '01' ]
uid = '2f402f80-da50-11e1-9b23-%s' % ''.join(mac)
icon = 'hue.png'
description_xml = 'description.xml'
lights = []
username = "******"
devicetype = "something"
portalservices = False


def gen_ts():
    return time.strftime('%Y-%m-%dT%H:%M:%S')
Beispiel #50
0
@name:      PyHouse/src/Modules/Security/security.py
@author:    D. Brian Kimmel
@contact:   [email protected]
@copyright: (c) 2015-2016 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Jun 29, 2015
@Summary:

"""

# Import system type stuff

# Import PyMh files
from Modules.Security.pi_camera import API as cameraApi
from Modules.Computer import logging_pyh as Logger
LOG = Logger.getLogger('PyHouse.Security       ')


class API(object):
    """ Called from house.

    """

    m_pyhouse_obj = None

    def __init__(self, p_pyhouse_obj):
        self.m_pyhouse_obj = p_pyhouse_obj
        self.m_api = cameraApi(p_pyhouse_obj)
        LOG.info('Initialized')

    def LoadXml(self, p_pyhouse_obj):
Beispiel #51
0
@note:      Created on Nov 11, 2014
@Summary:   Handle lighting scheduled events.

This module will handle all scheduled events for the Lighting system of a house.
This is so other modules only need to dispatch to here for any lighting event - scene, theme or whatever.

"""

#  Import system type stuff

#  Import PyMh files
from Modules.Families.family_utils import FamUtil
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities import tools, json_tools

LOG = Logger.getLogger('PyHouse.LightAction    ')

SECONDS_IN_WEEK = 604800  #  7 * 24 * 60 * 60


class Utility(object):
    """
    """

    @staticmethod
    def _find_full_obj(p_pyhouse_obj, p_web_obj):
        """ Given the limited information from the web browser, look up and return the full object.
        If more than one device has the same name, return the first one found.
        """
        for l_light in p_pyhouse_obj.House.Lighting.Lights.itervalues():
            if p_web_obj.Name == l_light.Name:
"""

__updated__ = '2017-03-26'

#  Import system type stuff
import xml.etree.ElementTree as ET

#  Import PyHouse files
from Modules.Core.data_objects import ButtonData
from Modules.Families.family_utils import FamUtil
from Modules.Computer import logging_pyh as Logging
from Modules.Core.Utilities.device_tools import XML as deviceXML
# from Modules.Core.Utilities.xml_tools import PutGetXML, XmlConfigTools

LOG = Logging.getLogger('PyHouse.LightingButton ')


""" Data

    x_pyhouse_obj.House.Lighting.Buttons.
                    BaseUUIDObject
                    DeviceObject
"""

class Utility(object):

    @staticmethod
    def _read_base_device(p_pyhouse_obj, p_xml):
        """
        @param p_xml: is the XML Element for the entire device
Beispiel #53
0
@copyright: (c) 2012-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Mar 20, 2012
@summary:   This module sends our external IP to freedns.

"""

# Import system type stuff
from twisted.web.client import getPage
from twisted.internet.defer import Deferred

# Import PyMh files and modules.
from Modules.Computer import logging_pyh

g_debug = 1
LOG = logging_pyh.getLogger('PyHouse.Internet    ')
INITIAL_DELAY = 1 * 60


class DynDnsAPI(object):
    """Update zero or more dynamic DNS sites.
    This is a repeating two stage process.
    First get our current External IP address.
    Second, update zero or more Dyn DNS sites with our address
    Then wait UpdateInterval time and repeat forever.
    Allow for missing responses so as to not break the chain of events.
    """
    def XX__init__(self, p_internet_obj, p_reactor):
        """
        Wait a bit to avoid all the starting chaos.
        """
Beispiel #54
0
#  Import PyMh files and modules.
from Modules.Core.data_objects import ControllerData
from Modules.Web.web_utils import GetJSONHouseInfo
from Modules.Drivers import VALID_INTERFACES
from Modules.Computer import logging_pyh as Logger
from Modules.Families.Insteon import Insteon_utils
from Modules.Utilities import json_tools


#  Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, 'template')

g_debug = 0
LOG = Logger.getLogger('PyHouse.webCntlr    ')



class ControllersElement(athena.LiveElement):
    """ a 'live' controllers element.
    """
    docFactory = loaders.xmlfile(os.path.join(templatepath, 'controllersElement.html'))
    jsClass = u'controllers.ControllersWidget'

    def __init__(self, p_workspace_obj, _p_params):
        self.m_workspace_obj = p_workspace_obj
        self.m_pyhouse_obj = p_workspace_obj.m_pyhouse_obj

    @athena.expose
    def getHouseData(self):
Beispiel #55
0
@copyright: (c) 2014-2015 by D. Brian Kimmel
@license:   MIT License
@note:      Created on Sep 2, 2013
@summary:   Schedule events

"""

# Import system type stuff
import xml.etree.ElementTree as ET

# Import PyMh files
from Modules.Core.data_objects import ScheduleBaseData, ScheduleLightData
from Modules.Utilities.xml_tools import XmlConfigTools, PutGetXML, stuff_new_attrs
from Modules.Computer import logging_pyh as Logger

LOG = Logger.getLogger('PyHouse.ScheduleXml ')


class Xml(object):

    @staticmethod
    def _read_one_lighting_schedule(p_schedule_element):
        """Extract schedule information from a schedule xml element.
        """
        l_obj = ScheduleLightData()
        l_obj.Level = PutGetXML.get_int_from_xml(p_schedule_element, 'Level')
        l_obj.LightName = PutGetXML.get_text_from_xml(p_schedule_element, 'LightName')
        l_obj.Rate = PutGetXML.get_int_from_xml(p_schedule_element, 'Rate')
        l_obj.RoomName = PutGetXML.get_text_from_xml(p_schedule_element, 'RoomName')
        return l_obj  # for testing
Beispiel #56
0
/srv/backup/home/briank/svn/smarthouse/trunk/Modules/parts/upb/usbhidserial.cpp

"""

# Import system type stuff
import Queue

# Import PyMh files
from Modules.Families.UPB.UPB_data import UPBData
from Modules.Families.UPB.UPB_constants import pim_commands
from Modules.Utilities.tools import PrintBytes
from Modules.Computer import logging_pyh as Logger
from Modules.Families.family_utils import FamUtil
from Modules.Utilities.debug_tools import PrettyFormatAny

LOG = Logger.getLogger('PyHouse.UPB_PIM        ')

# UPB Control Word
# Page 15
LINK_PKT = 0x80
LOW_REQ = 0x02

ACK_REQ = 0x10
ACK_ID = 0x20
ACK_MSG = 0x40

# Timeouts for send/receive delays
SEND_TIMEOUT = 0.8
RECEIVE_TIMEOUT = 0.9  # this is for fetching data in the RX buffer

# Command types
Beispiel #57
0
@note:      Created on Jun 18, 2015
@Summary:

"""
# Import system type stuff
import os
from nevow import athena
from nevow import loaders

# Import PyMh files and modules.
from Modules.Core.data_objects import MqttBrokerData
from Modules.Web.web_utils import JsonUnicode, GetJSONComputerInfo
from Modules.Computer import logging_pyh as Logger
from Modules.Utilities.uuid_tools import Uuid

LOG = Logger.getLogger('PyHouse.webMqtt     ')

# Handy helper for finding external resources nearby.
webpath = os.path.join(os.path.split(__file__)[0])
templatepath = os.path.join(webpath, 'template')


class MqttElement(athena.LiveElement):
    """ a 'live' thermostat element.
    """
    docFactory = loaders.xmlfile(os.path.join(templatepath,
                                              'mqttElement.html'))
    jsClass = u'mqtt.MqttWidget'

    def __init__(self, p_workspace_obj, _p_params):
        self.m_workspace_obj = p_workspace_obj