LCN: Cover positioning

Hi @alengwenus ,

I have 27 covers in my house, which I can freely position within LCN. As is stands, your motor integration is not supporting this feature. Is there a particular reason for not offering that?

I am thinking about workarounds. One way would be to send key presses from HA to LCN, for which the respective position command is then programmed with LCN-Pro. In the documentation I saw some examples how to use this. What I am uncertain about is if one can send short/long/released for a key. Or is a key hit always interpreted as short?

Thanks :pray:

Hi @Sourcer63 ,
having time based positioning turned out to be not very reliable with LCN when I tried to implement that. So I postponed that as I do not need it for myself. I wanted to give it another try one day but I have other things with higher priority on my todo list.

You can send any key press event you want using the send_keys service action. There is also an example in the docs.

1 Like

Thanks for your reply,

Until now I thought that the positioning command is transparent, i.e. only the command is issued and the infrastructure is doing the rest. In LCN I have for example programmed things like “position motor 1 to 120” and the cover will move accordingly. Admittedly, I don’t see any PCK command that would do that. :innocent:

Actually I am using a small Linux system, called LinHK, that does the same as PCHK but offers a lot of additional possibilities, e.g. the cover positioning. Positioning requires that I store individual up and down times for each cover in the system. These behave as if there was a physical BS4 present.

So the path forward will be to send key presses instead. That requires 25 unused keys.

Is this then always a “short” key press or can I also send “long” or “released” triggers?

As written in the documentation you can use hit (short keypress), make (long keypress) and break (release keypress) as events.

Thanks,
After 20 years of German LCN with its Kurz, Lang and Los, I didn’t realize that Hit, Make, Break are the English equivalents.:innocent:

According to what you said, you could directly send the PCK command for the BS4 instead of sending keys:

Very interesting! But I am a little bit lost, still very much at the HomeAssistant beginner level.

Your PCK example is

action: lcn.pck
data:
  address: myhome.0.7
  pck: PIN4
  • Since I need multiple actions, how do I define an individual name to distinguish them?
  • What is the structure of the address? I guess that 0 is the segment, and 7 stands for the module number. But where is myhome defined?
  • For the command I need to use for example R8M2GO70

Whatever method you choose, you will have issues with reading the actual cover position back into Home Assistant.

Maybe you simply should try out solutions like this one (also available via HACS).
It‘s not super convenient but I would expect that it works as described.

The positioning infrastructure is working reliably. I would rather prefer to be able to position the cover. Seeing this in HA is not a top priority and more a nice-to-have than a must.

Anyway, at this moment I am in a testing phase and would like to experiment a little bit with the different possibilities first. I checked your LCN documentation but am uncertain about the PCK address semantic. what does myhome in your examples stand for and where is it defined?

myhome is the name of your LCN integration entry (it’s pchk by default if I remember correctly).

The format is <integration entry>.<segment id>.m<module id>

However, I am about to change the action services in the near future so this format will vanish and be replaced by the device_id. Configuring actions will be a lot easier then. :slightly_smiling_face:

Putting the following into configuration.yaml throws errors

action: lcn.pck
data:
  address: linhk.0.117
  pck: R8M2GO70

Config

Does the action block need to be preceeded by something?

It seems that lcn.pck is not recognized. Does it work for you?

Yes, works for me. Maybe the integration name is wrong?

Service actions are typically triggered by an automation or script and therefore need to be embedded in their definition.

You can read more about this in Automation actions - Home Assistant. There are also several examples.

The integration is called LinHK. The name looks correct:
Host name

I added a test automation to my yaml:

automation:
- alias: "TEST Rollladen BĂźro"
  triggers:
    - trigger: state
      entity_id: binary_sensor.bewegung
      to: "on"
  actions:
    - action: lcn.pck
      data:
        address: LinHK.0.117
        pck: R8M2GO70    

This throws me an “Invalid host name” error upon execution. Same if I use pchk as host name.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 742, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lcn/services.py", line 395, in async_call_service
    device_connection = self.get_device_connection(service)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lcn/services.py", line 74, in get_device_connection
    raise ValueError("Invalid host name.")
ValueError: Invalid host name.

Any ideas where I could look to debug this?

Actually the LCN-PCK access appears to be functional. I just checked the log of my LinHK-coupling and found this:

[20241006 15:59:41.091655]  [error] invalid PCK command: >M000117.R8M2GO70

So the positioning command is correctly transmitted, but sadly not recognized by the control software. There is a support forum, yet I haven’t been on for years and wouldn’t even know if the programmer is still around. We will see.

Currently there is a bug in the address determination: If you renamed the integration entry after creating it, then the service actions will not adapt to that new name.
You have to use the original name (unfortunately it is not visible in the UI after changing it).
That bug will be fixed with the service action rework I mentioned above.

Actually the LCN-PCK access appears to be functional. I just checked the log of my LinHK-coupling and found this:

[20241006 15:59:41.091655]  [error] invalid PCK command: >M000117.R8M2GO70

So the positioning command is correctly transmitted, but sadly not recognized by the control software. There is a support forum, yet I haven’t been on for years and wouldn’t even know if the programmer is still around. We will see.

I don’ remember if I changed the name but I am able to control all entities placed on a dashboard, switch lights etc. on and off…

What is not working is the manual control under Development Tools | Actions.
pck error

This will systematically throw an error regardless of the selected pck command and whether I use the s and m address prefixes or not. I can see “invalid host” errors in the log but this time nothing is received by the connecting software, hence I assume that nothing gets sent.

I am a little bit confused because putting any command into the configuration.yaml seems to be issued by the integration.At least R8MxGO is received by my coupling software (I didn’t explicitely test the PI command in yaml). I assume that the manual control should not be different from the yaml, or is it? Maybe this will be cured with your next release.

Basically all automations defined in the configuration.yaml should call exactly the same functionality as called with the UI. I have no idea why the one method works while the other one doesn‘t.

Can you please check that you entered the integration name exactly as shown in the HA LCN integration settings (including upper/lowercase)?
In one of your posts it‘s „LinHK“ but in your screenshot it‘s „linhk“.

1 Like