Cannot define the level for blinds/rollershutter in script

  • Platform information:
    • OS: Docker image: “openhab/openhab:latest”
    • openHAB version: openHAB 3.4.4

I have a working setup with openHAB and Homematic. I am using the HmIP-BROLL with FW 1.10.8 and I would like to close the blinds to some percantages. I have written a script for a rule like the following:

      script: >-2
           BROLLKUECHER_4_LEVEL.sendCommand(40)
    type: script.ScriptAction

I understand that the Point to send the command to needs to be of ?Type? Rollershutter, which I believe is configured in my model as follows:




Question: What am I missing, that the blinds are not closing to my defined value?

There are several possible issues here. Can you please share the entire rule code and not just the script line?

Hi Justin,

this is the full rule:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Local_weather_and_forecast_ForecastHours03_Maxtemperature
    type: core.ItemStateUpdateTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: Local_weather_and_forecast_ForecastHours03_Maxtemperature
      state: "24"
      operator: ">"
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-2
           BROLLKUECHER_4_LEVEL.sendCommand(40)
    type: script.ScriptAction

Thanks

Sven

It is possible that your rule is not running at all. You have not told us what kind of Item Local_weather_and_forecast_ForecastHours03_Maxtemperature but if it is a Number:Temperature type Item, then to make sure that you are performing the comparison you think you are you should include the unit in the comparison value (for example, 24 °C).

If your rule does run, it is possible that is it then encountering an error in your script. It is not clear to me what -2 is doing in the script definition:

      script: >-2
           BROLLKUECHER_4_LEVEL.sendCommand(40)

My first recommendation is that this doesn’t even have to be a script action. If you are just sending a command to an item then add an Item Action to the rule instead of the script.

If there’s some reason to really prefer the script (for example, you intend to expand this action later) then the first the you should do is track down that -2 which I don’t believe should be there, and then test the script to see if it works. You do this by using the Run Now button in the lower left-hand corner of the script editor. When you press that button if you don’t get the result you are expecting, check the logs to see what is really going on.

Hu Justin,

I think this is unrelated to the rule and therefore I decided to break it down to just this one command. I can go to the UI under Settings–>Scripts and enter only the command BROLLSZR_4_LEVEL.sendCommand(40) - that results into a fully clsoed/opened blind with the following log:

2023-06-15 08:12:21.256 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'BROLLSZR_4_LEVEL' received command 40
2023-06-15 08:12:21.256 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'BROLLSZR_4_LEVEL' predicted to become 40
2023-06-15 08:12:21.256 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL' updated to 40
2023-06-15 08:12:21.412 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_SECTION_STATUS' updated to NORMAL
2023-06-15 08:12:21.412 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL' updated to 40
2023-06-15 08:12:21.412 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL_STATUS' updated to NORMAL
2023-06-15 08:12:21.413 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_SECTION' updated to 3
2023-06-15 08:12:21.413 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BROLLSZR_4_SECTION' changed from 4 to 3
2023-06-15 08:12:21.413 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_PROCESS' updated to NOT_STABLE
2023-06-15 08:12:21.413 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BROLLSZR_4_PROCESS' changed from STABLE to NOT_STABLE
2023-06-15 08:12:21.414 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_ACTIVITY_STATE' updated to STABLE
2023-06-15 08:12:22.317 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_SECTION_STATUS' updated to NORMAL
2023-06-15 08:12:22.317 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL' updated to 40
2023-06-15 08:12:22.317 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL_STATUS' updated to NORMAL
2023-06-15 08:12:22.318 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_SECTION' updated to 3
2023-06-15 08:12:22.318 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_PROCESS' updated to NOT_STABLE
2023-06-15 08:12:22.319 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_ACTIVITY_STATE' updated to STABLE
2023-06-15 08:12:22.346 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_SECTION_STATUS' updated to NORMAL
2023-06-15 08:12:22.347 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_LEVEL' updated to 100
2023-06-15 08:12:22.347 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_LEVEL_STATUS' updated to NORMAL
2023-06-15 08:12:22.348 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_SECTION' updated to 0
2023-06-15 08:12:22.349 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_PROCESS' updated to STABLE
2023-06-15 08:12:22.349 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_ACTIVITY_STATE' updated to STABLE
2023-06-15 08:12:34.917 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_SECTION_STATUS' updated to NORMAL
2023-06-15 08:12:34.918 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL' updated to 40
2023-06-15 08:12:34.918 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_LEVEL_STATUS' updated to NORMAL
2023-06-15 08:12:34.919 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_SECTION' updated to 4
2023-06-15 08:12:34.919 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BROLLSZR_4_SECTION' changed from 3 to 4
2023-06-15 08:12:34.920 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_PROCESS' updated to STABLE
2023-06-15 08:12:34.920 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BROLLSZR_4_PROCESS' changed from NOT_STABLE to STABLE
2023-06-15 08:12:34.920 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_4_ACTIVITY_STATE' updated to STABLE
2023-06-15 08:12:34.939 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_SECTION_STATUS' updated to NORMAL
2023-06-15 08:12:34.939 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_LEVEL' updated to 100
2023-06-15 08:12:34.939 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_LEVEL_STATUS' updated to NORMAL
2023-06-15 08:12:34.940 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_SECTION' updated to 0
2023-06-15 08:12:34.940 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_PROCESS' updated to STABLE
2023-06-15 08:12:34.940 [INFO ] [openhab.event.ItemStateEvent        ] - Item 'BROLLSZR_6_ACTIVITY_STATE' updated to STABLE

I think it is strange that running the same command again, will toggle the blinds, so if they are down, they will get up and vice versa.

Yes, that line was not one of the possible issues I outlined. The syntax of that command is correct and it will work when there are not other problems. I was not suggesting that you test your command in a different script but test the actual script that is part of the rule. Because the -2 shows up in the rule code definition for some reason, that is most likely causing that particular script to fail.

I don’t want to sound ungrateful and the rule might has its own troubles, because I was still developing it. Thanks for helping me with debugging the issue.

However, the rule is disabled at the moment and I want to understand why my .sendCommand(int) isn’t bringing the blinds to a specific level. That’s why I tried to minimize the code as much as possible to narrow down the problem.

Do you know what the cause of the misbehaving of the sendCommand could be? I hoped I would have simply forgotten to create a link, or accessing the wrong item, or something like that.

You have jumped to the conclusion that it is the sendCommand that is the problem, yet you haven’t provided any evidence to support this conclusion (for example, logs when the rule runs) and, quite frankly, from what you have provided that is not very likely to be the actual problem. If you really still think this is the issue then you have to do a more clear job of laying out all the factors that lead you to this conclusion.

For example, the script test you mentioned used the item BROLLSZR_4_LEVEL but that is not the item in the original rule which is BROLLKUECHER_4_LEVEL. Are these items even defined the same way? Have you tested wither ROLLKUECHER_4_LEVEL when used in the basic script? Have you tested whether BROLLSZR_4_LEVEL works when substituted into the rule script?

From the information you have provided, I still have to say that the most likely issue is somewhere else in the rule, but I’m OK with being proven wrong so long as evidence is provided.

I second what @JustinG is writing, we need more information.
What happens when you send a state command (not just update) to that item via REST Api ?
Will the physical device move correctly to the desired position ?
If not, we need more information about the device (Thing) and the channel type the Item is linked to.

Edit: replied to wrong post, so
Cc @auto-sven-mate