PLCBUS.pm

NAME

PLCBUS - use the PLCBUS with misterhouse

DESCRIPTION

Enables the use of PLCBUS modules with misterhouse. To send/receive data from the bus a PLCBUS2-T 1141 device is required.

All testing was done with the USB variant but there should be no difference.

This module depends on a separate server process 'plcbussrv' to connect to the PLCBUS. You can get the tool from https://github.com/tobser/plcbussrv, see README.md for installation instructions. The server process is automatically started by this module

mh.private.ini

    plcbus_serial_port=/dev/plcbus
    plcbus_phase_mode=3
    plcbus_user_code=0xAB
    plcbus_command_file=/tmp/plcbuscommands
    plcbussrv_port=4567
    debug=plcbus:2|plcbus_module:2
    plcbus_logfile=1
plcbus_serial_port

Filename of your 1141

plcbus_phase_mode

Set to 1 or 3, default is 1

plcbus_user_code

The PLCBUS user code. All all modules including the 3-Phasecouple must be setup with the same user code otherwise they will not react to commands if not set the default of 0xff is used

plcbus_command_file

Can be used to execute arbitrary PLCBUS commands not available through the web interface. See SETTING UP A NEW PLCBUS MODULE on how to use it.

For a list of available commands take a look at %cmd_to_hex at the beginning of PLCBUS.pm

plcbussrv_port

TCP port to use for the plcbussrv server process. Default is '4567'

plcbus_logfile

if set to '1' a seperate logfile "$main::config_parms{data_dir}/logs/plcbus.log" with all plcbus logging is created. This may help to keep the global mh logfile clean while still being able to debug plcbus. All logmessages are written regardless of your 'debug=' setting.

if set to '0' or omitted, no logfile is created.

SAMPLE .MHT FILE

    Format = A
    # PLCBUS_TYPE,   address,  name,                groups
    PLCBUS_2026G,    B2,       StandardLamp,        Property|livingroom(10;10)
    PLCBUS_2263DAU,  B4,       StaircaseLightning,  Property|staircase(5;20)
    PLCBUS_2026G,    B5,       TvLamp,              Property|livingroom(20;20)
    PLCBUS_Scene,    O2,       TestScene

CATEGORY PLCBUS

The module automatically creates the "PLCBUS"-Category which contains all PLCBUS voice commands.

VOICE COMMANDS

Voice commands for the user code and for all home address are created. Those are worded as found in the documentation for the serial interface of the 1141. This may and probably will change in future.

PLCBUS ITEMS

For now all devices can only go into on/off state You can use the Voice_Cmds of the PLCBUS Category execute specific PLCBUS commands e.g. 'status_req' to retrieve the current state of the module. 'status_req' will also change the on/off state of the module if an answer is received. Other commands such as to get the signal strength do not change the state of the item. You have to check the misterhouse log for the result of those commands.

There are 3 special voice command states '1_phase', '3-phase' and 'use_mh_ini_phase_mode' to use a specific phase mode for one unit. This command is stored per unit, and is also restored between misterhouse restarts. 'use_mh_ini_phase_mode' deletes the setting and the phase mode specified in mh.ini is used.

SETTING UP A NEW PLCBUS MODULE

You may want to enable full debug output in for PLCBUS in your private mh.ini file to see what's actually going on:

    debug=plcbus:2|plcbus_module:2

Let's say we purchased a new PLCBUS_2026G plug in module. First we need to decide for an address for our new module, e.g. C7 and create a new entry in our mht file:

    PLCBUS_2026G,    C7,       newTestLamp, PLCBUS_C

Now reload or restart misterhouse. Misterhouse should now create the new device and start the plcbussrv server, which you should have installed already. If not see the DESCRIPTION for a link.

If all went as expected you should find your new device in the PLCBUS_C group:

http://misterhouse/ia7/#path=/objects&parents=PLCBUS_C&_collection_key=0,1,17,$PLCBUS_C

Now we have to tell the module about its new address. All modules I used so far are brought into setup mode by pressing the setup button for 5s. The LED starts blinking as soon as the module changes into setup mode. The 3-Phasecouple is an exception, its LED turns of as soon as it changed to setup mode.

As soon as the LED start to blink you have to send a 'on' command to the module. Either by changing its state via the web interface to 'on' or by using the PCLBUS command file (see mh.private.ini setting)

    echo c,7,on > /tmp/plcbuscommands

If the module stops blinking and the attached light turns off, the module now knows its own address and should react to your commands. To change the brightness level and fade rate try the following command

    echo c,7,presetdim,60,7 > /tmp/plcbuscommands

For less information on available commands see the documentation for the 1141 RS-232 Interface. You can get it in the download section of the PLCBUS forum http://www.plc-bus.info/downloads.php?cat=2 (you need to be logged in)

Now start playing with your new toys. But not too much, cause your 1141 and/or your phase couple may get annoyed :-(

AUTHOR

Tobias Sachs diespambox@gmx.net

 PLCBUS.pm