Virtual controller
Contents
The virtual controller service allows to define virtual units and sensors, which can be used for automation tests, demos and other related purposes.
Setup
Use the template EVA_DIR/share/svc-tpl/svc-tpl-controller-virtual.yml:
bus:
path: var/bus.ipc
command: svc/eva-controller-virtual
config:
# auto-create virtual items on set/action
auto_create: false
# define virtual items
items:
#- sensor:tests/temp
#- sensor:tests/hum
#- sensor:tests/pressure
#- sensor:tests/alarm
#- sensor:tests/voltage
#- sensor:tests/power
#- unit:tests/lamp
#- unit:tests/vent
#- unit:tests/door
#- unit:tests/u1
user: nobody
workers: 1
Create the service using eva-shell:
eva svc create eva.controller.virt1 /opt/eva4/share/svc-tpl/svc-tpl-controller-virtual.yml
or using the bus CLI client:
cd /opt/eva4
cat DEPLOY.yml | ./bin/yml2mp | \
./sbin/bus ./var/bus.ipc rpc call eva.core svc.deploy -
(see eva.core::svc.deploy for more info)
EAPI methods
See EAPI commons for the common information about the bus, types, errors and RPC calls.
action
Description |
Executes a mapped unit action |
Parameters |
See Unit actions |
Returns |
See Unit actions |
get
Description |
Gets controller state of a virtual item |
Parameters |
required |
Returns |
Item state struct |
Name |
Type |
Description |
Required |
i |
String |
Item OID |
yes |
Return payload example:
{
"oid": "sensor:tests/voltage",
"status": 1,
"value": 25.43
}
list
Description |
Lists virtual items and their states |
Parameters |
none |
Returns |
List (struct) |
Return payload example:
[
{
"oid": "unit:tests/door",
"status": 0,
"value": null
},
{
"oid": "sensor:tests/temp",
"status": 1,
"value": 42.37
},
{
"oid": "sensor:tests/voltage",
"status": 1,
"value": 25.43
}
]
set
Description |
Sets controller state of a virtual item |
Parameters |
required |
Returns |
nothing |
Name |
Type |
Description |
Required |
i |
String |
Item OID |
yes |
status |
u16 |
Item status |
no |
value |
Any |
Item state value |
no |