Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
naiades-platform-poc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
naiades
naiades-platform-poc
Commits
1b82e867
Commit
1b82e867
authored
Oct 06, 2020
by
Federico Sismondi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update() FlowerBed data model with last suggested changes from Carouge
parent
f3d97966
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
scripts-admin/create_entities.py
scripts-admin/create_entities.py
+17
-10
No files found.
scripts-admin/create_entities.py
View file @
1b82e867
...
...
@@ -51,7 +51,7 @@ def get_ngsiv2_typed_description(val):
# Data model templates, they describe those MUST-HAVE attributes, extra attributes can be added later on using the API
extra_arg
s
=
{
attr
s
=
{
'WeatherObserved'
:
{
'dateObserved'
:
datetime
.
utcnow
(),
# mandatory
'location'
:
Point
([
0
,
0
]),
# mandatory
...
...
@@ -77,13 +77,18 @@ extra_args = {
'FlowerBed'
:
{
'location'
:
Point
([
0
,
0
]),
# mandatory
'flowerType'
:
None
,
'taxon'
:
None
,
'category'
:
[],
'width'
:
0
,
'height'
:
0
,
'depth'
:
0
,
'sunExposure'
:
None
,
'dateLastWatering'
:
datetime
.
fromtimestamp
(
0
),
'nextWateringDeadline'
:
datetime
.
fromtimestamp
(
0
),
'nextWateringAmountRecommendation'
:
datetime
.
fromtimestamp
(
0
),
'soilMoisture'
:
0.0
,
'refDevice'
:
None
,
}
}
,
}
entities
=
[
...
...
@@ -123,7 +128,7 @@ entities = [
# http headers
headers
=
{
'Fiware-Service'
:
None
,
'Fiware-Service'
:
None
,
# UPDATE this before sending request!
'Content-Type'
:
'application/json'
}
...
...
@@ -138,20 +143,22 @@ for urn, pilots in entities:
data_type
=
str
(
urn
)
.
split
(
':'
)[
2
]
for
pilot
in
pilots
:
try
:
entities_map
[
pilot
]
.
append
({
'id'
:
urn
,
'type'
:
data_type
,
**
{
attr_n
:
get_ngsiv2_typed_description
(
attr_v
)
for
attr_n
,
attr_v
in
extra_args
[
data_type
]
.
items
()}
})
data
=
{
attr_n
:
get_ngsiv2_typed_description
(
attr_v
)
for
attr_n
,
attr_v
in
attrs
[
data_type
]
.
items
()}
entities_map
[
pilot
]
.
append
(
{
'id'
:
urn
,
'type'
:
data_type
,
**
data
}
)
except
KeyError
:
raise
KeyError
(
'Unrecognized pilot {}'
.
format
(
pilot
))
# for _, ents in entities_map.items():
# pprint(ents, indent=4)
#import sys
#sys.exit(0)
#
import sys
#
sys.exit(0)
# create entities in IoT platform
print
(
'Updating/creating entities'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment