Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Jan 21, 2024
1 parent f482319 commit 3a4d015
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 29 deletions.
61 changes: 33 additions & 28 deletions Tapo Discovery/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,42 @@ private function GetDevices(): array
$this->SendDebug('IPS Devices', $IPSDevices, 0);
$Values = [];
foreach ($Devices as $Device) {
$InstanceID = false;
$Guid = \TpLink\DeviceModel::GetGuidByDeviceModel($Device[\TpLink\Api\Result::DeviceModel]);
if (!$Guid) {
continue;
}
$InstanceID = array_search(strtoupper($Device[\TpLink\Api\Result::Mac]), $IPSDevices);
if ($InstanceID) {
$Create = [
'moduleID' => IPS_GetInstance($InstanceID)['ModuleInfo']['ModuleID'],
'configuration' => [
\TpLink\Property::Open => IPS_GetProperty($InstanceID, \TpLink\Property::Open),
\TpLink\Property::Host => $Device[\TpLink\Api\Result::Ip],
\TpLink\Property::Mac => IPS_GetProperty($InstanceID, \TpLink\Property::Mac),
\TpLink\Property::Username => $this->ReadAttributeString(\TpLink\Attribute::Username),
\TpLink\Property::Password => $this->ReadAttributeString(\TpLink\Attribute::Password),
\TpLink\Property::Protocol => $Device[\TpLink\Api\Result::MGT][\TpLink\Api\Result::Protocol]
]
];
$Open = false;
if ($Guid == \TpLink\GUID::HubConfigurator) {
$Guid = \TpLink\GUID::Hub;
$ConnectionID = IPS_GetInstance($InstanceID)['ConnectionID'];
if (IPS_InstanceExists($ConnectionID)) {
$Open = IPS_GetProperty($ConnectionID, \TpLink\Property::Open);
}
} else {
$Open = IPS_GetProperty($InstanceID, \TpLink\Property::Open);
}
unset($IPSDevices[$InstanceID]);
} else {
$Guid = \TpLink\DeviceModel::GetGuidByDeviceModel($Device[\TpLink\Api\Result::DeviceModel]);
if (!$Guid) {
continue;
}
$Create = [
'moduleID' => $Guid,
'configuration' => [
\TpLink\Property::Open => true,
\TpLink\Property::Host => $Device[\TpLink\Api\Result::Ip],
\TpLink\Property::Mac => $Device[\TpLink\Api\Result::Mac],
\TpLink\Property::Username => $this->ReadAttributeString(\TpLink\Attribute::Username),
\TpLink\Property::Password => $this->ReadAttributeString(\TpLink\Attribute::Password),
\TpLink\Property::Protocol => $Device[\TpLink\Api\Result::MGT][\TpLink\Api\Result::Protocol]
]
];
$Open = true;
}
$Create = [
'moduleID' => $Guid,
'configuration' => [
\TpLink\Property::Open => $Open,
\TpLink\Property::Host => $Device[\TpLink\Api\Result::Ip],
\TpLink\Property::Mac => $Device[\TpLink\Api\Result::Mac],
\TpLink\Property::Username => $this->ReadAttributeString(\TpLink\Attribute::Username),
\TpLink\Property::Password => $this->ReadAttributeString(\TpLink\Attribute::Password),
\TpLink\Property::Protocol => $Device[\TpLink\Api\Result::MGT][\TpLink\Api\Result::Protocol]
]
];
if ($Guid == \TpLink\GUID::Hub) {
$Create = [[
'moduleID' => \TpLink\GUID::HubConfigurator,
'configuration' => new stdClass()
], $Create];
}
$Values[] = [
'host' => $Device[\TpLink\Api\Result::Ip],
Expand All @@ -116,8 +121,8 @@ private function GetDevices(): array
}
foreach ($IPSDevices as $InstanceID => $Mac) {
$GUID = IPS_GetInstance($InstanceID)['ModuleInfo']['ModuleID'];
$Host = '';
if ($GUID == \TpLink\GUID::HubConfigurator) {
$Host = '';
$ConnectionID = IPS_GetInstance($InstanceID)['ConnectionID'];
if (IPS_InstanceExists($ConnectionID)) {
$Host = IPS_GetProperty($ConnectionID, \TpLink\Property::Host);
Expand Down
18 changes: 17 additions & 1 deletion libs/TapoLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,23 @@ class VariableIdentTrv
],
];
}

/*
// channel group alarm
public static final String CHANNEL_GROUP_ALARM = "alarm";
public static final String CHANNEL_ALARM_ACTIVE = "alarmActive";
public static final String CHANNEL_ALARM_SOURCE = "alarmSource";
public static final String CHANNEL_GROUP_SENSOR = "sensor";
public static final String CHANNEL_IS_OPEN = "isOpen";
public static final String CHANNEL_TEMPERATURE = "currentTemp";
public static final String CHANNEL_HUMIDITY = "currentHumidity";
// hub child events
public static final String EVENT_BATTERY_LOW = "batteryIsLow";
public static final String EVENT_CONTACT_OPENED = "contactOpened";
public static final String EVENT_CONTACT_CLOSED = "contactClosed";
public static final String EVENT_STATE_BATTERY_LOW = "batteryLow";
public static final String EVENT_STATE_OPENED = "open";
public static final String EVENT_STATE_CLOSED = "closed";
*/
class VariableProfile
{
public const Runtime = 'Tapo.Runtime';
Expand Down

0 comments on commit 3a4d015

Please sign in to comment.