Custom Component: Nikobus

With feedback module unchecked, the states are correct.
When the state is updated by the feedback module,
you are always considering the message as a group-1 message, also when it is a group-2 one.

2024-06-27 16:13:33.641 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1CAD910000FF0000000083465C
2024-06-27 16:13:33.641 DEBUG (MainThread) [custom_components.nikobus.nkblistener] ** Feedback module refresh command answer: $1CAD910000FF0000000083465C
2024-06-27 16:13:33.642 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=91AD, group=1, module_state=00FF00000000

2024-06-27 16:15:47.030 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1CAD910000FF00FF00004C251A
2024-06-27 16:15:47.030 DEBUG (MainThread) [custom_components.nikobus.nkblistener] ** Feedback module refresh command answer: $1CAD910000FF00FF00004C251A
2024-06-27 16:15:47.031 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=91AD, group=1, module_state=00FF00FF0000

2024-06-27 16:16:53.708 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1CAD910000FF0000000083465C
2024-06-27 16:16:53.709 DEBUG (MainThread) [custom_components.nikobus.nkblistener] ** Feedback module refresh command answer: $1CAD910000FF0000000083465C
2024-06-27 16:16:53.709 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=91AD, group=1, module_state=00FF00000000

2024-06-27 16:19:07.097 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1CAD910000FF00FF00004C251A
2024-06-27 16:19:07.098 DEBUG (MainThread) [custom_components.nikobus.nkblistener] ** Feedback module refresh command answer: $1CAD910000FF00FF00004C251A
2024-06-27 16:19:07.098 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=91AD, group=1, module_state=00FF00FF0000

I see, so due to the fact you are connected to the feedback module and not a pc-link module, you do not get the refresh request command

in this example

Feedback module refresh command: $10170747ABDBF7

$1012 means group 1
$1017 means group 2

2024-06-27 14:04:04.471 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $10170747ABDBF7
2024-06-27 14:04:04.471 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Feedback module refresh command: $10170747ABDBF7
2024-06-27 14:04:04.627 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1C074700000000000000981112
2024-06-27 14:04:04.627 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Feedback module refresh command answer: $1C074700000000000000981112
2024-06-27 14:04:04.627 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=4707, group=2, module_state=000000000000

As you are directly connected to feedback module, this command is not shared on the bus. Do you have a pc-link ? then move the connection towards the pc-link module or else 2 options

a- keep using integration refresh rate
b- I need to find a way to understand if the refresh if for group 1 or 2 without having the refresh command input.

No option B :frowning:

The output is exactly the same $1C074700000000000000981112 for group 1 or 2 refresh, so without the command

$10120747402BFC
or
$10170747402BFC

it is not possible to know if the refresh is for group 1 or 2

2024-06-27 14:04:37.512 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $10120747402BFC
2024-06-27 14:04:37.512 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Feedback module refresh command: $10120747402BFC
2024-06-27 14:04:37.668 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1C074700000000000000981112
2024-06-27 14:04:37.668 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Feedback module refresh command answer: $1C074700000000000000981112
2024-06-27 14:04:37.668 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=4707, group=1, module_state=000000000000

2024-06-27 14:05:10.551 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $10170747ABDBF7
2024-06-27 14:05:10.551 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Feedback module refresh command: $10170747ABDBF7
2024-06-27 14:05:10.707 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Listener - Receiving message: $1C074700000000000000981112
2024-06-27 14:05:10.707 DEBUG (MainThread) [custom_components.nikobus.nkblistener] Feedback module refresh command answer: $1C074700000000000000981112
2024-06-27 14:05:10.708 DEBUG (MainThread) [custom_components.nikobus.nikobus] Processing feedback module data: module_address=4707, group=2, module_state=000000000000

So, will be trying to force the feedback module to share this data in the bus or else if you do not have pc-link I need to adapt the code so you can have a custom refresh rate and a feedback-module. using the custom refresh rate today disables the feedback module so your feedback led will not work.

I donā€™t have a pc link module. However, there is a distinction in the last 6 characters of the received message, so you can know that it is for an other group.

In my example, it is like this (based on real situation with the lights right now):

  • message ends with 83465C: first 6 outputs
  • message ends with 4C251A: last 6 outputs

So a quick-n-dirty solution can be an optional suffix in the config of the controller.

On the other hand, I think this is working fine in the nikobus binding in openhab, Iā€™ll test that in a bit. Perhaps we can ā€˜borrowā€™ some logic overthereā€¦

OpenHAB use a custom refresh rate, as in this integration, so no problem using that.

Problem is your feedback led will not work IF you work with module outputs.
They will work if you use the buttons defined in the integration.

So basically, with current version and custom refresh rate, you will have the exact same behaviour as in openhab.

I will switch to feedback module connect to check

As a new user on this forum, I canā€™t add any more new replies in this topicā€¦
So I edit this one:

Meanwhile I have added all my nikobus buttons to the config.
Indeed, the system with loading only the impacted modules works really great!
I have configured HA in combination with Nikobus almost completely as I like it now.

I had a look at the led functionality, but Iā€™m not sure what it should doā€¦ At the moment, the leds are controlled by the nikobus hardware/software, what exactly should the HA Integration do with that?

I know how to calculate checksum for commands

Nikobus-HA/custom_components/nikobus/nkbprotocol.py at main Ā· fdebrus/Nikobus-HA (github.com)

I guess itā€™s similar for answers ?

yet, the checksum will vary from one install to another as module addresses are differents, so it could be done but complex.

I was thinking to ask the user at integration setup time what connectivity is used. based on user input (pc link, feedback module) I can then change the logic towards

Connected to PC-LINK without FEEDBACK

  • Custom refresh only

Connected to PC-LINK with FEEDBACK

  • Custom
    or
  • Feedback

Connected to FEEDBACK

  • Custom refresh only but still enables the LED logic for the modules outputs, which is not the case today.

Will reflect a bitā€¦

New release, have a try Release Nikobus 2024.6.28 Ā· fdebrus/Nikobus-HA (github.com)

thank you for the work here! i will report back once i figured the pc module out

Hello,

Everything is working file. I can switch everything from HA and I get all feedbacks to HA is a button is pressed.
Now I wanted to add an automation when a Nikobus-button is pressed 3 seconds.
How exactly can I configure this.
I can only select if the button is ON, OFF or pressed.

I think I found it. I will test this.

alias: "React to Nikobus Button Push"
description: "Perform actions when a Nikobus button is reported as pressed."
trigger:
  - platform: event
    event_type: **nikobus_button_pressed**
    event_data:
      address: **"specific_button_address"**  # Optional: Specify to react to a specific button
action:
  - service: homeassistant.toggle
    entity_id: light.example_light

In this code, you can replace nikobus_button_pressed with any of the below

nikobus_button_pressed
nikobus_button_released
nikobus_long_button_pressed
nikobus_short_button_pressed
nikobus_button_pressed_0
nikobus_button_pressed_1
nikobus_button_pressed_2
nikobus_button_pressed_3

Then as needed you can also specify specific_button_address if you need the automation to react on a specific button press.

so to your exmaple

alias: "inkom"
description: "automation for inkom"
trigger:
  - platform: event
    event_type: nikobus_button_pressed_3
    event_data:
      address: "C5E952"
action:
  - service: homeassistant.toggle
    entity_id: light.example_light

Alternativly your can use the defined button sensor to detect a press, but I recommand using the above as it use the home assistant event bus and much more flexible. Itā€™s up to your use case to go for one or the other, for a 3 sec event press detection go for the event bus.

So if you take action on defined button in HA, or on physical Nikobus button, LED will behave accordingly.

Now, if you go to a module page where all outputs are defined, you can also take action on those button and it will trigger the LED if you have defined a ON/OFF address in the module_config.json file.

Send me PM, if you canā€™t post anymore :slight_smile:

Hi,

I have a problem after installing the latest update (or the update before)

Now I canā€™t control wy switch module anymore from HA

I get the error
ha1

Logger: homeassistant.components.automation.react_to_nikobus_button_push
Bron: helpers/script.py:526
integratie: Automatisering (documentatie, problemen)
Eerst voorgekomen: 13:15:39 (1 gebeurtenissen)
Laatst gelogd: 13:15:39

React to Nikobus Button Push: Error executing script. Unexpected error for call_service at pos 1: 'led_on'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, 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 2741, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 977, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1049, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/nikobus/switch.py", line 68, in async_turn_on
    await self._dataservice.api.turn_on_switch(self._address, self._channel)
  File "/config/custom_components/nikobus/nikobus.py", line 169, in turn_on_switch
    led_on = self.dict_module_data["switch_module"][address]["channels"][channel - 1]["led_on"]

itā€™s a RTFM situation :slight_smile: You need to update your module_config file.
Sorry, this is a breaking change to support button with feedback led, even if you do not have any, module_config file has to be updated

New Feature

Feedback led management: Feedback led are now managed when trigering modules outputs. Update your module.json config file according the readme for this to work.

Fix

For users having a Feedback Module:

  • If you are connected to the Feedback Module without a PC-Link in the installation setup or later in configuration, leave the box unchecked.
  • If you are connected to a PC-Link and have a Feedback Module, check the box either during setup or later through the configuration option (refer to the readme for details).

Thank you, now I can control the switch modules again.

I noticed an error in the log-file.
I donā€™t have any dimmer-modules in my configuration

Error while setting up nikobus platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 366, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/nikobus/light.py", line 23, in async_setup_entry
    for address, dimmer_module_data in dataservice.api.dict_module_data['dimmer_module'].items()
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'dimmer_module'

Nice to hear !

On the dimmer module matter, you just found a bug. thank you ! will correct for next release.

The reason why I updated the addin is because I wanted to test the 3sec press.
Unfortely, it didnā€™t work.

this is the yaml

alias: Alles uit aan inkom
description: Alles uit aan inkom
trigger:
  - platform: event
    event_type: nikobus_button_pressed_3
    event_data:
      address: DE4AD2
action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.s2_06

If I run it manualy, the light goes on.

Even the time in the automation screen is updated, but light stays out
ha2

I was thinking that I wade a bad test, because I wanted to switch on a nikobus-item with a nikobus-button with HA. Normaly you donā€™t do that , because that is configured into Nikobus. Olso, the bus will be occopied by pressing 3 sec a button, so you canā€™t send a nokobus event.

Thats why a made another test. I wanted to swith a ā€˜Helperā€™-swith on.
Unfortunately this didnā€™t work either

alias: Alles uit aan inkom
description: Alles uit aan inkom
trigger:
  - platform: event
    event_type: nikobus_button_pressed_3
    event_data:
      address: DE4AD2
action:
  - service: input_boolean.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.sfeer

You can check that the event is fired with the right address by listening to events ā€œnikobus_button_pressed_3ā€ in the developer tools.