# ha4us-scripts

> ha4us-scripts is a Node.js based script runner for use in ha4us based smart home environments.

In the current version it is basically a copy of mqtt-scripts developed by Sebastian Raff aka hobbyquaker.

## Needed methods in scripts

### states

- set Setting a datapoint (emits mqtt XYZ/set/....)
- get observes the last status (options: timeout=1s, active:false - emits a get)
- getCached gets the last value from cache (sync, since it's only does a internal lookup)
- status - emits a status of current scriptDomain topic (optionally retained)

### scheduler

#### Use cases

- turn on in the morning:
  at ( 'sunset','06:30').subscribe(onNext(idx, _array of params__)); cron(' *')

# License

MIT ©2017 Ulf Steinberg
MIT ©2015 Sebastian Raff

## Index

### Enumerations

- ScriptEventType

### Classes

- Ha4usScript
- Sandbox
- ScriptEvent

### Interfaces

- Ha4usScriptingEnvironment
- Logger
- ScriptOptions

### Functions

- Adapter

### Object literals

- ADAPTER_OPTIONS

## Functions

### Adapter

- Adapter($log: any, $args: any, $states: StateService, $yaml: any, $objects: ObjectService): object

- - Defined in index.ts:72

  #### Parameters

  - ##### $log: any

  - ##### $args: any

  - ##### $states: StateService

  - ##### $yaml: any

  - ##### $objects: ObjectService

  #### Returns object

  - ##### $onDestroy: $onDestroy

  - ##### $onInit: $onInit

## Object literals

### Const ADAPTER_OPTIONS

ADAPTER_OPTIONS: object

- Defined in index.ts:29

### imports

imports: string[] = ['$log', '$args', '$states', '$yaml', '$objects']

- Defined in index.ts:69

### name

name: string = "scripts"

- Defined in index.ts:31

### path

path: string = __dirname + '/..'

- Defined in index.ts:32

### args

args: object

- Defined in index.ts:33

### dir

dir: object

- Defined in index.ts:34

### alias

alias: string = "dir"

- Defined in index.ts:35

### demandOption

demandOption: boolean = false

- Defined in index.ts:36

### describe

describe: string = "directory of script files"

- Defined in index.ts:37

### type

type: string = "string"

- Defined in index.ts:38

### lat

lat: object

- Defined in index.ts:40

### alias

alias: string = "lat"

- Defined in index.ts:41

### default

default: number = 54.46

- Defined in index.ts:42

### demandOption

demandOption: boolean = false

- Defined in index.ts:43

### describe

describe: string = "Latitude for sun calculation"

- Defined in index.ts:44

### type

type: string = "number"

- Defined in index.ts:45

### long

long: object

- Defined in index.ts:47

### alias

alias: string = "long"

- Defined in index.ts:48

### default

default: number = 9.95

- Defined in index.ts:49

### demandOption

demandOption: boolean = false

- Defined in index.ts:50

### describe

describe: string = "Longitutde for sun calculation"

- Defined in index.ts:51

### type

type: string = "number"

- Defined in index.ts:52

### times

times: object

- Defined in index.ts:54

### alias

alias: string = "times"

- Defined in index.ts:55

### default

default: string = ""

- Defined in index.ts:56

### demandOption

demandOption: boolean = false

- Defined in index.ts:57

### describe

describe: string = "List of custom times"

- Defined in index.ts:58

### type

type: string = "string"

- Defined in index.ts:59

### watch

watch: object

- Defined in index.ts:61

### alias

alias: string = "w"

- Defined in index.ts:62

### default

default: boolean = true

- Defined in index.ts:64

### demandOption

demandOption: boolean = false

- Defined in index.ts:63

### describe

describe: string = "watch for script file changes"

- Defined in index.ts:65

### type

type: string = "boolean"

- Defined in index.ts:66

Generated using TypeDoc