Class reference

Reference for returned classes from some functions. These are not intended to be created by the user.

Watches

ItemNoUpdateWatch

class ItemNoUpdateWatch(name, secs)
EVENT

alias of ItemNoUpdateEvent

cancel()

Cancel the item watch

listen_event(callback)

Listen to (only) the event that is emitted by this watcher

ItemNoChangeWatch

class ItemNoChangeWatch(name, secs)
EVENT

alias of ItemNoChangeEvent

cancel()

Cancel the item watch

listen_event(callback)

Listen to (only) the event that is emitted by this watcher

Scheduler

OneTimeJob

class OneTimeJob(parent, func)
cancel()

Cancel the job.

get_next_run()

Return the next execution timestamp.

Return type

datetime

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

CountdownJob

class CountdownJob(parent, func)
cancel()

Cancel the job.

countdown(time)

Set the time after which the job will be executed.

Parameters

time (Union[timedelta, float, int]) – time

Return type

CountdownJob

get_next_run()

Return the next execution timestamp.

Return type

datetime

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

stop()

Stops the countdown so it can be started again with a call to reset

ReoccurringJob

class ReoccurringJob(parent, func)
boundary_func(func)

Add a function which will be called when the datetime changes. Use this to implement custom boundaries. Use None to disable the boundary function.

Parameters

func (Optional[Callable[[datetime], datetime]]) – Function which returns a datetime obj, arg is a datetime with the next run time. Return SKIP_EXECUTION together with a reoccurring job to skip the proposed run time.

Return type

DateTimeJobBase

cancel()

Cancel the job.

earliest(time_obj)

Set earliest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run earlier

Return type

DateTimeJobBase

get_next_run()

Return the next execution timestamp.

Return type

datetime

interval(interval)

Set the interval at which the task will run.

Parameters

interval (Union[int, float, timedelta]) – interval in secs or a timedelta obj

Return type

ReoccurringJob

jitter(start, stop=None)

Add a random jitter per call in the interval [start <= secs <= stop] to the next run. If stop is omitted start must be positive and the interval will be [-start <= secs <= start] Passing None as start will disable jitter.

Parameters
  • start (Union[int, float, None]) – Interval start or None to disable jitter

  • stop (Union[int, float, None]) – Interval stop or None to build interval based on start

Return type

DateTimeJobBase

latest(time_obj)

Set latest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run later

Return type

DateTimeJobBase

offset(timedelta_obj)

Set a constant offset to the calculation of the next run. None will disable the offset.

Parameters

timedelta_obj (Optional[timedelta]) – constant offset

Return type

DateTimeJobBase

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

DayOfWeekJob

class DayOfWeekJob(parent, func)
boundary_func(func)

Add a function which will be called when the datetime changes. Use this to implement custom boundaries. Use None to disable the boundary function.

Parameters

func (Optional[Callable[[datetime], datetime]]) – Function which returns a datetime obj, arg is a datetime with the next run time. Return SKIP_EXECUTION together with a reoccurring job to skip the proposed run time.

Return type

DateTimeJobBase

cancel()

Cancel the job.

earliest(time_obj)

Set earliest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run earlier

Return type

DateTimeJobBase

get_next_run()

Return the next execution timestamp.

Return type

datetime

jitter(start, stop=None)

Add a random jitter per call in the interval [start <= secs <= stop] to the next run. If stop is omitted start must be positive and the interval will be [-start <= secs <= start] Passing None as start will disable jitter.

Parameters
  • start (Union[int, float, None]) – Interval start or None to disable jitter

  • stop (Union[int, float, None]) – Interval stop or None to build interval based on start

Return type

DateTimeJobBase

latest(time_obj)

Set latest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run later

Return type

DateTimeJobBase

offset(timedelta_obj)

Set a constant offset to the calculation of the next run. None will disable the offset.

Parameters

timedelta_obj (Optional[timedelta]) – constant offset

Return type

DateTimeJobBase

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

time(time)

Set a time of day when the job will run.

Parameters

time (Union[time, datetime]) – time

Return type

DayOfWeekJob

weekdays(weekdays)

Set the weekdays when the job will run.

Parameters

weekdays (Union[str, Iterable[Union[str, int]]]) – Day group names (e.g. 'all', 'weekend', 'workdays'), an iterable with day names (e.g. ['Mon', 'Fri']) or an iterable with the isoweekday values (e.g. [1, 5]).

Return type

DayOfWeekJob

DawnJob

class DawnJob(parent, func)
boundary_func(func)

Add a function which will be called when the datetime changes. Use this to implement custom boundaries. Use None to disable the boundary function.

Parameters

func (Optional[Callable[[datetime], datetime]]) – Function which returns a datetime obj, arg is a datetime with the next run time. Return SKIP_EXECUTION together with a reoccurring job to skip the proposed run time.

Return type

DateTimeJobBase

cancel()

Cancel the job.

earliest(time_obj)

Set earliest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run earlier

Return type

DateTimeJobBase

get_next_run()

Return the next execution timestamp.

Return type

datetime

jitter(start, stop=None)

Add a random jitter per call in the interval [start <= secs <= stop] to the next run. If stop is omitted start must be positive and the interval will be [-start <= secs <= start] Passing None as start will disable jitter.

Parameters
  • start (Union[int, float, None]) – Interval start or None to disable jitter

  • stop (Union[int, float, None]) – Interval stop or None to build interval based on start

Return type

DateTimeJobBase

latest(time_obj)

Set latest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run later

Return type

DateTimeJobBase

offset(timedelta_obj)

Set a constant offset to the calculation of the next run. None will disable the offset.

Parameters

timedelta_obj (Optional[timedelta]) – constant offset

Return type

DateTimeJobBase

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

SunriseJob

class SunriseJob(parent, func)
boundary_func(func)

Add a function which will be called when the datetime changes. Use this to implement custom boundaries. Use None to disable the boundary function.

Parameters

func (Optional[Callable[[datetime], datetime]]) – Function which returns a datetime obj, arg is a datetime with the next run time. Return SKIP_EXECUTION together with a reoccurring job to skip the proposed run time.

Return type

DateTimeJobBase

cancel()

Cancel the job.

earliest(time_obj)

Set earliest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run earlier

Return type

DateTimeJobBase

get_next_run()

Return the next execution timestamp.

Return type

datetime

jitter(start, stop=None)

Add a random jitter per call in the interval [start <= secs <= stop] to the next run. If stop is omitted start must be positive and the interval will be [-start <= secs <= start] Passing None as start will disable jitter.

Parameters
  • start (Union[int, float, None]) – Interval start or None to disable jitter

  • stop (Union[int, float, None]) – Interval stop or None to build interval based on start

Return type

DateTimeJobBase

latest(time_obj)

Set latest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run later

Return type

DateTimeJobBase

offset(timedelta_obj)

Set a constant offset to the calculation of the next run. None will disable the offset.

Parameters

timedelta_obj (Optional[timedelta]) – constant offset

Return type

DateTimeJobBase

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

SunsetJob

class SunsetJob(parent, func)
boundary_func(func)

Add a function which will be called when the datetime changes. Use this to implement custom boundaries. Use None to disable the boundary function.

Parameters

func (Optional[Callable[[datetime], datetime]]) – Function which returns a datetime obj, arg is a datetime with the next run time. Return SKIP_EXECUTION together with a reoccurring job to skip the proposed run time.

Return type

DateTimeJobBase

cancel()

Cancel the job.

earliest(time_obj)

Set earliest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run earlier

Return type

DateTimeJobBase

get_next_run()

Return the next execution timestamp.

Return type

datetime

jitter(start, stop=None)

Add a random jitter per call in the interval [start <= secs <= stop] to the next run. If stop is omitted start must be positive and the interval will be [-start <= secs <= start] Passing None as start will disable jitter.

Parameters
  • start (Union[int, float, None]) – Interval start or None to disable jitter

  • stop (Union[int, float, None]) – Interval stop or None to build interval based on start

Return type

DateTimeJobBase

latest(time_obj)

Set latest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run later

Return type

DateTimeJobBase

offset(timedelta_obj)

Set a constant offset to the calculation of the next run. None will disable the offset.

Parameters

timedelta_obj (Optional[timedelta]) – constant offset

Return type

DateTimeJobBase

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

DuskJob

class DuskJob(parent, func)
boundary_func(func)

Add a function which will be called when the datetime changes. Use this to implement custom boundaries. Use None to disable the boundary function.

Parameters

func (Optional[Callable[[datetime], datetime]]) – Function which returns a datetime obj, arg is a datetime with the next run time. Return SKIP_EXECUTION together with a reoccurring job to skip the proposed run time.

Return type

DateTimeJobBase

cancel()

Cancel the job.

earliest(time_obj)

Set earliest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run earlier

Return type

DateTimeJobBase

get_next_run()

Return the next execution timestamp.

Return type

datetime

jitter(start, stop=None)

Add a random jitter per call in the interval [start <= secs <= stop] to the next run. If stop is omitted start must be positive and the interval will be [-start <= secs <= start] Passing None as start will disable jitter.

Parameters
  • start (Union[int, float, None]) – Interval start or None to disable jitter

  • stop (Union[int, float, None]) – Interval stop or None to build interval based on start

Return type

DateTimeJobBase

latest(time_obj)

Set latest boundary as time of day. None will disable boundary.

Parameters

time_obj (Optional[time]) – time obj, scheduler will not run later

Return type

DateTimeJobBase

offset(timedelta_obj)

Set a constant offset to the calculation of the next run. None will disable the offset.

Parameters

timedelta_obj (Optional[timedelta]) – constant offset

Return type

DateTimeJobBase

remaining()

Returns the remaining time to the next run or None if the job is not scheduled

Return type

Optional[timedelta]

Returns

remaining time as a timedelta or None

Configuration

settings ApplicationConfig

Structure that contains the complete configuration

field directories: DirectoriesConfig [Optional]
field habapp: HABAppConfig [Optional]
field location: LocationConfig [Optional]
field mqtt: MqttConfig [Optional]
field openhab: OpenhabConfig [Optional]

Directories

settings DirectoriesConfig

Configuration of directories that are used

field config: Optional[Path] = 'config'

Folder from which configuration files (e.g. for textual thing configuration) will be loaded

field lib: Optional[Path] = 'lib'

Folder where additional libraries can be placed

field logging: Path = 'log'

Folder where the logs will be written to

field param: Optional[Path] = 'params'

Folder from which the parameter files will be loaded

field rules: Path = 'rules'

Folder from which the rule files will be loaded

Location

settings LocationConfig

location where the instance is running. Is used to calculate Sunrise/Sunset.

field elevation: float = 0.0
field latitude: float = 0.0
field longitude: float = 0.0

MQTT

settings MqttConfig

MQTT configuration

field connection: Connection [Optional]
field general: General [Optional]
field publish: Publish [Optional]
field subscribe: Subscribe [Optional]
settings Connection
field client_id: str = 'HABApp'
field host: str = ''
field password: str = ''
field port: int = 8883
field tls: TLSSettings [Optional]
field user: str = ''
settings TLSSettings
field ca cert: Path = ''

Path to a CA certificate that will be treated as trusted

field enabled: bool = True

Enable TLS for the connection

field insecure: bool = False

Validate server hostname in server certificate

settings Subscribe
field qos: Literal[0, 1, 2] = 0

Default QoS for subscribing

field topics: Tuple[Tuple[str, Optional[Literal[0, 1, 2]]], ...] = ('#',)
settings Publish
field qos: Literal[0, 1, 2] = 0

Default QoS when publishing values

field retain: bool = False

Default retain flag when publishing values

settings General
field listen_only: bool = False

If True HABApp does not publish any value to the broker

Openhab

settings OpenhabConfig
field connection: Connection [Optional]
field general: General [Optional]
field ping: Ping [Optional]
settings Connection
field buffer: ByteSize = '128kib'

Buffer for reading lines in the SSE event handler. This is the buffer that gets allocated for every(!) request and SSE message that the client processes. Increase only if you get error messages or disconnects e.g. if you use large images.

field password: str = ''
field url: AnyHttpUrl = 'http://localhost:8080'

Connect to this url

Constraints
  • minLength = 1

  • maxLength = 65536

  • format = uri

field user: str = ''
field verify_ssl: bool = True

Check certificates when using https

settings Ping
field enabled: bool = True

If enabled the configured item will show how long it takes to send an update from HABApp and get the updated value back from openHAB in milliseconds

field interval: int = 10

Seconds between two pings

Constraints
  • minimum = 0.1

field item: str = 'HABApp_Ping'

Name of the Numberitem

settings General
field listen_only: bool = False

If True HABApp does not change anything on the openHAB instance.

field wait_for_openhab: bool = True

If True HABApp will wait for items from the openHAB instance before loading any rules on startup

HABApp

settings HABAppConfig

HABApp internal configuration. Only change values if you know what you are doing!

field logging: LoggingConfig [Optional]
field thread pool: ThreadPoolConfig [Optional]
settings ThreadPoolConfig
field enabled: bool = True

When the thread pool is disabled HABApp will become an asyncio application. Use only if you have experience developing asyncio applications! If the thread pool is disabled using blocking calls in functions can and will break HABApp

field threads: ConstrainedIntValue = 10

Amount of threads to use for the executor

Constraints
  • minimum = 1

  • maximum = 16