https://github.com/ctron/mitemp-gateway
Drogue Cloud BLE Gateway for the Mi Temperature sensor 2
https://github.com/ctron/mitemp-gateway
Last synced: over 1 year ago
JSON representation
Drogue Cloud BLE Gateway for the Mi Temperature sensor 2
- Host: GitHub
- URL: https://github.com/ctron/mitemp-gateway
- Owner: ctron
- License: apache-2.0
- Created: 2021-05-26T15:00:20.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-15T10:21:34.000Z (over 4 years ago)
- Last Synced: 2025-01-04T23:25:48.441Z (over 1 year ago)
- Language: Python
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mi Temp BLE Gateway
This is a small agent, publishing Mi Temp 2 telemetry to a [Drogue IoT](https://drogue.io) instance.
## Installing
* Install Podman
* Fedora:
~~~shell
sudo dnf -y install podman
~~~
* Ubuntu 20.10 (including Raspberry Pi 3/4):
~~~shell
sudo apt -y install podman runc
~~~
* Running it once
podman run -net=host --privileged --rm -ti -e APP_ID=my-app -e DEVICE_ID=mitemp-gateway -e DEVICE_PASSWORD=device12 -e ENDPOINT=https://http-endpoint-drogue-iot.apps.your.cluster.tld -d ghcr.io/ctron/mitemp-gateway:latest
* Create a systemd unit (`/etc/systemd/system/mitemp-gateway.service`):
~~~ini
[Unit]
Description=MiTemp Gateway
[Service]
Restart=on-failure
ExecStartPre=/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
ExecStart=/usr/bin/podman run --rm --conmon-pidfile /%t/%n-pid --cidfile /%t/%n-cid -net=host --privileged -e APP_ID=my-app -e DEVICE_ID=mitemp-gateway -e DEVICE_PASSWORD=device12 -e ENDPOINT=https://http-endpoint-drogue-iot.apps.your.cluster.tld -d ghcr.io/ctron/mitemp-gateway:latest
ExecStop=/usr/bin/sh -c "/usr/bin/podman rm -f `cat /%t/%n-cid`"
KillMode=none
Type=forking
PIDFile=/%t/%n-pid
[Install]
WantedBy=multi-user.target
~~~
Be sure to replace the environment variables:
* `ENDPOINT` – HTTP endpoint in Drogue Cloud
* `APP_ID` – Application ID in Drogue Cloud
* `DEVICE_ID` – (Gateway) Device ID in Drogue Cloud (defaults to `mitemp-gateway` in this readme)
* `DEVICE_PASSWORD` – Password part of the device credentials
* Reload the daemon:
~~~shell
sudo systemctl daemon-reload
~~~
* Activate the unit
~~~shell
sudo systemctl enable --now mitemp-gateway.service
~~~
* Ensure to create one device per sensor, and a gateway in Drogue Cloud
* Create a gateway
~~~
drg create device --app my-app mitemp-gateway-ctron --spec '{
"credentials":{
"credentials":[
{"pass": "my-secret-password"}
]
}
}'
~~~
* Create a device per sensor, using the Bluetooth MAC (e.g. `12:34:56:78:9A:BC`)
~~~
drg create device --app my-app '12:34:56:78:9A:BC' --spec '{
"gatewaySelector": {
"matchNames": [
"mitemp-gateway-ctron"
]
}
}'
~~~