Skip to content

Commit

Permalink
Fixing typo
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Sep 1, 2021
1 parent 7fe6934 commit 27f0801
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
22 changes: 19 additions & 3 deletions devices_module/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,29 @@ def to_dict(
related_objects: bool = False, # pylint: disable=unused-argument
) -> Dict[str, str or int or bool or None]:
"""Transform entity to dictionary"""
return {
"id": self.device_id.__str__(),
"params": self.params,
structure: dict = {
"id": self.connector_id.__str__(),
"type": self.connector.type,
"connector": self.connector.connector_id.__str__(),
"device": self.device.connector_id.__str__(),
}

if isinstance(self.connector, FbBusConnectorEntity):
return {**structure, **{
"address": self.params.get("address"),
"max_packet_length": self.params.get("max_packet_length"),
"description_support": bool(self.params.get("description_support", False)),
"settings_support": bool(self.params.get("settings_support", False)),
"configured_key_length": self.params.get("configured_key_length"),
}}

elif isinstance(self.connector, FbMqttV1ConnectorEntity):
return {**structure, **{
"username": self.params.get("username"),
}}

return structure


class ChannelEntity(db.Entity, EntityEventMixin, EntityCreatedMixin, EntityUpdatedMixin):
"""
Expand Down
1 change: 1 addition & 0 deletions src/Entities/Devices/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public function toArray(): array
{
$baseProperties = [
'id' => $this->getPlainId(),
'type' => $this->getConnector()->getType(),
'device' => $this->getDevice()->getPlainId(),
'connector' => $this->getConnector()->getPlainId(),
];
Expand Down

0 comments on commit 27f0801

Please sign in to comment.