Skip to content

Commit

Permalink
[common] Fixing property parent - child value mapping (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 19, 2023
1 parent b702ebc commit 8b212e0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Queue/Consumers/StoreDeviceConnectionState.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function __construct(

/**
* @throws DBAL\Exception
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws DevicesExceptions\Runtime
* @throws MetadataExceptions\InvalidArgument
Expand Down
12 changes: 8 additions & 4 deletions src/Queue/Consumers/StoreDeviceState.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function __construct(

/**
* @throws DoctrineCrudExceptions\InvalidArgumentException
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws ExchangeExceptions\InvalidArgument
* @throws ExchangeExceptions\InvalidState
Expand Down Expand Up @@ -132,6 +133,7 @@ public function consume(Entities\Messages\Entity $entity): bool
/**
* @param array<Entities\Messages\CapabilityState> $state
*
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
Expand Down Expand Up @@ -174,12 +176,12 @@ private function processSubDevice(
$this->channelPropertiesStatesManager->writeValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::ACTUAL_VALUE_KEY => DevicesUtilities\ValueHelper::transformValueFromDevice(
DevicesStates\Property::ACTUAL_VALUE_FIELD => DevicesUtilities\ValueHelper::transformValueFromDevice(
$property->getDataType(),
$property->getFormat(),
DevicesUtilities\ValueHelper::flattenValue($item->getValue()),
),
DevicesStates\Property::VALID_KEY => true,
DevicesStates\Property::VALID_FIELD => true,
]),
);
}
Expand All @@ -189,6 +191,7 @@ private function processSubDevice(
* @param array<Entities\Messages\CapabilityState> $state
*
* @throws DoctrineCrudExceptions\InvalidArgumentException
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws ExchangeExceptions\InvalidArgument
* @throws ExchangeExceptions\InvalidState
Expand Down Expand Up @@ -246,6 +249,7 @@ private function processThirdPartyDevice(

/**
* @throws DoctrineCrudExceptions\InvalidArgumentException
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws ExchangeExceptions\InvalidArgument
* @throws ExchangeExceptions\InvalidState
Expand Down Expand Up @@ -297,8 +301,8 @@ private function writeProperty(
$this->channelPropertiesStatesManager->writeValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::EXPECTED_VALUE_KEY => $value,
DevicesStates\Property::PENDING_KEY => true,
DevicesStates\Property::EXPECTED_VALUE_FIELD => $value,
DevicesStates\Property::PENDING_FIELD => true,
]),
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Queue/Consumers/WriteSubDeviceState.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function consume(Entities\Messages\Entity $entity): bool
$this->channelPropertiesStatesManager->setValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::PENDING_KEY => $now->format(DateTimeInterface::ATOM),
DevicesStates\Property::PENDING_FIELD => $now->format(DateTimeInterface::ATOM),
]),
);
}
Expand All @@ -292,8 +292,8 @@ public function consume(Entities\Messages\Entity $entity): bool
$this->channelPropertiesStatesManager->setValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::EXPECTED_VALUE_KEY => null,
DevicesStates\Property::PENDING_KEY => false,
DevicesStates\Property::EXPECTED_VALUE_FIELD => null,
DevicesStates\Property::PENDING_FIELD => false,
]),
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Queue/Consumers/WriteThirdPartyDeviceState.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function consume(Entities\Messages\Entity $entity): bool
$this->channelPropertiesStatesManager->setValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::PENDING_KEY => $now->format(DateTimeInterface::ATOM),
DevicesStates\Property::PENDING_FIELD => $now->format(DateTimeInterface::ATOM),
]),
);
}
Expand All @@ -305,8 +305,8 @@ public function consume(Entities\Messages\Entity $entity): bool
$this->channelPropertiesStatesManager->setValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::EXPECTED_VALUE_KEY => null,
DevicesStates\Property::PENDING_KEY => false,
DevicesStates\Property::EXPECTED_VALUE_FIELD => null,
DevicesStates\Property::PENDING_FIELD => false,
]),
);
}
Expand Down

0 comments on commit 8b212e0

Please sign in to comment.