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 69a0197 commit 7a0ca30
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/Queue/Consumers/StoreChannelPropertyState.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function __construct(
}

/**
* @throws DevicesExceptions\InvalidArgument
* @throws DevicesExceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
Expand Down Expand Up @@ -163,19 +164,19 @@ public function consume(Entities\Messages\Entity $entity): bool

if ($property->getDataType()->equalsValue(MetadataTypes\DataType::DATA_TYPE_BUTTON)) {
$this->channelPropertiesStateManager->setValue($property, Utils\ArrayHash::from([
DevicesStates\Property::ACTUAL_VALUE_KEY => null,
DevicesStates\Property::EXPECTED_VALUE_KEY => null,
DevicesStates\Property::PENDING_KEY => false,
DevicesStates\Property::VALID_KEY => true,
DevicesStates\Property::ACTUAL_VALUE_FIELD => null,
DevicesStates\Property::EXPECTED_VALUE_FIELD => null,
DevicesStates\Property::PENDING_FIELD => false,
DevicesStates\Property::VALID_FIELD => true,
]));
} else {
$this->channelPropertiesStateManager->setValue($property, Utils\ArrayHash::from([
DevicesStates\Property::ACTUAL_VALUE_KEY => DevicesUtilities\ValueHelper::transformValueFromDevice(
DevicesStates\Property::ACTUAL_VALUE_FIELD => DevicesUtilities\ValueHelper::transformValueFromDevice(
$property->getDataType(),
$property->getFormat(),
$entity->getValue(),
),
DevicesStates\Property::VALID_KEY => true,
DevicesStates\Property::VALID_FIELD => true,
]));
}

Expand Down
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
6 changes: 3 additions & 3 deletions src/Queue/Consumers/WriteChannelPropertyState.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ function () use ($connector, $device, $property, $valueToWrite): void {
$this->channelPropertiesStates->setValue(
$property,
Utils\ArrayHash::from([
DevicesStates\Property::PENDING_KEY => $now->format(DateTimeInterface::ATOM),
DevicesStates\Property::PENDING_FIELD => $now->format(DateTimeInterface::ATOM),
]),
);
}
Expand Down Expand Up @@ -618,8 +618,8 @@ function (Throwable $ex) use ($connector, $device, $property): void {
$this->channelPropertiesStates->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 7a0ca30

Please sign in to comment.