PLCLogo Solution: Rollershutter continius Position Control (0 to 100)

Problem Statement

How to control roller shutters / roller blinds / sun-blinds from Logo using wall-switches and in parallel from openHAB with full support of the Position? (Alexa set rollershutter to 50%)

Concept

Assuming the roller shutter drive (motor) can be controlled from 2 relay-outputs of Logo. One Logo-output controls the upwards-direction, the other controls the downwards-direction. Simple roller shutters do not provide any information of the current position, but have end-switches that assure the shutter stops at the top/bottom endpoints.

Solution

Here is a screenshot of what the result looks like.
Location Card

LOGO! Configuration (LOGO! SoftComfort Diagram Editor)
To control one rollo shutter the following UDF (user defined function) shall be used in your logo program.


Find the UDF for Logo8 here (remove .pdf):
RolloUDFInv.lma.pdf (62.3 KB)

The test-program looks like this:

UDF Parameter
UDF Parameter
TL= Runtime Time for complete Closure in seconds
TNL= Time where the roller shutter is at final position and power to the motor is still on to ensure complete opening.

Do not forget to configure the VM for the ‘Positions’:
Parameter

Openhab

dependencies

  • JS Transformation
  • JS Scripting addon ( ECMAScript-2021)
  • PLCLogo Binding
  • item names must be as shown only the part in front of “_” can be changed but must be the same for all three Items per rollershutter

LOGO Rollershutter Things

Things
three memory Things
OGSz_RolloIst → VD609
OGSz_RolloSoll → VW607
OGSz_RolloTrigger → VB600.2

LOGO rollershutter Items

Items

Rollo:
*type rollershutter

  • semantic Class Blinds
  • groups: semantic Group Room and non semantic group all rollershutters
  • channel linked to OGSz_RolloIst with Profile JS File Round.js
(function(i) {
  result = Math.round(i)
  return (result);
})(input)
  • Metadata: Auto-update false
  • Metadate: Alexa see yaml below
value: Shutter.RangeValue
config:
  actionMappings:
    - Close=DOWN
    - Open=UP
    - Lower=DOWN
    - Raise=UP
    - Stop=STOP
  capabilityNames:
    - "@Setting.Position"
  name: Rollo Schlafzimmer
  stateMappings:
    - Closed=100
    - Open=0:99
  supportedCommands:
    - UP=@Value.Up:@Value.Open
    - DOWN=@Value.Down:@Value.Close
    - STOP=@Value.Stop

OGSz_RolloSoll:

  • type number
  • non semantic
  • channel linked to OGSz_RolloSoll with no Profile

OGSz_RolloTrigger:

  • type switch
  • non semantic
  • channel linked to OGSz_RolloTrigger with no Profile

Rule javascript ECMAScript-2021

configuration: {}
triggers:
  - id: "1"
    configuration:
      groupName: OG_Rollos
    type: core.GroupCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript;version=ECMAScript-2021
      script: >
        var { DOWN, UP, ON, OFF } = require("@runtime");

        var Sollitem = items.getItem(event.itemName.replace('Rollo', 'RolloSoll'));

        var Triggeritem = items.getItem(event.itemName.replace('Rollo', 'RolloTrigger'));

        if (event.itemCommand == DOWN) {

          Sollitem.sendCommand("100");

        } else if (event.itemCommand == UP) {

          Sollitem.sendCommand("0");

        } else {

          Sollitem.sendCommand(event.itemCommand.toString());

        };

        Triggeritem.sendToggleCommand();
    type: script.ScriptAction

“One Rule to Rule them all” the rule looks at all items in the Group if one of them gets an command it Runs the Rule and gets the respective items.

Usage

I1 and I2 Inputs from Logo First Push Moves the rollershutter in the selected direction. second push of either Input stops the movement. Full Up and Down stops the rollershutter (configured Time)
Command to Item “Rollo”
“UP” moves rollershutter to fully Open
“DOWN” moves rollershutter to fully Closed
number command moves rollershutter to this position.
new command while rollershutter moves, stops it.

Full Yaml to Items, Links and Things

Items:

{
    "link": "http://192.168.178.30:8080/rest/items/OGSz_RolloTrigger",
    "state": "ON",
    "editable": true,
    "type": "Switch",
    "name": "OGSz_RolloTrigger",
    "label": "OGSz_RolloTrigger",
    "category": "",
    "tags": [],
    "groupNames": []
  },
{
    "link": "http://192.168.178.30:8080/rest/items/OGSz_RolloSoll",
    "state": "100",
    "stateDescription": {
      "pattern": "%.0f",
      "readOnly": false,
      "options": []
    },
    "editable": true,
    "type": "Number",
    "name": "OGSz_RolloSoll",
    "label": "OGSz_RolloSoll",
    "category": "",
    "tags": [],
    "groupNames": []
  },
{
    "link": "http://192.168.178.30:8080/rest/items/OGSz_Rollo",
    "state": "100",
    "stateDescription": {
      "minimum": 0,
      "maximum": 100,
      "step": 1,
      "pattern": "%.0f",
      "readOnly": false,
      "options": [
        {
          "value": "0",
          "label": "Open"
        },
        {
          "value": "100",
          "label": "Closed"
        }
      ]
    },
    "commandDescription": {
      "commandOptions": [
        {
          "command": "0",
          "label": "Open"
        },
        {
          "command": "100",
          "label": "Closed"
        }
      ]
    },
    "metadata": {
      "listWidget": {
        "value": " ",
        "config": {
          "stateInCenter": true
        }
      },
      "widgetOrder": {
        "value": "2"
      },
      "alexa": {
        "value": "Shutter.RangeValue",
        "config": {
          "actionMappings": [
            "Close=DOWN",
            "Open=UP",
            "Lower=DOWN",
            "Raise=UP",
            "Stop=STOP"
          ],
          "capabilityNames": [
            "@Setting.Position"
          ],
          "name": "Rollo Schlafzimmer",
          "stateMappings": [
            "Closed=100",
            "Open=0:99"
          ],
          "supportedCommands": [
            "UP=@Value.Up:@Value.Open",
            "DOWN=@Value.Down:@Value.Close",
            "STOP=@Value.Stop"
          ]
        }
      },
      "semantics": {
        "value": "Equipment_Blinds",
        "config": {
          "hasLocation": "OGSz_Raum"
        }
      },
      "stateDescription": {
        "value": " ",
        "config": {
          "max": "100",
          "min": "0",
          "options": "0=Open,100=Closed",
          "readOnly": false,
          "step": "1"
        }
      },
      "autoupdate": {
        "value": "false"
      }
    },
    "editable": true,
    "type": "Rollershutter",
    "name": "OGSz_Rollo",
    "label": "Rollo",
    "category": "rollershutter",
    "tags": [
      "Blinds"
    ],
    "groupNames": [
      "OGSz_Raum",
      "OG_Rollos"
    ]
  },

Links:

{
    "editable": true,
    "channelUID": "plclogo:memory:12cb0c0bb7:6a7a885e89:value",
    "configuration": {
      "function": "Runden.js",
      "profile": "transform:JS"
    },
    "itemName": "OGSz_Rollo"
  },
 {
    "editable": true,
    "channelUID": "plclogo:memory:12cb0c0bb7:10f4cc243b:state",
    "configuration": {},
    "itemName": "OGSz_RolloTrigger"
  },
{
    "editable": true,
    "channelUID": "plclogo:memory:12cb0c0bb7:cbe0984beb:value",
    "configuration": {},
    "itemName": "OGSz_RolloSoll"
  },

Things:

 {
    "channels": [
      {
        "linkedItems": [
          "OGSz_RolloTrigger"
        ],
        "uid": "plclogo:memory:12cb0c0bb7:10f4cc243b:state",
        "id": "state",
        "channelTypeUID": "plclogo:switch",
        "itemType": "Switch",
        "kind": "STATE",
        "label": "VB600.2",
        "description": "Digital in/output block VB600.2",
        "defaultTags": [],
        "properties": {
          "block": "VB600.2"
        },
        "configuration": {}
      }
    ],
    "statusInfo": {
      "status": "ONLINE",
      "statusDetail": "NONE"
    },
    "editable": true,
    "label": "OGSz_RolloTrigger",
    "bridgeUID": "plclogo:device:12cb0c0bb7",
    "configuration": {
      "block": "VB600.2",
      "force": false,
      "threshold": 0
    },
    "properties": {},
    "UID": "plclogo:memory:12cb0c0bb7:10f4cc243b",
    "thingTypeUID": "plclogo:memory"
  },
{
    "channels": [
      {
        "linkedItems": [
          "OGSz_Rollo"
        ],
        "uid": "plclogo:memory:12cb0c0bb7:6a7a885e89:value",
        "id": "value",
        "channelTypeUID": "plclogo:number",
        "itemType": "Number",
        "kind": "STATE",
        "label": "VD609",
        "description": "Analog in/output block VD609",
        "defaultTags": [],
        "properties": {
          "block": "VD609"
        },
        "configuration": {}
      }
    ],
    "statusInfo": {
      "status": "ONLINE",
      "statusDetail": "NONE"
    },
    "editable": true,
    "label": "OGSz_RolloIst",
    "bridgeUID": "plclogo:device:12cb0c0bb7",
    "configuration": {
      "block": "VD609",
      "force": false,
      "threshold": 0
    },
    "properties": {},
    "UID": "plclogo:memory:12cb0c0bb7:6a7a885e89",
    "thingTypeUID": "plclogo:memory",
    "location": "Schlafzimmer"
  },
{
    "channels": [
      {
        "linkedItems": [
          "OGSz_RolloSoll"
        ],
        "uid": "plclogo:memory:12cb0c0bb7:cbe0984beb:value",
        "id": "value",
        "channelTypeUID": "plclogo:number",
        "itemType": "Number",
        "kind": "STATE",
        "label": "VW607",
        "description": "Analog in/output block VW607",
        "defaultTags": [],
        "properties": {
          "block": "VW607"
        },
        "configuration": {}
      }
    ],
    "statusInfo": {
      "status": "ONLINE",
      "statusDetail": "NONE"
    },
    "editable": true,
    "label": "OGSz_RolloSoll",
    "bridgeUID": "plclogo:device:12cb0c0bb7",
    "configuration": {
      "block": "VW607",
      "force": false,
      "threshold": 0
    },
    "properties": {},
    "UID": "plclogo:memory:12cb0c0bb7:cbe0984beb",
    "thingTypeUID": "plclogo:memory",
    "location": "Schlafzimmer"
  },

Greetings Markus