Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Commit

Permalink
Merge pull request #16 from foglamp/1.5.0RC
Browse files Browse the repository at this point in the history
1.5.0 Release
  • Loading branch information
praveen-garg authored Feb 22, 2019
2 parents d46a167 + c24d086 commit c5d2fd6
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 136 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*.idea

# Build
packages/Debian/build/
packages/build/

# Compiled Object files
*.pyc
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2018 Dianomic Systems

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 2 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ Create Debian Package
.. code-block:: console
$ ./make_deb help
make_deb {arm} [clean|cleanall]
make_deb [clean|cleanall]
This script is used to create the Debian package of foglamp dht11 plugin
Arguments:
arm - Build an armv7l package
clean - Remove all the old versions saved in format .XXXX
cleanall - Remove all the versions, including the last one
``./make_deb arm`` will create the debian package inside ``packages/Debian/build/``.
``./make_deb`` will create the debian package inside ``packages/build/``.


Pre Debian Package Install
Expand Down
4 changes: 2 additions & 2 deletions VERSION.south.dht11
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foglamp_south_dht11_version=1.0.1
foglamp_version>=1.3
foglamp_south_dht11_version=1.5.0
foglamp_version>=1.5
90 changes: 41 additions & 49 deletions make_deb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

##--------------------------------------------------------------------
## Copyright (c) 2018 OSIsoft, LLC
## Copyright (c) 2018 Dianomic Systems
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand All @@ -16,70 +16,62 @@
## limitations under the License.
##--------------------------------------------------------------------
##
## Author: Ivan Zoratti, Praveen Garg
## Author: Ivan Zoratti, Praveen Garg, Vaibhav Singhal
##

set -e
plugin_type="south"
plugin_name="dht11"

GIT_ROOT=`pwd` # The script must be executed from the root git directory
architecture="none"
usage="$(basename "$0") {arm} [clean|cleanall]
This script is used to create the Debian package of foglamp dht11 plugin
Arguments:
arm - Build an armv7l package
usage="$(basename "$0") [clean|cleanall]
This script is used to create the Debian package of FogLAMP '${plugin_name}' ${plugin_type} plugin
Arguments:
clean - Remove all the old versions saved in format .XXXX
cleanall - Remove all the versions, including the last one"

if [ $# -gt 0 ]
then
for i in "$@"
do
case "$i" in
arm)
architecture="armhf"
shift
;;
clean)
echo -n "Cleaning the build folder from older versions..."
find "${GIT_ROOT}/packages/Debian/build" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
GIT_ROOT=`pwd` # The script must be executed from the root git directory
for i in "$@"
do
case "$i" in
clean)
echo -n "Cleaning the build folder from older versions..."
find "${GIT_ROOT}/packages/build" -maxdepth 1 | grep '.*\.[0-9][0-9][0-9][0-9]' | xargs rm -rf
echo "Done."
exit 0
;;
cleanall)
if [ -d "${GIT_ROOT}/packages/build" ]; then
echo -n "Cleaning the build folder..."
rm -rf ${GIT_ROOT}/packages/build/*
echo "Done."
shift
;;
cleanall)
if [ -d "${GIT_ROOT}/packages/Debian/build" ]; then
echo -n "Cleaning the build folder..."
rm -rf ${GIT_ROOT}/packages/Debian/build/*
echo "Done."
else
echo "No build folder, skipping cleanall"
fi
shift
;;
help)
echo "${usage}"
exit 1
;;
*)
echo "Unrecognized option: $i"
exit 1
;;
esac
done
else
echo "See help and select the architecture to use, *x86* or *arm*"
fi
else
echo "No build folder, skipping cleanall"
fi
exit 0
;;
help)
echo "${usage}"
exit 0
;;
*)
echo "Unrecognized option: $i"
exit 1
;;
esac
done


# If the architecture has not been defined, then the script is complete
if [[ "$architecture" == "none" ]]; then
# echo "${usage}"
if [ "$(dpkg --print-architecture)" != "armhf" ]; then
echo "Package building is only supported on armhf architecture!!"
exit 0
fi

architecture="armhf"

version=`cat ${GIT_ROOT}/VERSION.south.dht11 | tr -d ' ' | grep 'foglamp_south_dht11_version=' | head -1 | sed -e 's/\(.*\)=\(.*\)/\2/g'`
foglamp_version=`cat ${GIT_ROOT}/VERSION.south.dht11 | tr -d ' ' | grep 'foglamp_version' | head -1 | sed -e 's/\(.*\)version\(.*\)/\2/g'`
BUILD_ROOT="${GIT_ROOT}/packages/Debian/build"
BUILD_ROOT="${GIT_ROOT}/packages/build"

# Final package name
package_name="foglamp-south-dht11-${version}-${architecture}"
Expand Down
2 changes: 1 addition & 1 deletion packages/Debian/armhf/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Version: 1.0.0
Section: devel
Priority: optional
Architecture: armhf
Depends: foglamp
Depends: build-essential,python3-dev,foglamp
Conflicts:
Maintainer: Dianomic Systems, Inc. <[email protected]>
Homepage: http://www.dianomic.com
Expand Down
8 changes: 1 addition & 7 deletions packages/Debian/armhf/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

##--------------------------------------------------------------------
## Copyright (c) 2018 OSIsoft, LLC
## Copyright (c) 2018 Dianomic Systems
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,12 +35,6 @@ set_files_ownership () {
chown -R root:root /usr/local/foglamp/python/foglamp/plugins/south/dht11
}

add_service () {
output=$(curl -sX POST http://localhost:8081/foglamp/service -d '{"name": "DHT11", "type": "south", "plugin": "dht11", "enabled": true}')
echo $output
}

# install_deps # FIXME: https://github.com/adafruit/Adafruit_Python_DHT/issues/99
set_files_ownership
add_service
echo "dht11 plugin installed."
51 changes: 0 additions & 51 deletions packages/Debian/armhf/DEBIAN/preinst

This file was deleted.

42 changes: 23 additions & 19 deletions python/foglamp/plugins/south/dht11/dht11.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,35 @@
import Adafruit_DHT

from foglamp.common import logger
from foglamp.plugins.common import utils
from foglamp.services.south import exceptions


__author__ = "Mark Riddoch"
__copyright__ = "Copyright (c) 2017 OSIsoft, LLC"
__copyright__ = "Copyright (c) 2018 Dianomic Systems"
__license__ = "Apache 2.0"
__version__ = "${VERSION}"

_DEFAULT_CONFIG = {
'plugin': {
'description': 'Python module name of the plugin to load',
'type': 'string',
'default': 'dht11'
'description': 'DHT11 South Plugin',
'type': 'string',
'default': 'dht11',
'readonly': 'true'
},
'pollInterval': {
'description': 'The interval between poll calls to the sensor poll routine expressed in milliseconds.',
'type': 'integer',
'default': '1000'
'assetName': {
'description': 'Asset name',
'type': 'string',
'default': "dht11",
'order': "1",
'displayName': 'Asset Name'
},
'gpiopin': {
'gpioPin': {
'description': 'The GPIO pin into which the DHT11 data pin is connected',
'type': 'integer',
'default': '4'
'default': '4',
'order': '3',
'displayName': 'GPIO Pin'
}

}
Expand All @@ -58,7 +64,7 @@ def plugin_info():

return {
'name': 'DHT11 GPIO',
'version': '1.0',
'version': '1.5.0',
'mode': 'poll',
'type': 'south',
'interface': '1.0',
Expand All @@ -76,7 +82,7 @@ def plugin_init(config):
Raises:
"""

handle = config
handle = copy.deepcopy(config)
return handle


Expand All @@ -95,12 +101,12 @@ def plugin_poll(handle):
"""

try:
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, handle['gpiopin']['value'])
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11, handle['gpioPin']['value'])
if humidity is not None and temperature is not None:
time_stamp = str(datetime.now(tz=timezone.utc))
time_stamp = utils.local_timestamp()
readings = {'temperature': temperature, 'humidity': humidity}
wrapper = {
'asset': 'dht11',
'asset': handle['assetName']['value'],
'timestamp': time_stamp,
'key': str(uuid.uuid4()),
'readings': readings
Expand All @@ -127,9 +133,7 @@ def plugin_reconfigure(handle, new_config):
"""
_LOGGER.info("Old config for DHT11 plugin {} \n new config {}".format(handle, new_config))

new_handle = copy.deepcopy(handle)
new_handle['restart'] = 'no'

new_handle = copy.deepcopy(new_config)
return new_handle


Expand All @@ -141,4 +145,4 @@ def plugin_shutdown(handle):
Returns:
Raises:
"""
pass
_LOGGER.info("DHT11 Poll plugin shutdown")
4 changes: 2 additions & 2 deletions test/test_dht11.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from python.foglamp.plugins.south.dht11 import dht11

__author__ = "Praveen Garg"
__copyright__ = "Copyright (c) 2017 OSIsoft, LLC"
__copyright__ = "Copyright (c) 2018 Dianomic Systems"
__license__ = "Apache 2.0"
__version__ = "${VERSION}"

Expand All @@ -28,7 +28,7 @@ def test_plugin_contract():
def test_plugin_info():
assert dht11.plugin_info() == {
'name': 'DHT11 GPIO',
'version': '1.0',
'version': '1.5.0',
'mode': 'poll',
'type': 'south',
'interface': '1.0',
Expand Down

0 comments on commit c5d2fd6

Please sign in to comment.