Flic hub http post --》 extract battery from header

I have managed to integrate the flic buttons presses via the flic hub http requests (api/events) :slight_smile: thx to alot of posts in this community.

I want to take it a step further and read that the battery level of the buttons are in the header of the post from the hub.
Any one succeeded in that?
"
The HTTP header does contain the following information: button-serial-number; button-battery-level; button-name.
"

I can only see the body of the request when listening to the event.

Thx

I would also like that +1

I got β€œRed Node” up and running as I hoped to be able to extract the header information from the http request fromt he flic hub. But with no luck. The msg.headers does not exists and the other "id"s does not contain what I hoped to find.

To make sure that the battery level actually are in the header information I put up at python-very-simple-http-server to listent to the requests from the http request from the flic-hub. I got the following result:

10.0.0.99 - - [31/Jan/2021 21:50:02] "GET /favicon.ico HTTP/1.1" 200 -
INFO:root:POST request,
Path: /api/events/test
Headers:
Accept-Encoding: gzip
Authorization: Bearer --censored---
User-Agent: Google-HTTP-Java-Client/1.23.0 (gzip)
button-serial-number: Bearer_censored
button-battery-level: 100
button-name: Test
timestamp: 2021-01-31T20:50:10Z
Content-Type: json
Cache-Control: no-cache
Pragma: no-cache
Host: 10.0.0.99:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: close
Content-Length: 49

As it is seen above header does indeed include the battery level, but I do not know how to extract that information when the HA receives the request from the flic hub via /api/events/test .
Does anyone have an idea to extract the header information on received requests?

I hope you get it working +1

I actually made it work.
It was a long shot and probably not the optimal solution.

What I did was:

  1. create each Button battery from template in the configuration.yaml
  2. created a dockerized webservice that split the http request into an api/evnets/flic and another one which posts an update to /api/state/sensor.flic_button1 (example). The webserver change the original flic post battery level from the header to state in the body.

That’s basically it.
It took some time and there probably a lot easier way through but I have not enough knowledge about the HA frame work.
In the end of the day I made it, but it is difficult to share…

I’ll give it a go, thanks a lot!