Shelly: Add support for the Shelly motion sensor

pull/415/head
Michael Zanetti 2021-04-12 00:52:29 +02:00
parent 88729479ee
commit 8dfe5795dd
5 changed files with 1390 additions and 1054 deletions

View File

@ -15,7 +15,7 @@ The currently supported devices are:
* Shelly 3EM
* Shelly H+T
* Shelly i3
* Shelly Motion
## Requirements
Shelly devices communicate with via MQTT. This means, in order to add Shelly devices to nymea, the nymea instance is required
@ -42,7 +42,5 @@ perfectly fine in the low power mode.
When adding a Shelly device that is meant to be installed in walls and has connectors to switches, a new Gateway type device
representing the Shelly device itself will be added. The gateway device allow basic monitoring (such as the connected state)
and interaction (e.g. reboot the Shelly device). In addition to that, a power switch device will appear which will reflect
presses on the Shelly's SW input. This power switch device also offers the possiblity to configure the used switch (e.g.
toggle, momentary, edge or detached from the Shelly's output). If a connected device has been selected during setup, an
additional device, e.g. the light will appear in the system and can be used to control the power output of the Shelly,
e.g. turning on or off the connected light.
presses on the Shelly's SW input. You can use generic things to connect them to those switches in order to represent your actual
devices connected to the Shelly devices.

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,8 @@
#include "integrations/integrationplugin.h"
#include "extern-plugininfo.h"
class ZeroConfServiceBrowser;
class PluginTimer;
@ -74,60 +76,6 @@ private:
PluginTimer *m_timer = nullptr;
QHash<Thing*, MqttChannel*> m_mqttChannels;
QHash<ThingClassId, ParamTypeId> m_idParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_usernameParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_passwordParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_connectedDeviceParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_connectedDevice2ParamTypeMap;
QHash<ThingClassId, ParamTypeId> m_channelParamTypeMap;
QHash<ThingClassId, StateTypeId> m_connectedStateTypesMap;
QHash<ThingClassId, StateTypeId> m_signalStrengthStateTypesMap;
QHash<ThingClassId, StateTypeId> m_powerStateTypeMap;
QHash<ThingClassId, StateTypeId> m_currentPowerStateTypeMap;
QHash<ThingClassId, StateTypeId> m_totalEnergyConsumedStateTypeMap;
QHash<ThingClassId, StateTypeId> m_colorStateTypeMap;
QHash<ThingClassId, StateTypeId> m_colorTemperatureStateTypeMap;
QHash<ThingClassId, StateTypeId> m_brightnessStateTypeMap;
QHash<ThingClassId, StateTypeId> m_updateStatusStateTypesMap;
QHash<ThingClassId, StateTypeId> m_currentVersionStateTypesMap;
QHash<ThingClassId, StateTypeId> m_availableVersionStateTypesMap;
QHash<ThingClassId, StateTypeId> m_batteryLevelStateTypeMap;
QHash<ThingClassId, StateTypeId> m_batteryCriticalStateTypeMap;
QHash<ActionTypeId, ThingClassId> m_rebootActionTypeMap;
// Relay based power actions
QHash<ActionTypeId, ThingClassId> m_powerActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_powerActionParamTypesMap;
// Color JSON based power actions
QHash<ActionTypeId, ThingClassId> m_colorPowerActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_colorPowerActionParamTypesMap;
// Color actions
QHash<ActionTypeId, ThingClassId> m_colorActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_colorActionParamTypesMap;
// Color JSON brightness actions
QHash<ActionTypeId, ThingClassId> m_colorBrightnessActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_colorBrightnessActionParamTypesMap;
// Color temp
QHash<ActionTypeId, ThingClassId> m_colorTemperatureActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_colorTemperatureActionParamTypesMap;
// Dimmable based power actions
QHash<ActionTypeId, ThingClassId> m_dimmablePowerActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_dimmablePowerActionParamTypesMap;
// Dimmable based brightness actions
QHash<ActionTypeId, ThingClassId> m_dimmableBrightnessActionTypesMap;
QHash<ActionTypeId, ParamTypeId> m_dimmableBrightnessActionParamTypesMap;
// Roller shutter actions
QHash<ActionTypeId, ThingClassId> m_rollerOpenActionTypeMap;
QHash<ActionTypeId, ThingClassId> m_rollerCloseActionTypeMap;
QHash<ActionTypeId, ThingClassId> m_rollerStopActionTypeMap;
// Firmware update actions
QHash<ActionTypeId, ThingClassId> m_updateActionTypesMap;
};
#endif // INTEGRATIONPLUGINSHELLY_H

View File

@ -1741,6 +1741,131 @@
}
]
},
{
"id": "a82737bb-f2d6-442e-a468-5acc0a2e4cd7",
"name": "shellyMotion",
"displayName": "Shelly Motion",
"createMethods": ["discovery"],
"interfaces": ["presencesensor", "lightsensor", "wirelessconnectable", "update", "battery"],
"paramTypes": [
{
"id": "b92fe8ba-8bfb-4d9a-9fb9-8d55ace8cfb4",
"name":"id",
"displayName": "Shelly ID",
"type": "QString",
"readOnly": true
},
{
"id": "ea210ec8-37ed-4479-9454-48cc06a1df88",
"name": "username",
"displayName": "Username (optional)",
"type": "QString"
},
{
"id": "b6a48fc4-5016-47d9-8454-c64686120ee1",
"name": "password",
"displayName": "Password (optional)",
"type": "QString"
}
],
"stateTypes": [
{
"id": "45c0cc07-0e13-449c-86a7-ab65d5cdf637",
"name": "isPresent",
"displayName": "Person is present",
"displayNameEvent": "Presence detected",
"type": "bool",
"defaultValue": false
},
{
"id": "a1e12487-ebab-4993-a075-78275aac7b0d",
"name": "lightIntensity",
"displayName": "Light intensity",
"displayNameEvent": "Light intensity changed",
"type": "double",
"unit": "Lux",
"defaultValue": 0
},
{
"id": "76438c2d-9742-4680-9139-d4b4e988cfd2",
"name": "vibration",
"displayName": "Vibration",
"displayNameEvent": "Vibration detected",
"type": "bool",
"defaultValue": false
},
{
"id": "9ed997fa-1ec8-44d2-ac44-c99d4e259dae",
"name": "connected",
"displayName": "Connected",
"displayNameEvent": "Connected or disconnected",
"type": "bool",
"defaultValue": false,
"cached": false
},
{
"id": "ecc61ce2-cb66-47ce-a65c-3b9e43ce6fdc",
"name": "signalStrength",
"displayName": "Signal strength",
"displayNameEvent": "Signal strength changed",
"type": "uint",
"unit": "Percentage",
"minValue": 0,
"maxValue": 100,
"defaultValue": 100
}, {
"id": "a604a66c-3143-45ce-a6e3-17a339f428ab",
"name": "updateStatus",
"displayName": "Update status",
"displayNameEvent": "Update status changed",
"type": "QString",
"possibleValues": ["idle", "available", "updating"],
"defaultValue": "idle"
},
{
"id": "e2d98172-5833-454b-9b4b-04693c6b9232",
"name": "currentVersion",
"displayName": "Current firmware version",
"displayNameEvent": "Current firmware version changed",
"type": "QString",
"defaultValue": ""
},
{
"id": "0c9e8da4-1b1c-4047-8e9d-c5c580bcf43f",
"name": "availableVersion",
"displayName": "Available firmware version",
"displayNameEvent": "Available firmware version changed",
"type": "QString",
"defaultValue": ""
},
{
"id": "1d03941e-9c41-446b-b698-f8dff335bf11",
"name": "batteryCritical",
"displayName": "Battery level critical",
"displayNameEvent": "Battery entered critical state",
"type": "bool",
"defaultValue": false
},
{
"id": "f6d89aa6-7dba-4bb0-89cf-36d85208933f",
"name": "batteryLevel",
"displayName": "Battery level",
"displayNameEvent": "Battery level changed",
"type": "int",
"minValue": 0,
"maxValue": 100,
"defaultValue": 0,
"unit": "Percentage"
}
],
"actionTypes": [
{
"id": "17327674-f160-44e1-8a3d-fc2b6e1ee319",
"name": "performUpdate",
"displayName": "Start firmware update"
}
]
},
{
"id": "512c3c7d-d6a6-4d2a-bccd-83147e5f9a25",
"name": "shellyGeneric",