Category: Non classé

Using the REST api to read sensors on Home assistant

During one of my little project of making timelapses videos with some IP cameras, I had the following problem : How do you stop capturing new images at night when the camera see nothing,
After all , the sun rise and sun set time are changing everyday ! and i didn’t see a simple way to calculate this.
then i remembered the sun.sun integration in Home assistant.

If i had a simple way to query this integration in my script , i could very simply stop my script when the sun was no longer present in the sky !

The Home assistant REST API

In any home assistant installation there is access to a REST API that lets you do a lot a things , but in my case, I don’t want much , I just want to know if the sun is above or below the horizon.

  1. Get a Authorization: Bearer token
    you first have to generate a token to authenticate your request . You have to go to your user section , this is the circle a the bottom of the toolbar, then at the bottom of the page , you can create a long term token ,
    Please take note of this token because Home assitant can only display it one time , if you loose it , you must recreate an other one.
  2. Then in my script i can use this
  3. it will return either above_horizon or below_horizon, I can then use this in my script to stop the capture when it’s below_horizon

I used jq filter the json result , but , if you can’t or don’t want to install it , you can replace it with this simple awk

Bazooka lance-patates

Un Allemand a ?t? arr?t? parce qu’il tirait sur les passants avec un bazooka lance-pommes de terre de fabrication artisanale, a-t-on appris vendredi aupr?s de la police d’Essen, dans l’ouest du pays.

“C’?tait comme un bazooka qui tirait des pommes de terre”, a expliqu? un porte-parole de la police. “Une arme rudement dangereuse ? courte port?e.”

Selon la police, l’homme avait fabriqu? lui-m?me son arme, constitu?e d’un tuyau de vidange long d’un m?tre cinquante reli? ? une bombe a?rosol, dont il enflammait le gaz pour propulser les pommes de terre vers leur cible.

Le suspect, ?g? de 33 ans, a ?t? inculp? pour tentatives de coups et blessures et violation de la l?gislation sur les armes ? feu.

source yahoo.fr actualit?e