Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth service #505

Merged
merged 5 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RUN apk add --no-cache --virtual .build-deps make g++ git coreutils \
&& cd /tmp \
&& rm -rf /tmp/open-zwave

# Install Bluez dependencies
RUN apk add --no-cache bluez

# Install Gladys
RUN mkdir /src
Expand Down
Binary file added front/src/assets/integrations/cover/bluetooth.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions front/src/components/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ import TasmotaPage from '../routes/integration/all/tasmota/device-page';
import TasmotaEditPage from '../routes/integration/all/tasmota/edit-page';
import TasmotaDiscoverPage from '../routes/integration/all/tasmota/discover-page';

// Integrations Bluetooth
import BluetoothDevicePage from '../routes/integration/all/bluetooth/device-page';
import BluetoothEditDevicePage from '../routes/integration/all/bluetooth/edit-page';
import BluetoothSetupPage from '../routes/integration/all/bluetooth/setup-page';
import BluetoothSetupPeripheralPage from '../routes/integration/all/bluetooth/setup-page/setup-peripheral';

const defaultState = getDefaultState();
const store = createStore(defaultState);

Expand Down Expand Up @@ -178,6 +184,11 @@ const AppRouter = connect(
<TasmotaEditPage path="/dashboard/integration/device/tasmota/edit/:deviceSelector" />
<TasmotaDiscoverPage path="/dashboard/integration/device/tasmota/discover" />

<BluetoothDevicePage path="/dashboard/integration/device/bluetooth" />
<BluetoothEditDevicePage path="/dashboard/integration/device/bluetooth/:deviceSelector" />
<BluetoothSetupPage path="/dashboard/integration/device/bluetooth/setup" />
<BluetoothSetupPeripheralPage path="/dashboard/integration/device/bluetooth/setup/:uuid" />

<ChatPage path="/dashboard/chat" />
<MapPage path="/dashboard/maps" />
<CalendarPage path="/dashboard/calendar" />
Expand Down
196 changes: 195 additions & 1 deletion front/src/config/demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1293,5 +1293,199 @@
}
]
}
]
],
"get /api/v1/service/bluetooth": {
"id": "a810b8db-6d04-4697-bed3-c4b72c996279",
"name": "bluetooth",
"enabled": true
},
"get /api/v1/service/bluetooth/device": [
{
"id": "fbedb47f-4d25-4381-8923-2633b23192a0",
"service_id": "a810b8db-6d04-4697-bed3-c4b72c996279",
"room_id": "cecc52c7-3e67-4b75-9b13-9a8867b0443d",
"name": "Nut Smart Tracker",
"selector": "bluetooth-sensor",
"external_id": "test-sensor-external",
"should_poll": false,
"poll_frequency": null,
"created_at": "2019-02-12T07:49:07.556Z",
"updated_at": "2019-02-12T07:49:07.556Z",
"features": [
{
"name": "Battery",
"selector": "test-battery",
"category": "battery",
"type": "integer",
"last_value": "12"
}
],
"room": {
"id": "cecc52c7-3e67-4b75-9b13-9a8867b0443d",
"name": "Living Room",
"selector": "living-room"
}
}
],
"get /api/v1/device/bluetooth-sensor": {
"id": "fbedb47f-4d25-4381-8923-2633b23192a0",
"service_id": "a810b8db-6d04-4697-bed3-c4b72c996279",
"room_id": "cecc52c7-3e67-4b75-9b13-9a8867b0443d",
"name": "Nut Smart Tracker",
"selector": "bluetooth-sensor",
"external_id": "bluetooth:external",
"should_poll": false,
"poll_frequency": null,
"created_at": "2019-02-12T07:49:07.556Z",
"updated_at": "2019-02-12T07:49:07.556Z",
"features": [
{
"name": "Battery",
"selector": "test-battery",
"category": "battery",
"type": "integer",
"last_value": "12"
}
],
"room": {
"id": "cecc52c7-3e67-4b75-9b13-9a8867b0443d",
"name": "Living Room",
"selector": "living-room"
}
},
"get /api/v1/service/bluetooth/status": {
"bluetoothStatus": "ready"
},
"get /api/v1/service/bluetooth/peripheral": [
{
"name": "BLE Device 1",
"external_id": "bluetooth:0011223341",
"selector": "bluetooth-0011223341",
"params": [
{
"name": "loaded",
"value": false
}
]
},
{
"name": "SML c9",
"model": "smlc9",
"external_id": "bluetooth:0011223342",
"selector": "bluetooth-0011223342",
"params": [
{
"name": "loaded",
"value": true
},
{
"name": "manufacturer",
"value": "AwoX"
}
]
},
{
"name": "Peanut temperature",
"external_id": "bluetooth:0011223343",
"selector": "bluetooth-0011223343",
"params": [
{
"name": "loaded",
"value": true
},
{
"name": "manufacturer",
"value": "Peanut"
}
],
"features": [
{
"name": "Battery",
"category": "battery",
"type": "integer",
"unit": "percent",
"read_only": true,
"keep_history": true,
"has_feedback": true,
"min": 0,
"max": 100
},
{
"name": "Temperature",
"category": "temperature-sensor",
"type": "decimal",
"read_only": true,
"keep_history": true,
"has_feedback": true,
"min": -100,
"max": 250
}
]
}
],
"get /api/v1/service/bluetooth/peripheral/bluetooth-0011223341": {
"name": "BLE Device 1",
"external_id": "bluetooth:0011223341",
"selector": "bluetooth-0011223341",
"params": [
{
"name": "loaded",
"value": false
}
]
},
"get /api/v1/service/bluetooth/peripheral/bluetooth-0011223342": {
"name": "SML c9",
"model": "smlc9",
"external_id": "bluetooth:0011223342",
"selector": "bluetooth-0011223342",
"params": [
{
"name": "loaded",
"value": true
},
{
"name": "manufacturer",
"value": "AwoX"
}
]
},
"get /api/v1/service/bluetooth/peripheral/bluetooth-0011223343": {
"name": "Peanut temperature",
"external_id": "bluetooth:0011223343",
"selector": "bluetooth-0011223343",
"params": [
{
"name": "loaded",
"value": true
},
{
"name": "manufacturer",
"value": "Peanut"
}
],
"features": [
{
"name": "Battery",
"category": "battery",
"type": "integer",
"unit": "percent",
"read_only": true,
"keep_history": true,
"has_feedback": true,
"min": 0,
"max": 100
},
{
"name": "Temperature",
"category": "temperature-sensor",
"type": "decimal",
"read_only": true,
"keep_history": true,
"has_feedback": true,
"min": -100,
"max": 250
}
]
}
}
44 changes: 44 additions & 0 deletions front/src/config/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,50 @@
"buttonSave": "Save",
"buttonCleanUp": "Clean Up",
"buttonSync": "Sync now"
},
"bluetooth": {
"title": "Bluetooth",
"description": "Control your Bluetooth devices.",
"deviceTab": "Devices",
"setupTab": "Setup",
"device": {
"title": "Bluetooth Devices",
"search": "Search devices",
"noDevices": "No Bluetooth devices added yet.",
"noFeatures": "No features",
"nameLabel": "Name",
"namePlaceholder": "Enter device name",
"roomLabel": "Room",
"externalIdLabel": "External ID",
"manufacturerLabel": "Fabricant",
"modelLabel": "Modèle",
"featuresLabel": "Features",
"noFeatureDiscovered": "No features discovered.",
"featureNamePlaceholder": "Enter feature name",
"saveButton": "Save",
"deleteButton": "Delete",
"editButton": "Edit"
},
"setup": {
"title": "Bluetooth Setup",
"bluetoothNotReadyError": "Bluetooth device is not reachable, please check it is enabled.",
"scanButton": "Scan",
"reloadButton": "Reload",
"noDeviceFound": "No bluetooth device discovered.",
"createDeviceInGladys": "Connect in Gladys",
"updateDeviceInGladys": "Update in Gladys",
"deviceCreatedSuccess": "The device was successfully added",
"createDeviceError": "There was an error while creating this device in Gladys. ",
"saveSuccess": "Bluetooth device successfully created.",
"saveError": "There was an error creating the device.",
"peripheral": {
"title": "Bluetooth Peripheral Configuration",
"notAvailable": "Peripheral is not available, please scan again.",
"createLabel": "Create",
"cancelLabel": "Cancel",
"successLabel": "Done"
}
}
}
},
"editScene": {
Expand Down
44 changes: 44 additions & 0 deletions front/src/config/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,50 @@
"buttonCleanUp": "Remettre à zéro",
"buttonSync": "Synchroniser"
},
"bluetooth": {
"title": "Bluetooth",
"description": "Contrôler vos appareils Bluetooth.",
"deviceTab": "Appareils",
"setupTab": "Configuration",
"device": {
"title": "Appareils Bluetooth",
"search": "Chercher un appareil",
"noDevices": "Aucun appareil Bluetooth n'a encore été ajouté.",
"noFeatures": "Aucune fonctionnalité",
"nameLabel": "Nom de l'appareil",
"namePlaceholder": "Entrez le nom de votre appareil",
"roomLabel": "Pièce",
"externalIdLabel": "ID externe",
"manufacturerLabel": "Manufacturer",
"modelLabel": "Model",
"featuresLabel": "Fonctionnalités",
"noFeatureDiscovered": "Aucune fonctionnalité détectée.",
"featureNamePlaceholder": "Nom de la fonctionnalité",
"saveButton": "Sauvegarder",
"deleteButton": "Supprimer",
"editButton": "Editer"
},
"setup": {
"title": "Configuration Bluetooth",
"scanButton": "Rechercher",
"reloadButton": "Recharger",
"bluetoothNotReadyError": "Le module Bluetooth n'est pas disponible, merci de vérifier qu'il est bien activé.",
"noDeviceFound": "Aucun périphérique Bluetooth détecté.",
"createDeviceInGladys": "Connecter dans Gladys",
"updateDeviceInGladys": "Mettre à jour dans Gladys",
"deviceCreatedSuccess": "L'appareil a été ajouté avec succès.",
"createDeviceError": "Une erreur s'est produite lors de la création de cet appareil dans Gladys.",
"saveSuccess": "L'appareil Bluetooth a été créé avec succés.",
"saveError": "Une erreur est survenue lors de la création de l'appareil.",
"peripheral": {
"title": "Configuration d'un appareil Bluetooth",
"notAvailable": "L'appareil n'est pas disponible, merci de faire une nouvelle recherche.",
"createLabel": "Créer",
"cancelLabel": "Annuler",
"successLabel": "Effectué"
}
}
},
"telegram": {
"title": "Telegram",
"description": "Parlez à Gladys grâce à Telegram.",
Expand Down
4 changes: 4 additions & 0 deletions front/src/config/integrations/devices.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@
{
"key": "tasmota",
"img": "/assets/integrations/cover/tasmota.jpg"
},
{
"key": "bluetooth",
"img": "/assets/integrations/cover/bluetooth.jpg"
}
]
49 changes: 49 additions & 0 deletions front/src/routes/integration/all/bluetooth/BluetoothPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Text } from 'preact-i18n';
import { Link } from 'preact-router/match';

const BluetoothPage = ({ children, ...props }) => (
<div class="page">
<div class="page-main">
<div class="my-3 my-md-5">
<div class="container">
<div class="row">
<div class="col-lg-3">
<h3 class="page-title mb-5">
<Text id="integration.bluetooth.title" />
</h3>
<div>
<div class="list-group list-group-transparent mb-0">
<Link
href="/dashboard/integration/device/bluetooth"
activeClassName="active"
class="list-group-item list-group-item-action d-flex align-items-center"
>
<span class="icon mr-3">
<i class="fe fe-radio" />
</span>
<Text id="integration.bluetooth.deviceTab" />
</Link>

<Link
href="/dashboard/integration/device/bluetooth/setup"
activeClassName="active"
class="list-group-item list-group-item-action d-flex align-items-center"
>
<span class="icon mr-3">
<i class="fe fe-sliders" />
</span>
<Text id="integration.bluetooth.setupTab" />
</Link>
</div>
</div>
</div>

<div class="col-lg-9">{children}</div>
</div>
</div>
</div>
</div>
</div>
);

export default BluetoothPage;
Loading