Simulation¶
The simulation has its own configuration, usually located at data/sim.xml:
<?xml version="1.0"?>
<simulation version="1">
<modulator busid="70" dsid="10">
<zone id="1"> <!-- id can be omitted, in fact zone may be omitted if there's only one zone -->
<device dsid="1" busid="1" type="standard.switch" />
<device dsid="2" busid="2" type="example.vlc_remote" />
<device dsid="4" busid="4" type="standard.simple"/>
<group id="1">
<device busid="4" />
</group>
<group id="4">
<device busid="2" />
</group>
</zone>
<zone id="2">
<device dsid="3" busid="3" type="standard.switch"/>
<device dsid="5" busid="5" type="standard.simple" />
<group id="1">
<device busid="5" />
</group>
</zone>
</modulator>
<modulator ...>
</modulator>
</simulation>
The simulation tag encloses multiple modulators. In the modulator tag the modulators busid (as in DS485 bus address) as well as its dsid get specified. The dsid as it's written there is actually expanded in the loader to be a simulation address and thus prefixed with 3504175fe0000000ffc. This applies for all dsids in this config file.
The device-type defines what object gets instanciated by the simulated dSM. There are two built-in dSIDs standard.simple a device that behaves like a light bulb and "standard.switch" which simulates a 9 button switch.
If the type of a device is not specified it defaults to "standard.simple".
To form groups inside a zone a group tag containing references to the devices must be inserted. At the moment it's not possible to define devices inside a group tag.
Your own dSID¶
It's possible to write custom dSIDs with the use of javascripts. Those scripts have to be registered on startup in the property-system at /config/subsystems/DSSim/js-devices/.
Register them in data/config.d/my.xml:
<?xml version="1.0" encoding="utf-8"?>
<properties version="1">
<property name="config">
<property name="subsystems/DSSim/js-devices">
<property name="example">
<property name="script-file" type="string">
<value>data/simulated_device.js</value>
</property>
<property name="id" type="string">
<value>example.js-device</value>
</property>
</property>
</property>
It's also possible to load multiple script files:
[...]
<property name="script-file[0]" type="string">
<value>data/test_device.js</value>
</property>
<property name="script-file[1]" type="string">
<value>data/temperature_sensor.js</value>
</property>
[...]
The id value can be used in data/sim.xml as type.
Metering¶
In config.xml you can turn on the metering subsystem as well as a fake meter:
<property name="subsystems/FakeMeter/enabled" type="boolean">
<value>true</value>
</property>
<property name="subsystems/Metering/enabled" type="boolean">
<value>true</value>
</property>
All you have to do is to set the values to false or true, to disable and enable them respectively.
Simulated devices do not consume energy by default, to enable consumption you have two possibilities to configure it in sim.xml
Adding a parameter named SimpleConsumption will turn on a very basic consumption algorithm on the device:
<device dsid="5" busid="5" type="standard.simple">
<parameter name="SimpleConsumption">1</parameter>
</device>
If you want more fine grained control over consumption, you can configure the follwing:
<device dsid="5" busid="5" type="standard.simple">
<parameter name="MinConsumption">0</parameter>
<parameter name="MaxConsumption">60</parameter>
<parameter name="JitterConsumption">5</parameter>
</device>
- MinConsumption the minimum a device should consume (when turned off)
- MaxConsumption the maximum a device should consume (when fully turned on)
- JitterConsumption a jitter