Пример #1
0
"""
This module allows runtime creation and removal of links.
"""
__all__ = ["add_link", "remove_link"]

from core.jsr223.scope import scriptExtension
scriptExtension.importPreset(None)

try:
    from org.openhab.core.thing.link import ItemChannelLink
except:
    from org.eclipse.smarthome.core.thing.link import ItemChannelLink

import core
from core import osgi
from core.log import logging, LOG_PREFIX
from core.utils import validate_item, validate_channel_uid

ItemChannelLinkRegistry = osgi.get_service(
    "org.openhab.core.thing.link.ItemChannelLinkRegistry") or osgi.get_service(
        "org.eclipse.smarthome.core.thing.link.ItemChannelLinkRegistry")

ManagedItemChannelLinkProvider = osgi.get_service(
    "org.openhab.core.thing.link.ManagedItemChannelLinkProvider"
) or osgi.get_service(
    "org.eclipse.smarthome.core.thing.link.ManagedItemChannelLinkProvider")

log = logging.getLogger("{}.core.links".format(LOG_PREFIX))


def add_link(item_or_item_name, channel_uid_or_string):
Пример #2
0
]

from inspect import isclass
# from java.util import UUID

# try:
#     from org.openhab.core.automation import Rule as SmarthomeRule
# except:
#     from org.eclipse.smarthome.automation import Rule as SmarthomeRule

from core.log import getLogger, log_traceback
from core.jsr223.scope import SimpleRule, scriptExtension

LOG = getLogger("core.rules")

scriptExtension.importPreset("RuleSimple")

def rule(name=None, description=None, tags=None):
    """
    This decorator can be used with both functions and classes to create rules.

    See :ref:`Guides/Rules:Decorators` for a full description of how to use
    this decorator.

    Examples:
        .. code-block::

          @rule('name', 'description', ['tag1', 'tag2'])
          @rule('name', tags=['tag1', 'tag2'])
          @rule('name')
Пример #3
0
from core.jsr223.scope import itemRegistry, things, scriptExtension
scriptExtension.importPreset(None)  # fix for Jython > 2.7.0

import inspect
import json
from shlex import split

import java.util
from java.nio.file.StandardWatchEventKinds import ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY

try:
    from org.openhab.core.automation.util import TriggerBuilder
    from org.openhab.core.automation import Trigger
except:
    from org.eclipse.smarthome.automation.core.util import TriggerBuilder
    from org.eclipse.smarthome.automation import Trigger

try:
    from org.openhab.config.core import Configuration
except:
    from org.eclipse.smarthome.config.core import Configuration

try:
    from org.openhab.core.thing import ChannelUID, ThingUID, ThingStatus
    from org.openab.core.thing.type import ChannelKind
except:
    from org.eclipse.smarthome.core.thing import ChannelUID, ThingUID, ThingStatus
    from org.eclipse.smarthome.core.thing.type import ChannelKind

try:
    from org.eclipse.smarthome.core.types import TypeParser
Пример #4
0
* **DirectoryEventTrigger** - fires when a directory reports an Event **(implemented in Jython and requires S1566, 2.5M2 or newer)**
"""
try:
    # pylint: disable=unused-import
    import typing
    if typing.TYPE_CHECKING:
        from core.jsr223.scope import (itemRegistry as t_itemRegistry, things
                                       as t_things)
        from java.nio.file import WatchEvent
    # pylint: enable=unused-import
except:
    pass

from core.jsr223.scope import scriptExtension

scriptExtension.importPreset("RuleSupport")
from core.jsr223.scope import TriggerBuilder, Configuration, Trigger
from core.utils import validate_uid

from java.nio.file import StandardWatchEventKinds

ENTRY_CREATE = StandardWatchEventKinds.ENTRY_CREATE  # type: WatchEvent.Kind
ENTRY_DELETE = StandardWatchEventKinds.ENTRY_DELETE  # type: WatchEvent.Kind
ENTRY_MODIFY = StandardWatchEventKinds.ENTRY_MODIFY  # type: WatchEvent.Kind


def when(target):
    """
    This function decorator creates a ``triggers`` attribute in the decorated
    function, which is used by the ``rule`` decorator when creating the rule.
    The ``when`` decorator simplifies the use of many of the triggers in this
""" 
  
Occupancy Manager     
       
Used to handle events from items that are used to determine and control occupancy
 
Dispatches the events to the area manager
                                       
"""
import traceback

from core.jsr223.scope import scriptExtension
scriptExtension.importPreset("RuleSimple")
scriptExtension.importPreset("RuleSupport")
scriptExtension.importPreset("RuleFactories")
import core
from core.triggers import when
from core.rules import rule
from core import osgi
from core import items
from core.jsr223.scope import NULL

from core.log import logging, LOG_PREFIX
log = logging.getLogger("{}.occupancy_manager".format(LOG_PREFIX))

# load the area manager class
import personal.occupancy.areas.area_manager
reload(personal.occupancy.areas.area_manager)
from personal.occupancy.areas.area_manager import Area_Manager

#start the area manager