Detection NUT

Parce que les applications du Raspberry Pi sont illimités...

Modérateur : Francois

Répondre
Bobyco
Messages : 6
Enregistré le : ven. 20 janv. 2017 17:49

Detection NUT

Message par Bobyco » mer. 13 févr. 2019 15:21

Bonjour,

Voila j'aimerai détecter ma présence quand je suis a la maison ou pas. J'ai un RPI 3 donc avec le bluetooth intégrer, avec la commande 'bluetoothctl' puis 'scan on' j'arrive a détecter mon NUT mini. J'ai trouvai un scripte shell :

Code : Tout sélectionner

#!/bin/bash

BLUETOOTHADDRCLEM="EA:91:0F:D0:E2:57" 
BLUETOOTHNAMECLEM="nut"
SLEEPTIME=10   # Check interval in s 
 
COUNTPRESENTCLEM=0
COUNTABSENTCLEM=0
 
while true
do
    DEVICECLEM=`hcitool name $BLUETOOTHADDRCLEM`
 
    if [[ $DEVICECLEM = $BLUETOOTHNAMECLEM ]]
    then
        COUNTPRESENTCLEM=$((COUNTPRESENTCLEM+1))
    else
        COUNTABSENTCLEM=$((COUNTABSENTCLEM+1))
    fi
 
        if [[ "$COUNTPRESENTCLEM" = 1 ]]        # 1 confirmation is OK to be sure Clement is here
        then
                # Do something here
                COUNTABSENTCLEM=0
                echo "$(date) - Present"
        fi
         
        if [[ "$COUNTABSENTCLEM" = 2 ]] # We need 3 confirmations to be sure Clement is really away
        then
                # Do something here
                COUNTPRESENTCLEM=0
                echo "$(date) - Absent"
        fi
 
    echo "$(date) - confirmation presence: $COUNTPRESENTCLEM"
    echo "$(date) - confirmation absence: $COUNTABSENTCLEM"
    sleep $SLEEPTIME
done
Alors avec mon iPhone j'arrive a détecter ma présence mais pas avec mon NUT mini. Vous aurez une idée ?

Répondre

Retourner vers « Et tout le reste »