Home2L - Python API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home
Main API

Description

Top-level functionality of the Resources library - most commonly used functions can be found here.

Collaboration diagram for Main API:

Accessing resources ...

def RcGetResource (uri, allowWait=False)
 
def RcGet (uri, allowWait=False)
 
def RcGarbageCollection ()
 
def RcBump (rc=None, soft=False)
 

Subscriptions (from C/C++ API) ...

Low-level operations to directly create and use CRcSubscriber objects.

Most probably, you will not need these functions. The preferred way in Python is to use the more compfortable decorators and operations in section "Subscriptions, events and timers (Python API)" below.

def RcNewSubscriber (*args)
 
def RcSubscribe (*args)
 
def RcUnsubscribeFromAll (subscr)
 

Placing requests ...

Details on the request arguments can be found in the C/C++ API documentation and the Home2L Book.

def RcSetRequest (rc, reqDef=None, attrs=None, value=None, id=None, priority=None, t0=None, t1=None, repeat=None, hysteresis=None, delDelay=None)
 
def RcSetTrigger (rc, attrs=None, id=None, priority=None, t0=None, t1=None, repeat=None, hysteresis=None)
 
def RcDelRequest (rc, id=None, t1=None)
 
def RcSetDefault (rc, reqDef=None, attrs=None, value=None, t0=None, t1=None, repeat=None, hysteresis=None, delDelay=None)
 

Drivers (from C/C++ API) ...

Low-level operations to directly create and use 'CRcDriver' objects.

Most probably, you will not need these functions. The preferred way in Python is to use the more compfortable decorators and operations in module "Home2L / Drivers".

def RcRegisterDriver (drvLid, _successState=rcsNoReport)
 
def RcRegisterResource (*args)
 
def RcRegisterSignal (*args)
 

Function Documentation

◆ RcGetResource()

def home2l.RcGetResource (   uri,
  allowWait = False 
)
RcGetResource(char const * uri, bool allowWait=False) -> CResource
Lookup a resource by its URI and return a reference to it.

◆ RcGet()

def home2l.RcGet (   uri,
  allowWait = False 
)
RcGet(char const * uri, bool allowWait=False) -> CResource
Lookup a resource by its URI and return a reference to it (shortcut for 'RcGetResource()').

◆ RcGarbageCollection()

def home2l.RcGarbageCollection ( )
RcGarbageCollection()

◆ RcBump()

def home2l.RcBump (   rc = None,
  soft = False 
)
RcBump(CResource rc=None, bool soft=False)

◆ RcNewSubscriber()

def home2l.RcNewSubscriber ( args)
RcNewSubscriber(char const * subscrLid, CResource rc=None) -> CRcSubscriber
RcNewSubscriber(char const * subscrLid, char const * pattern) -> CRcSubscriber
Create and register a new subscriber object, optionally subscribe to resources.

◆ RcSubscribe()

def home2l.RcSubscribe ( args)
RcSubscribe(CRcSubscriber subscr, CResource rc) -> CRcSubscriber
RcSubscribe(CRcSubscriber subscr, char const * pattern) -> CRcSubscriber

◆ RcUnsubscribeFromAll()

def home2l.RcUnsubscribeFromAll (   subscr)
RcUnsubscribeFromAll(CRcSubscriber subscr)
Unsubscribe to all resources managed by the subscriber.

◆ RcSetRequest()

def home2l.RcSetRequest (   rc,
  reqDef = None,
  attrs = None,
  value = None,
  id = None,
  priority = None,
  t0 = None,
  t1 = None,
  repeat = None,
  hysteresis = None,
  delDelay = None 
)
Set a request to a resource with selected attributes.

The attributes can be set in a flexible way, either by (named) function arguments
or by a textual description as accepted by the Home2L Shell or CRcRequest::SetFromStr().

The parameters have the following meanings:

- reqDef = full definition as a single string '<val> [<attrs>]' or just the value
           Note: To avoid ambiguities, values of type string should never be passed by this,
                 but by the 'value' and 'attrs' arguments instead.
           If 'reqDef' is not a string instance, it is used as a value ('val').
- attrs  = attribute string (similar to 'reqDef', but without the first field interpreted as value)

- value      = value (any type or string)
- id         = request ID [default = instance name]
- priority   = request priority (0..9) [default = 3 (= rcPrioNormal)]
- t0         = on time
- t1         = off time
- repeat     = repetition interval
- hysteresis = hysteresis time
- delDelay   = deletion delay (if no value is passed and the call is used to delete the request)

Information on the syntax of textual request definition can be found in the Home2L Book and
in the C/C++ API documentation for CRcRequest::SetFromStr(). Arguments representing absolute times
(e.g. 't0', 't1') can have any type and format as accepted by 'TicksAbsOf()'.
Arguments representing relative times (e.g. 'repeat', 'hysteresis', 'delDelay') can have any type
and format as accepted by 'TicksRelOf()'.

If an attribute is set both by means of a string ('reqDef' or 'attrs') or a named parameter,
the named parameter is taken. If no attributes are specified, their defaults as specified in [...]
above are used.

If the effective value is 'None' (no value is passed), the call will delete the request with
the specified ID passing 'delDelay' as the the 't1' argument of RcDelRequest().

Examples:

- Request integer value 7 with default attributes:
    RcSetRequest (rc, 7);
    RcSetRequest (rc, '7');
    RcSetRequest (rc, value = '7');
    RcSetRequest (rc, reqDef = '7');

- Request integer value 7 with ID '#user' and priority 3:
    RcSetRequest (rc, 7, id = 'user', priority = 3);
    RcSetRequest (rc, 7, '#user *3');
    RcSetRequest (rc, '7 #user *3');

- Delete this request again:
    RcSetRequest (rc, value = None, id = 'user');
    RcSetRequest (rc, '? #user');

- Delete this request in 5 seconds:
    RcSetRequest (rc, value = None, id = 'user', delDelay = '5s');

- Request string value 'Hello *3' with priority 5 and an off time at 6pm today:
    RcSetRequest (rc, value = 'Hello *3', attrs = '*5 -18:00');
    RcSetRequest (rc, value = 'Hello *3', prio = 5, t1 = '-18:00');

- Set request with user-supplied attributes, some of which must not be changed by user
    RcSetRequest (rc, 7, userAttrs, t1 = '-23:00')    # t1 overrides an eventual off time in userAttrs

- Set request with user-supplied attributes and defaults
    req = CRcRequest (val = 7, t1 = '-23:00')       # Set value and default attributes
    req->Set (attrs = userAttrs)     # userAttrs may override t1

◆ RcSetTrigger()

def home2l.RcSetTrigger (   rc,
  attrs = None,
  id = None,
  priority = None,
  t0 = None,
  t1 = None,
  repeat = None,
  hysteresis = None 
)
Set a request to a trigger resource with selected attributes.

◆ RcDelRequest()

def home2l.RcDelRequest (   rc,
  id = None,
  t1 = None 
)
Delete a request.

◆ RcSetDefault()

def home2l.RcSetDefault (   rc,
  reqDef = None,
  attrs = None,
  value = None,
  t0 = None,
  t1 = None,
  repeat = None,
  hysteresis = None,
  delDelay = None 
)
Set a default request.

◆ RcRegisterDriver()

def home2l.RcRegisterDriver (   drvLid,
  _successState = rcsNoReport 
)
RcRegisterDriver(char const * drvLid, ERcState _successState=rcsNoReport) -> CRcEventDriver
Register a new driver.

◆ RcRegisterResource()

def home2l.RcRegisterResource ( args)
RcRegisterResource(char const * drvLid, char const * rcLid, ERcType _type, bool _writable, void * _data=None) -> CResource
RcRegisterResource(char const * drvLid, char const * rcLid, char const * rcTypeDef, void * _data=None) -> CResource
Register a new resource to a driver.

◆ RcRegisterSignal()

def home2l.RcRegisterSignal ( args)
RcRegisterSignal(char const * name, ERcType type) -> CResource
RcRegisterSignal(char const * name, CRcValueState vs) -> CResource
Register a new signal for the built-in 'signal' driver.