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
16211803
Commit
16211803
authored
Sep 09, 2020
by
Federico Sismondi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update() in data model for entities of DCA components
parent
36881f4f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
39 deletions
+32
-39
dca-carouge-watering/app.py
dca-carouge-watering/app.py
+1
-3
scripts-admin/create_entities.py
scripts-admin/create_entities.py
+31
-36
No files found.
dca-carouge-watering/app.py
View file @
16211803
...
...
@@ -193,7 +193,7 @@ def _forward_reading_to_ctx_broker():
url
=
"{}/v2/entities/{}/attrs"
.
format
(
URL_BASE
,
entity_id
)
payload
=
{
'soilMoisture'
:
{
'value'
:
sensor_reading
},
'dateObserved'
:
{
'type'
:
'DateTime'
,
'value'
:
timestamp
},
#
'dateObserved': {'type': 'DateTime', 'value': timestamp},
}
r
=
client_request
.
patch
(
...
...
@@ -232,8 +232,6 @@ def _dump_raw_data_to_filesystem():
def
_dummy_post_handler
():
if
request
.
data
:
app
.
logger
.
info
(
"Request data:
%
s"
%
request
.
data
)
if
request
.
json
:
app
.
logger
.
info
(
"Request json:
%
s"
%
request
.
json
)
if
request
.
form
:
app
.
logger
.
info
(
"Request form:
%
s"
%
request
.
form
)
...
...
scripts-admin/create_entities.py
View file @
16211803
...
...
@@ -22,6 +22,7 @@ logger = logging.getLogger()
URL_BASE
=
'http://{}:1026'
.
format
(
os
.
getenv
(
'ORION_HOST'
))
def
get_ngsiv2_typed_description
(
val
):
if
isinstance
(
val
,
Point
):
return
{
'type'
:
'geo:json'
,
'value'
:
dict
(
val
)}
...
...
@@ -41,47 +42,40 @@ 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_args
=
{
'WeatherObserved'
:
{
'dateObserved'
:
datetime
.
utcnow
(),
# mandatory
'location'
:
Point
([
0
,
0
]),
# mandatory
'source'
:
''
,
'illuminance'
:
0
,
'temperature'
:
0.0
,
'precipitation'
:
0
,
'atmosphericPressure'
:
0.0
,
'windSpeed'
:
0
,
'pressureTendency'
:
0.0
,
'relativeHumidity'
:
0
,
},
'WeatherForecast'
:
{
'dateIssued'
:
datetime
.
utcnow
(),
# mandatory
'location'
:
Point
([
0
,
0
]),
# mandatory
'dayMinimum'
:
{
'feelsLikeTemperature'
:
0
,
'temperature'
:
0
,
'relativeHumidity'
:
0.0
},
'dayMaximum'
:
{
'feelsLikeTemperature'
:
0
,
'temperature'
:
0
,
'relativeHumidity'
:
0.0
},
'precipitationProbability'
:
0.0
,
'windSpeed'
:
0
,
'validFrom'
:
datetime
.
fromtimestamp
(
0
),
'validTo'
:
datetime
.
fromtimestamp
(
0
),
},
'WeatherObserved'
:
{
'dateObserved'
:
datetime
.
utcnow
(),
# mandatory
'location'
:
Point
([
0
,
0
]),
# mandatory
'source'
:
''
,
'illuminance'
:
0
,
'temperature'
:
0.0
,
'precipitation'
:
0
,
'atmosphericPressure'
:
0.0
,
'windSpeed'
:
0
,
'pressureTendency'
:
0.0
,
'relativeHumidity'
:
0
,
},
'WeatherForecast'
:
{
'dateIssued'
:
datetime
.
utcnow
(),
# mandatory
'location'
:
Point
([
0
,
0
]),
# mandatory
'dayMinimum'
:
{
'feelsLikeTemperature'
:
0
,
'temperature'
:
0
,
'relativeHumidity'
:
0.0
},
'dayMaximum'
:
{
'feelsLikeTemperature'
:
0
,
'temperature'
:
0
,
'relativeHumidity'
:
0.0
},
'precipitationProbability'
:
0.0
,
'windSpeed'
:
0
,
'validFrom'
:
datetime
.
fromtimestamp
(
0
),
'validTo'
:
datetime
.
fromtimestamp
(
0
),
},
'FlowerBed'
:
{
'location'
:
Point
([
0
,
0
]),
# mandatory
'soilMoisture'
:
0.0
,
'moistureDeviceEui'
:
None
,
'boxOperatorComment'
:
''
,
'soilType'
:
None
,
'location'
:
Point
([
0
,
0
]),
# mandatory
'flowerType'
:
None
,
'sunExposure'
:
None
,
'windExposure'
:
None
,
'boxId'
:
None
,
'boxSize'
:
None
,
'dateLastWatering'
:
datetime
.
fromtimestamp
(
0
),
'nextWateringDeadline'
:
datetime
.
fromtimestamp
(
0
),
'nextWateringAmountRecommendation'
:
datetime
.
fromtimestamp
(
0
),
'installationDate'
:
datetime
.
fromtimestamp
(
0
),
'soilMoisture'
:
0.0
,
'moistureDeviceEui'
:
None
,
'boxId'
:
None
,
'boxSize'
:
None
,
'boxOperatorComment'
:
''
,
}
}
...
...
@@ -140,7 +134,8 @@ for urn, pilots in entities:
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
()}
**
{
attr_n
:
get_ngsiv2_typed_description
(
attr_v
)
for
attr_n
,
attr_v
in
extra_args
[
data_type
]
.
items
()}
})
except
KeyError
:
raise
KeyError
(
'Unrecognized pilot {}'
.
format
(
pilot
))
...
...
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