Fibaro integration - button support

Hi All,

I’ve added a Fibaro Button to my Yubii:

Unfortunately it seems not to be supported by the Fibaro HA integration

The trigger won’t be forwarded to Home Assistant.

It would be a nice addition as the products seems to be very solid.

Would love, if someone could have a look into it. I am unfortunately only an end user :frowning:

I would like to join this request. It would be great to be able to use the Button as an emergency button.
I’ve tried various settings in Fibaro HLC2 and HCL3, but couldn’t find anything that would make the Button show up as an entity in HA.

1 Like

Hi @RuudvanMunster not sure if this will become available. Guess it is easier to buy a silicon labs (silabs.com) z-wave stick and bring the button into HA with this blueprint:
ZWave-JS - Fibaro The Button (FGPB-101) v2021.12.08

I am thinking about switching from yubii to ZWave-JS with as this seems more clear to me. But I am not sure, if the motion sensor is still as finely adjustable as it is with the fibaro box
->EDIT: …you can! google was my friend…

I dived into the topic and basically it is possible to implement that as fibaro push channel forwards central scene events to HA when a button is pressed.
Unfortunately the fibaro integration currently does not implement any HA events and triggers so it is a bigger change in HA needed to get this feature done.
If I find time I will try to implement it, but do not expect that to happen soon. If someone likes to help out implementing this feature I’m happy to provide more information about what I found out already.

Is this because Fibaro has a different implementation for The Button and e.g. the Motionsensor? The Motionsensor is “on” for a short time, but that seems to be enough to trigger an automation in HA. I was hoping for something similar.
I can imagine it is quite a job for you to implement a solution for the button. I do not understand enough yet about the integration mechanism to be of value for helping to implement.
Are there ways around?
One I can imagine is to create a script or association to switch a device. And use the state of that device as a trigger within HA.
As far as a know, Fibaro does not have a mechanism of “variables” that can be set from pressing The Button?

I am considering that as well. I like the Fibaro integration. It makes my system more modular. And it might also somewhat offload the HA system itself. Although I have no idea if that is so and to what extend.
A solution for the short term might also be to use the Z-wave-JS solution for the Button only. It also helps me understand the cons and pros of both approaches. From a power consumption point of view using a z-wave stick might be better than the Fibaro Home Center (Light).

Connecting events from other systems to entities in HA is discouraged and should therefore not be made.

If you like to create a workaround it should be possible to create a scene in fibaro which reacts on the button press event and calls a webhook on home assistant.

HA doc for webhooks: Automation Trigger - Home Assistant

Thanx, I really like the idea of ​​a webhook.

I completed the HA side of this webhook, which was actually very simple. The webhook has been tested with sw following cURL string and then works properly.

curl -X POST -H 'Content-Type: application/json' http://homeassistant:8123/api/webhook/<webhook_ID>

Unfortunately from the Fibaro side it is quite a challenge for me. :grin:
I was able to create a Lua scene within Fibaro that reacts to the button. The Declarations part responds nicely to impressions of The Button. That looks like this:

{
  conditions = { {
      id = 150,
      isTrigger = true,
      operator="==",
      property = "centralSceneEvent",
      type = "device",
      value = {
        keyAttribute = "Pressed",
        keyId = 1
      }
    } },
  operator = "all"
}

If I test that with the action send e-mail, it works perfectly:

hub.alert('email', {[1] = 29, }, 'The Button has been pushed', false, '')

This code was provided by the editor of HCL3.

I did find something that can do an HTTP POST:

api.post(http://homeassistant:8123/api/webhook/<webhook_ID>, ??????)`

And then I got stuck. And so far searching in forums etc. has yielded little to fill in the missing question marks.

Do you have any suggestions on how I can proceed with this?

Here are many ideas: https://forum.fibaro.com/topic/54857-lua-or-qa-to-run-http-url-powerviewluxaflexhunterdouglas/

If I understand it correctly something like that should do it in HC3.

net.HTTPClient():request('http://homeassistant:8123/api/webhook/<webhook_ID>', {
    options={
      headers = {
        ['Content-Type'] = 'application/json',
      },
      method = 'POST',
    },
    success = function(response) 
            print(response.status)
            print(response.data)
    end,
    error = function(message)
            print("error:", message)
    end
})

Not sure if the network local name homeassistant works, probably you can try as well with the IP address instead.

Almost there. At least the webhook arrives in Home Assistant. With the correct webhook_ID. However, does not work due to a JSON decode error.

2022-11-09 22:53:58.534 ERROR (MainThread) [homeassistant.components.webhook] Error processing webhook <webhook_id>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/webhook/__init__.py", line 129, in async_handle_webhook
    response = await webhook["handler"](hass, webhook_id, request)
  File "/usr/src/homeassistant/homeassistant/components/webhook/trigger.py", line 42, in _handle_webhook
    base_result["json"] = await request.json()
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_request.py", line 663, in json
    return loads(body)
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I will try more after checking the link you have send me. I am in a steep learning curve. This kind of programming is rather unknown territory for me. :slight_smile:

It works! With a twist. :grinning:

The error message in HA appears to be caused by missing a JSON payload. By adding a dummy payload, the webhook works fine now. See the code below:

> local url = "http://192.168.50.25:8123/api/webhook/"
> local hook = "<Webhook_ID>"
> local urlhook = url .. hook
> local headers = {
>         ["Content-Type"] = 'application/json',
>     }
> local payload = '{"Text:" : "This is non-sense"}'
> 
> net.HTTPClient():request(urlhook, {
>     options = {
>       method = 'POST',
>       headers = headers,
>       data = payload,
>       timeout = 5000
>     },
>     success = function(response) 
>             print(response.status)
>             print(response.data)
>     end,
>     error = function(message)
>             print("error:", message)
>     end
>   })

I also added the use of some local variables to make the main code more readable.

Again thanks a lot!
To me, this looks like a good alternative for adding support for “The Button”.

1 Like