50 lines
1.2 KiB
Markdown
50 lines
1.2 KiB
Markdown
|
# Node and Home Assistant Directly
|
||
|
### Nodejs interacts with HomeAssiant via a nodejs class/API
|
||
|
|
||
|
Example: Watch some entities and change others based on their values
|
||
|
|
||
|
```yaml
|
||
|
# paste this in as one entry of the views: property in ui-lovelace.yaml
|
||
|
# you must be in lovelace yaml mode.
|
||
|
- title: Node Testing
|
||
|
cards:
|
||
|
- type: vertical-stack
|
||
|
cards:
|
||
|
# - type: horizontal-stack
|
||
|
- type: entities
|
||
|
entities:
|
||
|
- entity: input_number.node_test_first_number
|
||
|
- entity: input_number.node_test_second_number
|
||
|
- entity: variable.node_test_sum
|
||
|
- entity: variable.node_test_switch
|
||
|
name: Dummy Switch (on>100)
|
||
|
```
|
||
|
|
||
|
|
||
|
```yaml
|
||
|
# Save this to node_test.yaml file in your config/packages directory
|
||
|
# change in /packages require a home assistant restart to take effect
|
||
|
variable:
|
||
|
node_test_sum:
|
||
|
value: 0
|
||
|
# dummy device value to turn on and off
|
||
|
node_test_switch:
|
||
|
value: 'OFF'
|
||
|
attributes:
|
||
|
icon: mdi:flash
|
||
|
|
||
|
input_number:
|
||
|
node_test_first_number:
|
||
|
name: "First Number"
|
||
|
initial: 25
|
||
|
min: 0
|
||
|
max: 100
|
||
|
step: 1
|
||
|
node_test_second_number:
|
||
|
name: "Second Number"
|
||
|
initial: 75
|
||
|
min: 0
|
||
|
max: 100
|
||
|
step: 1
|
||
|
```
|