# receivedCommand in blockly?

**URL:** <https://community.openhab.org/t/receivedcommand-in-blockly/122848>\
**Category:** Scripts & Rules\
**Tags:** openhab3, oh3, blockly\
**Created:** [May 27, 2021, 11:09am UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848 "2021-05-27T11:09:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![deadbabylon](https://community.openhab.org/letter_avatar_proxy/v4/letter/d/0ea827/32.png) [@deadbabylon](https://community.openhab.org/u/deadbabylon)\
**Post date:** [May 27, 2021, 11:09am UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848/1 "2021-05-27T11:09:14Z")

</div>

Hi,

maybe it’s a stupid question, but how do I react to a command which was send to an item?

Just the equivalent to this DSL rule:

```php
triggers:
  - id: "1"
    configuration:
      itemName: test
    type: core.ItemCommandTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: |-
        switch (receivedCommand){
          case ON: {
            logInfo("TEST","TEST received ON")
          }
            
          case OFF: {
            logInfo("TEST","TEST received OFF")  
          }
        }
    type: script.ScriptAction

```

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [May 27, 2021, 2:12pm UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848/2 "2021-05-27T14:12:37Z")

</div>

That is not yet supported in Blockly.

---

<div class="post-metadata">

**Author:** ![ubeaut](https://community.openhab.org/user_avatar/community.openhab.org/ubeaut/32/119014_2.png) [@ubeaut](https://community.openhab.org/u/ubeaut)\
**Post date:** [May 27, 2021, 11:18pm UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848/3 "2021-05-27T23:18:19Z")

</div>

If you want to do it in JavaScript as blockly doesn’t support it then it is like this:

```auto
var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var Exec = Java.type("org.openhab.core.model.script.actions.Exec");
var Duration = Java.type("java.time.Duration");
var TOPIC = null;
var PAYLOAD = null;

var rfinput = itemRegistry.getItem('RFBridgekitchen_Receiveddata').getState().toString();

switch(rfinput) {
 //row 3 green and switch is on S
     case 'BB369A':
     events.sendCommand("Lightsshedinandoutside_Shedlights", 'ON');
       logger.info('Shed lights ON');
    break;

//row 3 red and switch is on S
     case 'BB3692':
     events.sendCommand("Lightsshedinandoutside_Shedlights", 'OFF');
       logger.info('Shed lights OFF');
    break;
  default:  
}

```

---

<div class="post-metadata">

**Author:** ![Zip\_Zip](https://community.openhab.org/user_avatar/community.openhab.org/zip_zip/32/45748_2.png) [@Zip\_Zip](https://community.openhab.org/u/Zip_Zip)\
**Post date:** [December 11, 2021, 12:05am UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848/4 "2021-12-11T00:05:17Z")

</div>

any news when “received command” will support in blockly?

PS maybe there is another way (in blockly) to get

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/9/0/908c272ee9e69d8f74e749272d8894cc07a6504e.png) buttons click?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [December 11, 2021, 2:48pm UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848/5 "2021-12-11T14:48:58Z")

</div>

PR is made and under review. There will be an event block and you can get to the item command through that.

---

<div class="post-metadata">

**Author:** ![stefan.hoehn](https://community.openhab.org/user_avatar/community.openhab.org/stefan.hoehn/32/81928_2.png) [@stefan.hoehn](https://community.openhab.org/u/stefan.hoehn)\
**Post date:** [December 25, 2021, 8:08pm UTC](https://community.openhab.org/t/receivedcommand-in-blockly/122848/6 "2021-12-25T20:08:31Z")

</div>

It has been made available with the 3.2.0 Release,

 ![image](https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/6/b67c5846b700df8dc3776b5fcf3d2be4d8665df2.png)

The [Blockly Reference](https://community.openhab.org/t/blockly-reference/128785) though is work in progress which is why you don’t see it yet there.
