-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver2.hms
51 lines (42 loc) · 1000 Bytes
/
driver2.hms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import state from driver;
import { DeviceDriver, DriverManager } from driver;
type Node = {
url: str,
name: str,
token: str,
}
@Driver
type NodeManagerDriver = {
config: {
nodes: [Node]
}
};
@Device
type NodeSwitch = {
config: {
id: str, // filtered out by provider
targetNode: ?str,
}
};
impl DriverManager for @Driver {
fn init(driver) {
...
}
fn report_health(driver) {
}
}
// TODO: implement this OR: add individual templates based on the device type:
// One template for the base device
// more templates for additional functionality
impl DeviceDriver with { onOff, dimmable, colorTemperature } for @Device {
// Missing methods: ....
fn set_power(dev: @Device, driver: @Driver, power: bool) {
for node in driver.nodes {
send_node(node, device, power);
}
}
}
// Can access @Device, @Driver
fn internal_stuff(dev: @Device, driver: @Driver) {
Driver.set_power(true)
}