This commit is contained in:
JonatanRek 2020-05-03 20:14:18 +02:00
parent 13678630f2
commit 8d2af9181a
2 changed files with 7 additions and 5 deletions

View File

@ -38,9 +38,11 @@ class GoogleHomeApi {
foreach ($subDevicesData as $subDeviceKey => $subDeviceData) { foreach ($subDevicesData as $subDeviceKey => $subDeviceData) {
if ($subDeviceData['type'] != "on/off" && $subDeviceData['type'] != "temp_cont") continue; if ($subDeviceData['type'] != "on/off" && $subDeviceData['type'] != "temp_cont") continue;
//Google Compatibile Action Type
$actionType = GoogleHomeDeviceTypes::getAction($subDeviceData['type']);
$tempDevice = [ $tempDevice = [
'id' => (string) $subDeviceData['subdevice_id'], 'id' => (string) $subDeviceData['subdevice_id'],
'type' => GoogleHomeDeviceTypes::getAction($subDeviceData['type']), 'type' => $actionType,
'name' => [ 'name' => [
'name' => $deviceData['name'], 'name' => $deviceData['name'],
], ],
@ -49,13 +51,11 @@ class GoogleHomeApi {
]; ];
//traids & Attributes //traids & Attributes
$tempDevice = GoogleHomeDeviceTypes::getSyncObj($tempDevice, GoogleHomeDeviceTypes::getAction($subDeviceData['type'])); $devices[] = GoogleHomeDeviceTypes::getSyncObj($tempDevice, $actionType);
$devices[] = $tempDevice;
} }
} }
} }
$response = [ $response = [
'requestId' => $requestId, 'requestId' => $requestId,
'payload' => [ 'payload' => [

View File

@ -83,7 +83,9 @@ class GoogleHomeDeviceTypes {
static function getSyncObj($deviceBaseObj, $deviceType){ static function getSyncObj($deviceBaseObj, $deviceType){
switch ($deviceType) { switch ($deviceType) {
case 'action.devices.types.OUTLET': case 'action.devices.types.OUTLET':
$deviceBaseObj['traits'] = 'action.devices.traits.OnOff'; $deviceBaseObj['traits'] = [
'action.devices.traits.OnOff'
];
break; break;
case 'action.devices.types.THERMOSTAT': case 'action.devices.types.THERMOSTAT':
$deviceBaseObj['traits'] = [ $deviceBaseObj['traits'] = [