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
d1bf205e
Commit
d1bf205e
authored
Jun 25, 2020
by
Federico Sismondi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update() entities init values
parent
be7f3218
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
7 deletions
+32
-7
weather-data-collection-carouge/weather_create_entities.py
weather-data-collection-carouge/weather_create_entities.py
+32
-7
No files found.
weather-data-collection-carouge/weather_create_entities.py
View file @
d1bf205e
...
...
@@ -51,18 +51,39 @@ weather_entities = [
extra_args
=
{
'WeatherObserved'
:
{
'dateObserved'
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
'location'
:
{
'type'
:
'Point'
,
'coordinates'
:
[
6.1385878
,
46.1838613
]}
'dateObserved'
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
# mandatory
'location'
:
{
'type'
:
'Point'
,
'coordinates'
:
[
6.1385878
,
46.1838613
]},
# mandatory
'source'
:
'misc.'
,
'illuminance'
:
0
,
'temperature'
:
0.0
,
'precipitation'
:
0
,
'atmosphericPressure'
:
0.0
,
'windSpeed'
:
0
,
'pressureTendency'
:
0.0
,
'relativeHumidity'
:
0
,
},
'WeatherForecast'
:
{
'dateIssued'
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
'dateIssued'
:
datetime
.
datetime
.
utcnow
()
.
isoformat
(),
# mandatory
'address'
:
{
'streetAddress'
:
'Place de Sardaigne'
,
'adressLocality'
:
'Carouge'
,
'ad
d
ressLocality'
:
'Carouge'
,
'addressCountry'
:
'Switzerland'
},
# mandatory
"dayMinimum"
:
{
"feelsLikeTemperature"
:
11
,
"temperature"
:
11
,
"relativeHumidity"
:
0.7
},
"dayMaximum"
:
{
"feelsLikeTemperature"
:
15
,
"temperature"
:
15
,
"relativeHumidity"
:
0.9
},
"precipitationProbability"
:
0.15
,
'windSpeed'
:
0
,
}
}
...
...
@@ -88,14 +109,15 @@ for urn, schema, keep_history in weather_entities:
)
entities
.
append
(
instance
)
# create entities in IoT platform
print
(
"Updating entities"
)
# log created entities
print
(
'Entities list (len {}) ready to be pushed to platform '
.
format
(
len
(
entities
)))
for
i
in
entities
:
pprint
(
i
,
indent
=
4
)
# create entities in IoT platform
print
(
"
%
s - updating entities"
%
datetime
.
datetime
.
now
()
.
replace
(
microsecond
=
0
)
.
isoformat
())
operation
=
{
"actionType"
:
"append"
,
"entities"
:
entities
...
...
@@ -105,9 +127,12 @@ try:
r
=
requests
.
post
(
url
=
URL_BASE
+
"/v2/op/update?options=keyValues"
,
headers
=
h
,
json
=
operation
)
if
not
(
200
<=
r
.
status_code
<
300
):
print
(
"HTTP status code not 2xx, something went wrong.."
)
print
(
r
.
status_code
)
print
(
r
.
reason
)
print
(
r
.
json
())
else
:
print
(
"Entities updated (HTTP response is 2xx)"
)
except
StopIteration
:
pass
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