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

View File

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