Blockly blocks, Log warning

I’m working on some Blockly blocks and get a Log warning whnever i use the block and save the rule.

This is the Block code;

uid: telegram_with_chatid_new
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Aug 23, 2022, 11:20:25 AM
component: BlockLibrary
config:
  name: Telegram-with-ChatID
slots:
  blocks:
    - component: BlockType
      config:
        args0:
          - name: MESSAGE
            type: input_value
          - name: BOT
            type: input_value
          - name: CHAT_ID_option
            options:
              - - with Chat-ID
                - >
                  ({{input:CHAT_ID}},{{input:MESSAGE}});
              - - without Chat-ID
                - >
                  ({{input:MESSAGE}});
            type: field_dropdown
          - name: CHAT_ID
            type: input_value
        colour: "#2ea5d8"
        helpUrl: ""
        inputsInline: false
        lastDummyAlign0: right
        message0: send on Telegram %1 from bot %2 %3 %4
        nextStatement: ""
        previousStatement: ""
        tooltip: ""
        type: message
      slots:
        code:
          - component: BlockCodeTemplate
            config:
              template: >
                {{utility:things}}.getActions('telegram',{{input:BOT}}).sendTelegram{{field:CHAT_ID_option}}
        toolbox:
          - component: PresetInput
            config:
              fields:
                TEXT: What's up?
              name: MESSAGE
              shadow: true
              type: text
          - component: PresetInput
            config:
              name: BOT
              shadow: true
              type: oh_thing
          - component: PresetInput
            config:
              fields:
                NUM: 0
              name: CHAT_ID
              shadow: true
              type: math_number
  utilities:
    - component: UtilityJavaType
      config:
        javaClass: org.openhab.core.model.script.actions.Things
        name: things

The Block is producing the correct code but i get this warning when i save the rule, though the rule is working as expected.

2022-08-23 11:20:53.729 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{input:CHAT_ID}} , it will remain the same.

2022-08-23 11:20:53.736 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{input:MESSAGE}} , it will remain the same.

I get the same Warn with a block from the Marketplace library Common Blocks.

Block-warn

2022-08-23 11:34:04.372 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{input:CHAT_ID}} , it will remain the same.

2022-08-23 11:34:04.375 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{input:MESSAGE}} , it will remain the same.

2022-08-23 11:34:04.377 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{input:timer_name}} , it will remain the same.

2022-08-23 11:34:04.379 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{field:duration_unit}} , it will remain the same.

2022-08-23 11:34:04.381 [WARN ] [automation.internal.RuleRegistryImpl] - Cannot find reference for {{input:duration}} , it will remain the same.

has anybody an idea what is wrong?

Roli

The error is complaining about a CHAT_ID and MESSAGE. So that probably means there is something up with Telegram. Usually stuff in {{ }} gets replaced with a value from a configuration property you set. So there is some config that you failed to do or that failed to work. If you don’t get any further help here, you might ask for help on the library’s thread itself.

The stuff in the {{ }} gets replaced as wanted and code output of the block is correct and working as expected.
The warning appears only when i select the block from the library and save the rule.

I got similar errors in the start-up process of my openhabian. But the problem is, that I don’t know which rule actually has the problem, because there is no rule-ID (for example) part of the error message. :-/ So this is not a problem of the “save process” of the rule… It happens also, when openhab is loaded the rules in the startup process.

Perhaps this thread solve also my problem :slight_smile:

Regards,
Tim

So what happens here is you put placeholders in your options for the dropdown field:

          - name: CHAT_ID_option
            options:
              - - with Chat-ID
                - >
                  ({{input:CHAT_ID}},{{input:MESSAGE}});
              - - without Chat-ID
                - >
                  ({{input:MESSAGE}});

While it works in that they will be replaced properly when Blockly generates the actual code, the side effect is that when you create a rule with a Blockly script action that includes this block type, you will still have placeholders in the blockSource parameter (scroll right):

configuration: {}
triggers: []
conditions: []
actions:
  - inputs: {}
    id: "1"
    configuration:
      blockSource: >-
        <xml xmlns="https://developers.google.com/blockly/xml"><block type="telegram_with_chatid_new_message" id="WF#dFF`*#XvF3BI)rh?P" x="192" y="144"><field name="CHAT_ID_option">({{input:CHAT_ID}},{{input:MESSAGE}});

        </field><value name="MESSAGE"><shadow type="text" id="y+/V*)lbF?x+H6.STceh"><field name="TEXT">What's up?</field></shadow></value><value name="BOT"><shadow type="oh_thing" id="faE!OV?JcU/O^+tZ7Q,@"><field name="thingUid">MyThing</field></shadow></value><value name="CHAT_ID"><shadow type="math_number" id="attx,C6U-f.(5;XB8#]E"><field name="NUM">0</field></shadow></value></block></xml>
      type: application/javascript
      script: >
        var things = Java.type('org.openhab.core.model.script.actions.Things');

        things.getActions('telegram','MyThing').sendTelegram(0,'What\'s up?');
    type: script.ScriptAction

Incidentally, this {{ }} syntax is also what is looked for when replacing parameters for rules created from rule templates. So the server sees this “mustache” (double-curvy braces) pattern and tries to find a (rule) parameter defined by a template to perform another replacement. Since it doesn’t find one you get a warning in the logs.

The “tl;dr” is: don’t put Blockly placeholders outside the template parameter of the BlockCodeTemplate component in Blockly libraries, like dropdown option values - it will work but it’s not that good a practice and you’ll get side effects like this.

Thanks Yannick for your detailed explanation.
In that case i have to find another solution for that library.