caspia.pan.rules package¶
Submodules¶
caspia.pan.rules.base module¶
-
class
caspia.pan.rules.base.RuleActivator(rule)[source]¶ Bases:
objectImplements some rule logic.
-
WARMUP_DURATION= 120.0¶
-
running_status(message=None)[source]¶ Set status to RUNNING and then to FAILURE or READY (contextmanager).
-
property
state¶ Tuple of RuleState and optional message.
-
caspia.pan.rules.blindscontrol module¶
-
class
caspia.pan.rules.blindscontrol.BlindsControl(name, storage)[source]¶ Bases:
caspia.meadow.client.gateway.ServiceGatewayMixin,caspia.meadow.services.blindscontrol.BlindsControlBaseInitialize new service.
- Parameters
name – Name of the service (or just its path)
include – What optional characteristics to include. Tuple of their names.
-
class
Mode¶ Bases:
enum.EnumAn enumeration.
-
BLOCK_DIRECT_SUN_DOWN= 'block-direct-sun-or-down'¶
-
BLOCK_DIRECT_SUN_UP= 'block-direct-sun-or-up'¶
-
MANUAL= 'manual'¶
-
-
property
all_observables¶
-
attach(connection)¶
-
property
attached¶
-
auto_discovery= True¶
-
characteristic_cached_read(characteristic)¶
-
characteristic_cached_write(characteristic, value_and_meta)¶
-
async
characteristic_read(characteristic, **kwargs)[source]¶ Read value of the characteristic.
- Parameters
characteristic – The characteristic to which the value should be written.
value – The value to be written.
kwargs – Dictionary with extra key (dictionary with metadata) and optionally a timeout (float specifing explicit timeout for the operation).
- Returns
Tuple (value, extra).
-
characteristic_subscribe(characteristic, on_value, on_error=None)¶
-
async
characteristic_write(characteristic, value, **kwargs)[source]¶ Write a value to the characteristic.
- Parameters
characteristic – The characteristic to which the value should be written.
value – The value to be written.
kwargs – Dictionary with extra key (dictionary with metadata) and optionally a timeout (float specifing explicit timeout for the operation).
-
characteristics= {'$metadata': <Characteristic <class 'caspia.meadow.services.base.ServiceMeta'>:$metadata>, 'mode': <Characteristic <class 'caspia.meadow.services.base.ServiceMeta'>:mode>}¶
-
detach()¶
-
static
get_subclass(stype, mixin=None)¶
-
load_definition(spec)¶ Update characteristics of this instance based on serialized specs.
- Parameters
spec – Dict most likely going to be coming from meadow - from some gateway informing us about its services and their characteristics.
-
metadata¶
-
mode¶
-
async
notify(characteristic, value, if_changed=False, extra=None)¶
-
on(name, *args, **kwargs)¶
-
optional= {}¶
-
async
published()¶
-
serialize()¶ Return serialized version (most likely dict) if possible or None.
-
type= 'blinds-control'¶
-
class
caspia.pan.rules.blindscontrol.BlindsControlRule(horizontal_view, vertical_view, blinds_seg_width, blinds_seg_spacing, blinds, sun=None, identifier=None)[source]¶ Bases:
caspia.meadow.rules.base.RuleIdentifier will become the BlindsControl’s service name. Name of the rule will be filled automatically.
-
build_identifier()¶ Builds unique identifier for this rule.
-
classmethod
deserialize(data, context)¶
-
enable_duplicates= False¶
-
property
identifier¶
-
serialize()¶ Return serialized version (most likely dict) if possible or None.
-
serialize_content()¶ Subclasses should override this and return serialized
self. If the instance cannot be serialized, return None. identifer key must not be included.
-
serialized_type= None¶
-
-
class
caspia.pan.rules.blindscontrol.BlindsControlRuleActivator(rule)[source]¶ Bases:
caspia.pan.rules.base.RuleActivator-
WARMUP_DURATION= 120.0¶
-
async
activate(warmup=True)¶ Activate the rule.
-
async
deactivate()¶ Deactivate the rule.
-
do_control¶
-
running_status(message=None)¶ Set status to RUNNING and then to FAILURE or READY (contextmanager).
-
property
state¶ Tuple of RuleState and optional message.
-
-
class
caspia.pan.rules.blindscontrol.Calc[source]¶ Bases:
object-
static
blinds_blocking_angle(width, spacing, angle)[source]¶ Given a current position of a sun and size of blind’s segments, calculate the minimum blind’s angle blocking all sunlight.
-
static
blinds_current_view(width, spacing, angle)[source]¶ Given blind’s width, spacing and current angle, calculate the view from inside out. :param width: width of the blind’s segments :param spacing: vertical spacing of segments :param angle: current angle of the segments in radians :returns: range of vertical view (tuple of two angles)
-
static
caspia.pan.rules.lightgroup module¶
-
class
caspia.pan.rules.lightgroup.LightGroupAttachRuleActivator(rule)[source]¶ Bases:
caspia.pan.rules.base.RuleActivator-
WARMUP_DURATION= 120.0¶
-
async
activate(warmup=True)¶ Activate the rule.
-
async
deactivate()¶ Deactivate the rule.
-
running_status(message=None)¶ Set status to RUNNING and then to FAILURE or READY (contextmanager).
-
property
state¶ Tuple of RuleState and optional message.
-
caspia.pan.rules.on_do module¶
-
class
caspia.pan.rules.on_do.OnDoRuleActivator(rule)[source]¶ Bases:
caspia.pan.rules.base.RuleActivator-
RETRY_DELAY= 5.0¶
-
RETRY_DELAY_MAX= 300.0¶
-
WARMUP_DURATION= 120.0¶
-
async
activate(warmup=True)¶ Activate the rule.
-
async
deactivate()¶ Deactivate the rule.
-
evaluation¶
-
running_status(message=None)¶ Set status to RUNNING and then to FAILURE or READY (contextmanager).
-
property
state¶ Tuple of RuleState and optional message.
-
caspia.pan.rules.thermostat module¶
-
class
caspia.pan.rules.thermostat.ThermostatRuleActivator(rule)[source]¶ Bases:
caspia.pan.rules.base.RuleActivator-
WARMUP_DURATION= 120.0¶
-
async
activate(warmup=True)¶ Activate the rule.
-
async
deactivate()¶ Deactivate the rule.
-
running_status(message=None)¶ Set status to RUNNING and then to FAILURE or READY (contextmanager).
-
property
state¶ Tuple of RuleState and optional message.
-