From b5d47a0ae2af57229b574b7604825caef1b5f787 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 14 Oct 2019 13:07:46 +0200 Subject: [PATCH 1/2] FlowerCare: Add a refresh rate setting --- flowercare/README.md | 7 ++++++- flowercare/devicepluginflowercare.cpp | 11 ++++++++++- flowercare/devicepluginflowercare.json | 9 +++++++++ .../74e2106a-3407-4e89-a27a-1c890d78bee7-en_US.ts | 5 +++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/flowercare/README.md b/flowercare/README.md index ac89f491..ad232906 100644 --- a/flowercare/README.md +++ b/flowercare/README.md @@ -1,4 +1,9 @@ # Flowercare -This pluggin provides support for the Bluetooth LE [Xiaomi Flower Care Monitor](https://xiaomi-mi.com/sockets-and-sensors/xiaomi-huahuacaocao-flower-care-smart-monitor/). +This plugin provides support for the Bluetooth LE +[Xiaomi Flower Care Monitor](https://xiaomi-mi.com/sockets-and-sensors/xiaomi-huahuacaocao-flower-care-smart-monitor/). + +The Xiaomi Flower Care sensor will provide information about temperature, soil moisture and conductivity as well as light intensity. +By default, the sensor value is refreshed from the sensor every 20 minutes. This setting can be changed to poll the sensor more or +less often, depending if more precise measurements or longer battery life are more important. diff --git a/flowercare/devicepluginflowercare.cpp b/flowercare/devicepluginflowercare.cpp index faee3ec7..2f9303b6 100644 --- a/flowercare/devicepluginflowercare.cpp +++ b/flowercare/devicepluginflowercare.cpp @@ -117,6 +117,15 @@ void DevicePluginFlowercare::setupDevice(DeviceSetupInfo *info) connect(m_reconnectTimer, &PluginTimer::timeout, this, &DevicePluginFlowercare::onPluginTimer); } + // Update refresh schedule when the refresh rate setting is changed + connect(device, &Device::settingChanged, flowerCare, [this, device] { + FlowerCare *flowerCare = m_list.value(device); + int refreshInterval = device->setting(flowerCareSettingsRefreshRateParamTypeId).toInt(); + if (m_refreshMinutes[flowerCare] > refreshInterval) { + m_refreshMinutes[flowerCare] = refreshInterval; + } + }); + info->finish(Device::DeviceErrorNoError); } @@ -183,5 +192,5 @@ void DevicePluginFlowercare::onSensorDataReceived(quint8 batteryLevel, double de device->setStateValue(flowerCareMoistureStateTypeId, moisture); device->setStateValue(flowerCareConductivityStateTypeId, fertility); - m_refreshMinutes[flowerCare] = 20; + m_refreshMinutes[flowerCare] = device->setting(flowerCareSettingsRefreshRateParamTypeId).toInt(); } diff --git a/flowercare/devicepluginflowercare.json b/flowercare/devicepluginflowercare.json index 468aa2eb..6f66846b 100644 --- a/flowercare/devicepluginflowercare.json +++ b/flowercare/devicepluginflowercare.json @@ -23,6 +23,15 @@ "inputType": "MacAddress" } ], + "settingsTypes": [ + { + "id": "e892d118-336e-4495-ae41-0c7cc907efe8", + "name": "refreshRate", + "displayName": "Refresh rate (minutes)", + "type": "uint", + "defaultValue": 20 + } + ], "stateTypes": [ { "id": "6254103a-ff8b-4f62-afda-6b5be1c933ec", diff --git a/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-en_US.ts b/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-en_US.ts index 7855b217..20626da9 100644 --- a/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-en_US.ts +++ b/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-en_US.ts @@ -119,5 +119,10 @@ The name of the StateType ({7e0a3b3d-72f4-4547-bd1e-2711be61c1a7}) of DeviceClas The name of the StateType ({f77608b3-8b5b-43a9-aab6-0dc35c694ec3}) of DeviceClass flowerCare + + Refresh rate (minutes) + The name of the ParamType (DeviceClass: flowerCare, Type: settings, ID: {e892d118-336e-4495-ae41-0c7cc907efe8}) + + From 28857f49e580182677398c1c04a69fa373d7fc64 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 14 Oct 2019 13:21:21 +0200 Subject: [PATCH 2/2] Add german translation --- ...74e2106a-3407-4e89-a27a-1c890d78bee7-de.ts | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-de.ts diff --git a/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-de.ts b/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-de.ts new file mode 100644 index 00000000..379b179d --- /dev/null +++ b/flowercare/translations/74e2106a-3407-4e89-a27a-1c890d78bee7-de.ts @@ -0,0 +1,128 @@ + + + + + DevicePluginFlowercare + + Cannot discover Bluetooth devices. Bluetooth is not available on this system. + Es kann nicht nach Bluetooth Geräten gesucht werden. Bluetooth ist auf diesem System nicht verfügbar. + + + Cannot discover Bluetooth devices. Bluetooth is disabled. + Es kann nicht nach Bluetooth Geräten gesucht werden. Bluetooth ist deaktiviert. + + + An error happened during Bluetooth discovery. + Beim Suchen von Bluetooth Geräten ist ein Fehler aufgetreten. + + + + flowerCare + + Flower Care + The name of the DeviceClass ({297e2efa-168c-4eb8-bf3f-f8694dc0a2b9}) +---------- +The name of the plugin flowerCare ({74e2106a-3407-4e89-a27a-1c890d78bee7}) + Flower Care + + + Xiaomi + The name of the vendor ({f037aa1a-f764-42f9-a613-338e683e4da5}) + Xiaomi + + + MAC address + The name of the ParamType (DeviceClass: flowerCare, Type: device, ID: {fe2dba0f-2a47-463e-a645-bcd55cf09750}) + MAC Adresse + + + Reachable changed + The name of the EventType ({6254103a-ff8b-4f62-afda-6b5be1c933ec}) of DeviceClass flowerCare + Erreichbar geändert + + + Reachable + The name of the ParamType (DeviceClass: flowerCare, EventType: connected, ID: {6254103a-ff8b-4f62-afda-6b5be1c933ec}) +---------- +The name of the StateType ({6254103a-ff8b-4f62-afda-6b5be1c933ec}) of DeviceClass flowerCare + Erreichbar + + + Battery level changed + The name of the EventType ({801a00ab-ce3b-4b10-9236-2f845c469a26}) of DeviceClass flowerCare + Batterieladung geändert + + + Battery level + The name of the ParamType (DeviceClass: flowerCare, EventType: batteryLevel, ID: {801a00ab-ce3b-4b10-9236-2f845c469a26}) +---------- +The name of the StateType ({801a00ab-ce3b-4b10-9236-2f845c469a26}) of DeviceClass flowerCare + Batterieladung + + + Battery level critical changed + The name of the EventType ({700a83e6-9fbb-4330-b00e-e9d0874b4f66}) of DeviceClass flowerCare + Batterieladung wird kritisch + + + Battery level critical + The name of the ParamType (DeviceClass: flowerCare, EventType: batteryCritical, ID: {700a83e6-9fbb-4330-b00e-e9d0874b4f66}) +---------- +The name of the StateType ({700a83e6-9fbb-4330-b00e-e9d0874b4f66}) of DeviceClass flowerCare + Batterieladung kritisch + + + Temperature changed + The name of the EventType ({4577a032-bafd-49ca-8625-6dcf90819e88}) of DeviceClass flowerCare + Temperatur geändert + + + Temperature + The name of the ParamType (DeviceClass: flowerCare, EventType: temperature, ID: {4577a032-bafd-49ca-8625-6dcf90819e88}) +---------- +The name of the StateType ({4577a032-bafd-49ca-8625-6dcf90819e88}) of DeviceClass flowerCare + Temperatur + + + Soil moisture changed + The name of the EventType ({5e3ac82a-1dda-4399-888e-529b391a814a}) of DeviceClass flowerCare + Bodenfeuchte geändert + + + Soil moisture + The name of the ParamType (DeviceClass: flowerCare, EventType: moisture, ID: {5e3ac82a-1dda-4399-888e-529b391a814a}) +---------- +The name of the StateType ({5e3ac82a-1dda-4399-888e-529b391a814a}) of DeviceClass flowerCare + Bodenfeuchte + + + Light intensity changed + The name of the EventType ({7e0a3b3d-72f4-4547-bd1e-2711be61c1a7}) of DeviceClass flowerCare + Lichtstärke geändert + + + Light intensity + The name of the ParamType (DeviceClass: flowerCare, EventType: lightIntensity, ID: {7e0a3b3d-72f4-4547-bd1e-2711be61c1a7}) +---------- +The name of the StateType ({7e0a3b3d-72f4-4547-bd1e-2711be61c1a7}) of DeviceClass flowerCare + Lichtstärke + + + Conductivity changed + The name of the EventType ({f77608b3-8b5b-43a9-aab6-0dc35c694ec3}) of DeviceClass flowerCare + Leitfähigkeit geändert + + + Conductivity + The name of the ParamType (DeviceClass: flowerCare, EventType: conductivity, ID: {f77608b3-8b5b-43a9-aab6-0dc35c694ec3}) +---------- +The name of the StateType ({f77608b3-8b5b-43a9-aab6-0dc35c694ec3}) of DeviceClass flowerCare + Leitfähigkeit + + + Refresh rate (minutes) + The name of the ParamType (DeviceClass: flowerCare, Type: settings, ID: {e892d118-336e-4495-ae41-0c7cc907efe8}) + Abtastrate (Minuten) + + +