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
ba0a4ce0
Commit
ba0a4ce0
authored
Nov 25, 2020
by
Federico Sismondi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates logged info
parent
78a42ed2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
dca-carouge-watering/app.py
dca-carouge-watering/app.py
+7
-6
No files found.
dca-carouge-watering/app.py
View file @
ba0a4ce0
...
...
@@ -144,6 +144,7 @@ def _log_level_of_moisture(cb, sensor):
else
:
app
.
logger
.
error
(
"Measurement not in expected range: {} cb"
.
format
(
cb
))
def
_log_level_of_battery_level
(
bat
,
sensor
):
if
bat
<
0.5
:
...
...
@@ -256,15 +257,16 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui):
app
.
logger
.
debug
(
'Found FlowerBed {} associated to sensor {}'
.
format
(
flowerbed_id
,
sensor_eui
))
body
=
{
"soilMoisture"
:
get_ngsiv2_typed_description
(
soil_moisture
)}
url
=
"{}/v2/entities/{}/attrs"
.
format
(
URL_BASE
,
flowerbed_id
)
r
=
client_request
.
patch
(
url
=
url
,
headers
=
http_header_post
,
json
=
{
"soilMoisture"
:
get_ngsiv2_typed_description
(
soil_moisture
)
}
json
=
body
)
app
.
logger
.
debug
(
'Sending data to CTX broker: {}'
.
format
(
body
))
if
not
(
200
<=
r
.
status_code
<
300
):
app
.
logger
.
error
(
'HTTP status code not 2xx, something went wrong..'
)
app
.
logger
.
error
(
r
.
status_code
)
...
...
@@ -272,7 +274,7 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui):
app
.
logger
.
error
(
r
.
json
())
return
"Got error {}"
.
format
(
r
.
reason
)
else
:
app
.
logger
.
info
(
'
HTTP response is {} - Entity updated'
.
format
(
r
.
status_code
))
app
.
logger
.
info
(
'
Entity updated (code {}), url {}'
.
format
(
r
.
status_code
,
url
))
return
"ok"
...
...
@@ -352,7 +354,6 @@ def _update_device_entity(deveui, comment, longitude, latitude, last_reception,
body
.
update
({
'value'
:
get_ngsiv2_typed_description
(
moist
)})
body
.
update
({
'batteryLevel'
:
get_ngsiv2_typed_description
(
bat
)})
if
dataFrame_rssi
:
body
.
update
({
'rssi'
:
get_ngsiv2_typed_description
(
dataFrame_rssi
)})
...
...
@@ -372,7 +373,7 @@ def _update_device_entity(deveui, comment, longitude, latitude, last_reception,
app
.
logger
.
error
(
r
.
json
())
return
"Got error {}"
.
format
(
r
.
reason
)
else
:
app
.
logger
.
info
(
'
HTTP response is {} - Entity updated'
.
format
(
r
.
status_code
))
app
.
logger
.
info
(
'
Entity updated (code {}), url {}'
.
format
(
r
.
status_code
,
url
))
return
"ok"
...
...
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