Cours:InfoEmbarquee : Différence entre versions
(→support utilisé) |
|||
Ligne 1 : | Ligne 1 : | ||
− | |||
− | + | Séances : | |
− | + | *[[Cours:InfoEmbarqueeConcommationMicroC|Analyse de la consommation d'un µcontroleur]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=script shell= | =script shell= |
Version du 13 septembre 2023 à 09:07
Séances :
script shell
mqtt
HA mqtt sensor
- https://www.home-assistant.io/integrations/sensor/
- https://github.com/home-assistant/core/blob/dev/homeassistant/const.py#L489
/usr/local/bin/createHaSensor :
#!/bin/bash
echo "name : $1"
echo "device class : $2"
echo "unit : $3"
topic="homeassistant/sensor/$1/config"
payload="{\"name\": \"$1\", \
\"unique_id\": \"$1\", \
\"state_topic\": \"homeassistant/sensor/$1/state\", \
\"device_class\":\"$2\", \
\"unit_of_measurement\":\"$3\" \
}"
mosquitto_pub -t "$topic" -m "$payload" -h 192.168.0.7
/usr/local/bin/deleteHaSensor :
#!/bin/bash
echo "name : $1"
echo "device class : $2"
echo "unit : $3"
topic="homeassistant/sensor/$1/config"
mosquitto_pub -t "$topic" -m "" -h 192.168.0.7
/usr/local/bin/publishHaSensor :
#!/bin/bash
echo "name : $1"
echo "valeur : $2"
topic="homeassistant/sensor/$1/state"
payload="{\"name\": \"$1\", \
\"unique_id\": \"$1\", \
\"state_topic\": \"homeassistant/sensor/$1/state\", \
\"device_class\":\"$2\", \
\"unit_of_measurement\":\"$4\" \
}"
mosquitto_pub -t "$topic" -m "$2" -h 192.168.0.7