Shelly: Add support for the Shelly 1L

master
Michael Zanetti 2020-12-01 17:48:44 +01:00
parent e1c1f13c79
commit 54f61560c5
4 changed files with 931 additions and 624 deletions

View File

@ -5,6 +5,7 @@ The Shelly plugin adds support for Shelly devices (https://shelly.cloud).
The currently supported devices are:
* Shelly 1
* Shelly 1PM
* Shelly 1L
* Shelly 2
* Shelly 2.5
* Shelly Plug / PlugS

View File

@ -60,6 +60,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
// Device param types
m_idParamTypeMap[shelly1ThingClassId] = shelly1ThingIdParamTypeId;
m_idParamTypeMap[shelly1pmThingClassId] = shelly1pmThingIdParamTypeId;
m_idParamTypeMap[shelly1lThingClassId] = shelly1lThingIdParamTypeId;
m_idParamTypeMap[shellyPlugThingClassId] = shellyPlugThingIdParamTypeId;
m_idParamTypeMap[shellyRgbw2ThingClassId] = shellyRgbw2ThingIdParamTypeId;
m_idParamTypeMap[shellyDimmerThingClassId] = shellyDimmerThingIdParamTypeId;
@ -71,6 +72,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_usernameParamTypeMap[shelly1ThingClassId] = shelly1ThingUsernameParamTypeId;
m_usernameParamTypeMap[shelly1pmThingClassId] = shelly1pmThingUsernameParamTypeId;
m_usernameParamTypeMap[shelly1lThingClassId] = shelly1lThingUsernameParamTypeId;
m_usernameParamTypeMap[shellyPlugThingClassId] = shellyPlugThingUsernameParamTypeId;
m_usernameParamTypeMap[shellyRgbw2ThingClassId] = shellyRgbw2ThingUsernameParamTypeId;
m_usernameParamTypeMap[shellyDimmerThingClassId] = shellyDimmerThingUsernameParamTypeId;
@ -82,6 +84,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_passwordParamTypeMap[shelly1ThingClassId] = shelly1ThingPasswordParamTypeId;
m_passwordParamTypeMap[shelly1pmThingClassId] = shelly1pmThingPasswordParamTypeId;
m_passwordParamTypeMap[shelly1lThingClassId] = shelly1lThingPasswordParamTypeId;
m_passwordParamTypeMap[shellyPlugThingClassId] = shellyPlugThingPasswordParamTypeId;
m_passwordParamTypeMap[shellyRgbw2ThingClassId] = shellyRgbw2ThingPasswordParamTypeId;
m_passwordParamTypeMap[shellyDimmerThingClassId] = shellyDimmerThingPasswordParamTypeId;
@ -91,8 +94,6 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_passwordParamTypeMap[shellyEm3ThingClassId] = shellyEm3ThingPasswordParamTypeId;
m_passwordParamTypeMap[shellyHTThingClassId] = shellyHTThingPasswordParamTypeId;
m_connectedDeviceParamTypeMap[shelly1ThingClassId] = shelly1ThingConnectedDeviceParamTypeId;
m_connectedDeviceParamTypeMap[shelly1pmThingClassId] = shelly1pmThingConnectedDeviceParamTypeId;
m_connectedDeviceParamTypeMap[shelly2ThingClassId] = shelly2ThingConnectedDevice1ParamTypeId;
m_connectedDeviceParamTypeMap[shelly25ThingClassId] = shelly25ThingConnectedDevice1ParamTypeId;
@ -110,6 +111,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
// States
m_connectedStateTypesMap[shelly1ThingClassId] = shelly1ConnectedStateTypeId;
m_connectedStateTypesMap[shelly1pmThingClassId] = shelly1pmConnectedStateTypeId;
m_connectedStateTypesMap[shelly1lThingClassId] = shelly1lConnectedStateTypeId;
m_connectedStateTypesMap[shelly2ThingClassId] = shelly2ConnectedStateTypeId;
m_connectedStateTypesMap[shelly25ThingClassId] = shelly25ConnectedStateTypeId;
m_connectedStateTypesMap[shellyPlugThingClassId] = shellyPlugConnectedStateTypeId;
@ -129,6 +131,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_signalStrengthStateTypesMap[shelly1ThingClassId] = shelly1SignalStrengthStateTypeId;
m_signalStrengthStateTypesMap[shelly1pmThingClassId] = shelly1pmSignalStrengthStateTypeId;
m_signalStrengthStateTypesMap[shelly1lThingClassId] = shelly1lSignalStrengthStateTypeId;
m_signalStrengthStateTypesMap[shelly2ThingClassId] = shelly2SignalStrengthStateTypeId;
m_signalStrengthStateTypesMap[shelly25ThingClassId] = shelly25SignalStrengthStateTypeId;
m_signalStrengthStateTypesMap[shellyPlugThingClassId] = shellyPlugSignalStrengthStateTypeId;
@ -146,6 +149,9 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_signalStrengthStateTypesMap[shellySocketPMThingClassId] = shellySocketPMSignalStrengthStateTypeId;
m_signalStrengthStateTypesMap[shellyRollerThingClassId] = shellyRollerSignalStrengthStateTypeId;
m_powerStateTypeMap[shelly1ThingClassId] = shelly1PowerStateTypeId;
m_powerStateTypeMap[shelly1pmThingClassId] = shelly1pmPowerStateTypeId;
m_powerStateTypeMap[shelly1lThingClassId] = shelly1lPowerStateTypeId;
m_powerStateTypeMap[shellyPlugThingClassId] = shellyPlugPowerStateTypeId;
m_powerStateTypeMap[shellyRgbw2ThingClassId] = shellyRgbw2PowerStateTypeId;
m_powerStateTypeMap[shellyDimmerThingClassId] = shellyDimmerPowerStateTypeId;
@ -157,6 +163,8 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_powerStateTypeMap[shellySocketPMThingClassId] = shellySocketPMPowerStateTypeId;
m_powerStateTypeMap[shellyEm3ThingClassId] = shellyEm3PowerStateTypeId;
m_currentPowerStateTypeMap[shelly1pmThingClassId] = shelly1pmCurrentPowerStateTypeId;
m_currentPowerStateTypeMap[shelly1lThingClassId] = shelly1lCurrentPowerStateTypeId;
m_currentPowerStateTypeMap[shellyPlugThingClassId] = shellyPlugCurrentPowerStateTypeId;
m_currentPowerStateTypeMap[shellyRgbw2ThingClassId] = shellyRgbw2CurrentPowerStateTypeId;
m_currentPowerStateTypeMap[shellyDimmerThingClassId] = shellyDimmerCurrentPowerStateTypeId;
@ -181,6 +189,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_updateStatusStateTypesMap[shelly1ThingClassId] = shelly1UpdateStatusStateTypeId;
m_updateStatusStateTypesMap[shelly1pmThingClassId] = shelly1pmUpdateStatusStateTypeId;
m_updateStatusStateTypesMap[shelly1lThingClassId] = shelly1lUpdateStatusStateTypeId;
m_updateStatusStateTypesMap[shelly2ThingClassId] = shelly2UpdateStatusStateTypeId;
m_updateStatusStateTypesMap[shelly25ThingClassId] = shelly25UpdateStatusStateTypeId;
m_updateStatusStateTypesMap[shellyPlugThingClassId] = shellyPlugUpdateStatusStateTypeId;
@ -192,6 +201,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_currentVersionStateTypesMap[shelly1ThingClassId] = shelly1CurrentVersionStateTypeId;
m_currentVersionStateTypesMap[shelly1pmThingClassId] = shelly1pmCurrentVersionStateTypeId;
m_currentVersionStateTypesMap[shelly1lThingClassId] = shelly1lCurrentVersionStateTypeId;
m_currentVersionStateTypesMap[shelly2ThingClassId] = shelly2CurrentVersionStateTypeId;
m_currentVersionStateTypesMap[shelly25ThingClassId] = shelly25CurrentVersionStateTypeId;
m_currentVersionStateTypesMap[shellyPlugThingClassId] = shellyPlugCurrentVersionStateTypeId;
@ -203,6 +213,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_availableVersionStateTypesMap[shelly1ThingClassId] = shelly1AvailableVersionStateTypeId;
m_availableVersionStateTypesMap[shelly1pmThingClassId] = shelly1pmAvailableVersionStateTypeId;
m_availableVersionStateTypesMap[shelly1lThingClassId] = shelly1lAvailableVersionStateTypeId;
m_availableVersionStateTypesMap[shelly2ThingClassId] = shelly2AvailableVersionStateTypeId;
m_availableVersionStateTypesMap[shelly25ThingClassId] = shelly25AvailableVersionStateTypeId;
m_availableVersionStateTypesMap[shellyPlugThingClassId] = shellyPlugAvailableVersionStateTypeId;
@ -221,12 +232,16 @@ IntegrationPluginShelly::IntegrationPluginShelly()
// Actions and their params
m_rebootActionTypeMap[shelly1RebootActionTypeId] = shelly1ThingClassId;
m_rebootActionTypeMap[shelly1pmRebootActionTypeId] = shelly1pmThingClassId;
m_rebootActionTypeMap[shelly1lRebootActionTypeId] = shelly1lThingClassId;
m_rebootActionTypeMap[shellyPlugRebootActionTypeId] = shellyPlugThingClassId;
m_rebootActionTypeMap[shellyRgbw2RebootActionTypeId] = shellyRgbw2ThingClassId;
m_rebootActionTypeMap[shellyDimmerRebootActionTypeId] = shellyDimmerThingClassId;
m_rebootActionTypeMap[shelly2RebootActionTypeId] = shelly2ThingClassId;
m_rebootActionTypeMap[shelly25RebootActionTypeId] = shelly25ThingClassId;
m_powerActionTypesMap[shelly1PowerActionTypeId] = shelly1ThingClassId;
m_powerActionTypesMap[shelly1pmPowerActionTypeId] = shelly1pmThingClassId;
m_powerActionTypesMap[shelly1lPowerActionTypeId] = shelly1lThingClassId;
m_powerActionTypesMap[shellyPlugPowerActionTypeId] = shellyPlugThingClassId;
m_powerActionTypesMap[shellyGenericPowerActionTypeId] = shellyGenericThingClassId;
m_powerActionTypesMap[shellyLightPowerActionTypeId] = shellyLightThingClassId;
@ -236,6 +251,9 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_powerActionTypesMap[shellySocketPMPowerActionTypeId] = shellySocketPMThingClassId;
m_powerActionTypesMap[shellyEm3PowerActionTypeId] = shellyEm3ThingClassId;
m_powerActionParamTypesMap[shelly1PowerActionTypeId] = shelly1PowerActionPowerParamTypeId;
m_powerActionParamTypesMap[shelly1pmPowerActionTypeId] = shelly1pmPowerActionPowerParamTypeId;
m_powerActionParamTypesMap[shelly1lPowerActionTypeId] = shelly1lPowerActionPowerParamTypeId;
m_powerActionParamTypesMap[shellyPlugPowerActionTypeId] = shellyPlugPowerActionPowerParamTypeId;
m_powerActionParamTypesMap[shellyGenericPowerActionTypeId] = shellyGenericPowerActionPowerParamTypeId;
m_powerActionParamTypesMap[shellyLightPowerActionTypeId] = shellyLightPowerActionPowerParamTypeId;
@ -269,6 +287,7 @@ IntegrationPluginShelly::IntegrationPluginShelly()
m_updateActionTypesMap[shelly1PerformUpdateActionTypeId] = shelly1ThingClassId;
m_updateActionTypesMap[shelly1pmPerformUpdateActionTypeId] = shelly1pmThingClassId;
m_updateActionTypesMap[shelly1lPerformUpdateActionTypeId] = shelly1lThingClassId;
m_updateActionTypesMap[shelly2PerformUpdateActionTypeId] = shelly2ThingClassId;
m_updateActionTypesMap[shelly25PerformUpdateActionTypeId] = shelly25ThingClassId;
m_updateActionTypesMap[shellyPlugPerformUpdateActionTypeId] = shellyPlugThingClassId;
@ -297,6 +316,8 @@ void IntegrationPluginShelly::discoverThings(ThingDiscoveryInfo *info)
namePattern = QRegExp("^shelly1-[0-9A-Z]+$");
} else if (info->thingClassId() == shelly1pmThingClassId) {
namePattern = QRegExp("^shelly1pm-[0-9A-Z]+$");
} else if (info->thingClassId() == shelly1lThingClassId) {
namePattern = QRegExp("^shelly1l-[0-9A-Z]+$");
} else if (info->thingClassId() == shellyPlugThingClassId) {
namePattern = QRegExp("^shellyplug(-s)?-[0-9A-Z]+$");
} else if (info->thingClassId() == shellyRgbw2ThingClassId) {
@ -549,7 +570,7 @@ void IntegrationPluginShelly::executeAction(ThingActionInfo *info)
return;
}
qCWarning(dcShelly()) << "Unhandled execute action call for device" << thing;
qCWarning(dcShelly()) << "Unhandled execute action" << info->action().actionTypeId() << "call for device" << thing;
}
void IntegrationPluginShelly::onClientConnected(MqttChannel *channel)
@ -1017,7 +1038,8 @@ void IntegrationPluginShelly::setupShellyGateway(ThingSetupInfo *info)
if (myThings().filterByParentId(info->thing()->id()).isEmpty()) {
// Always create the switch thing if we don't have one yet for shellies with input (1, 1pm etc)
if (info->thing()->thingClassId() == shelly1ThingClassId
|| info->thing()->thingClassId() == shelly1pmThingClassId) {
|| info->thing()->thingClassId() == shelly1pmThingClassId
|| info->thing()->thingClassId() == shelly1lThingClassId) {
ThingDescriptor switchChild(shellySwitchThingClassId, info->thing()->name() + " switch", QString(), info->thing()->id());
switchChild.setParams(ParamList() << Param(shellySwitchThingChannelParamTypeId, 1));
autoChilds.append(switchChild);

View File

@ -22,14 +22,6 @@
"type": "QString",
"readOnly": true
},
{
"id": "d0e0499e-faa0-432a-a760-c295b0aefed0",
"name": "connectedDevice",
"displayName": "Connected device",
"type": "QString",
"allowedValues": ["None", "Generic", "Light", "Socket"],
"defaultValue": "Generic"
},
{
"id": "fa1aa0f6-93b2-410d-a2c5-7b2f45eae679",
"name": "username",
@ -44,6 +36,17 @@
}
],
"stateTypes": [
{
"id": "5b7eeb6c-6113-41f3-a61b-3076d087c9fe",
"name": "power",
"displayName": "Powered",
"displayNameEvent": "Turned on/off",
"displayNameAction": "Turn on/off",
"type": "bool",
"defaultValue": false,
"writable": true,
"ioType": "digitalOutput"
},
{
"id": "e5d41e05-2296-457e-97d8-98a5ac0de615",
"name": "connected",
@ -108,7 +111,7 @@
"name": "shelly1pm",
"displayName": "Shelly 1PM",
"createMethods": ["discovery"],
"interfaces": [ "gateway", "wirelessconnectable", "update" ],
"interfaces": [ "gateway", "extendedsmartmeterconsumer", "wirelessconnectable", "update" ],
"paramTypes": [
{
"id": "6df5db8a-4e27-49e5-8cf9-78cb8497d831",
@ -117,14 +120,6 @@
"type": "QString",
"readOnly": true
},
{
"id": "3aacd693-3f1a-4040-be3a-953e600da44f",
"name": "connectedDevice",
"displayName": "Connected device",
"type": "QString",
"allowedValues": ["None", "Generic", "Light", "Socket"],
"defaultValue": "Generic"
},
{
"id": "99a31711-0029-461e-9117-2834451175c1",
"name": "username",
@ -139,6 +134,17 @@
}
],
"stateTypes": [
{
"id": "ff44d332-52c3-4142-83e3-01d56c2eb42e",
"name": "power",
"displayName": "Powered",
"displayNameEvent": "Turned on/off",
"displayNameAction": "Turn on/off",
"type": "bool",
"defaultValue": false,
"writable": true,
"ioType": "digitalOutput"
},
{
"id": "df23a5ea-5f54-42ac-ab6b-aea8f71224f0",
"name": "connected",
@ -183,6 +189,24 @@
"displayNameEvent": "Available firmware version changed",
"type": "QString",
"defaultValue": ""
},
{
"id": "23594959-1cd4-4e23-a7ae-b0b7fbd29daa",
"name": "totalEnergyConsumed",
"displayName": "Total energy consumed",
"displayNameEvent": "Total consumed energy changed",
"type": "double",
"unit": "KiloWattHour",
"defaultValue": 0
},
{
"id": "3ec03053-7cf5-44fb-ad92-041eed9edd9a",
"name": "currentPower",
"displayName": "Current power consumption",
"displayNameEvent": "Current power consumption changed",
"type": "double",
"unit": "Watt",
"defaultValue": 0
}
],
"actionTypes": [
@ -198,6 +222,122 @@
}
]
},
{
"id": "20754114-1591-48b5-af2f-8c9966adb7c4",
"name": "shelly1l",
"displayName": "Shelly 1L",
"createMethods": ["discovery"],
"interfaces": [ "gateway", "extendedsmartmeterconsumer", "wirelessconnectable", "update" ],
"paramTypes": [
{
"id": "afd5f2c5-dbe4-4d60-80a6-97b77264ad7c",
"name":"id",
"displayName": "Shelly ID",
"type": "QString",
"readOnly": true
},
{
"id": "b7c4c031-77ec-4ce7-a499-5bb8bf117fe8",
"name": "username",
"displayName": "Username (optional)",
"type": "QString"
},
{
"id": "e93b4eae-618c-4c4b-9c3e-0226361f87a2",
"name": "password",
"displayName": "Password (optional)",
"type": "QString"
}
],
"stateTypes": [
{
"id": "94276bb9-ef68-47ab-8e74-34ebe54b411f",
"name": "power",
"displayName": "Powered",
"displayNameEvent": "Turned on/off",
"displayNameAction": "Turn on/off",
"type": "bool",
"defaultValue": false,
"writable": true,
"ioType": "digitalOutput"
},
{
"id": "2a333f45-2bba-4643-b973-1bb47d56306a",
"name": "connected",
"displayName": "Connected",
"displayNameEvent": "Connected changed",
"type": "bool",
"defaultValue": false,
"cached": false
},
{
"id": "cce7906d-fdef-4804-b118-b5abefa6c6ed",
"name": "signalStrength",
"displayName": "Signal strength",
"displayNameEvent": "Signal strength changed",
"type": "uint",
"unit": "Percentage",
"minValue": 0,
"maxValue": 100,
"defaultValue": 100
},
{
"id": "0e47815d-0084-4a30-957a-f73ed100bed5",
"name": "updateStatus",
"displayName": "Update status",
"displayNameEvent": "Update status changed",
"type": "QString",
"possibleValues": ["idle", "available", "updating"],
"defaultValue": "idle"
},
{
"id": "2303ffb7-8de4-4993-b3ac-95e4c035b790",
"name": "currentVersion",
"displayName": "Firmware version",
"displayNameEvent": "Firmware version changed",
"type": "QString",
"defaultValue": ""
},
{
"id": "5f357a69-6096-4f31-9b5b-b2d5478739da",
"name": "availableVersion",
"displayName": "Available firmware version",
"displayNameEvent": "Available firmware version changed",
"type": "QString",
"defaultValue": ""
},
{
"id": "0f879e7b-2124-4d98-9828-e5bbd1b344ce",
"name": "totalEnergyConsumed",
"displayName": "Total energy consumed",
"displayNameEvent": "Total consumed energy changed",
"type": "double",
"unit": "KiloWattHour",
"defaultValue": 0
},
{
"id": "194f4f1b-86a7-4c04-abf0-2459ae7e2821",
"name": "currentPower",
"displayName": "Current power consumption",
"displayNameEvent": "Current power consumption changed",
"type": "double",
"unit": "Watt",
"defaultValue": 0
}
],
"actionTypes": [
{
"id": "5a05c09a-c6a0-4141-aeeb-86afdb49ffaf",
"name": "reboot",
"displayName": "Reboot"
},
{
"id": "fa6a52fa-6a57-4d65-8c41-1e61b545dd9b",
"name": "performUpdate",
"displayName": "Update firmware"
}
]
},
{
"id": "f277d3a3-62e0-49c1-90b2-4108578e80bf",
"name": "shelly2",