Repository: ChristianTremblay/BAC0 (language: python)

Issue:
Auto Save Function Error
I have auto save function enable for a particular device but the history does not auto save after user defined polling cycles. However, history does save when save function manually executed for this device. I had other devices on the network performed as expected with auto save function. Please see the error message below: 
![Auto Saving Issue](https://user-images.githubusercontent.com/67067860/105737163-3988c900-5efb-11eb-8120-c11478d3fcd9.PNG)

Don't raise in `_discoverPoints` when TrendLog init fails
This can happen if the read for `logDeviceObjectProperty` fails while building the `TrendLog` object. Currently there's a debug message generated, for example:

`DEBUG   | Property Access Error for <bacpypes.basetypes.ErrorType object at 0x7f0394564940>`

but no other information and the exception stops the controller's points list from getting populated


Discussion / hints:
This is a super mega giga big error message :) Which is not really supposed to appear until thing goes really bad.... Can you tell me more about the use case and when / why / how it happened.


Fix patch:
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644
index 00000000..b671fc09
--- /dev/null
+++ b/.github/workflows/stale.yml
@@ -0,0 +1,19 @@
+name: Mark stale issues and pull requests
+
+on:
+  schedule:
+  - cron: "30 1 * * *"
+
+jobs:
+  stale:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/stale@v3
+      with:
+        repo-token: ${{ secrets.GITHUB_TOKEN }}
+        stale-issue-message: 'Stale issue message'
+        stale-pr-message: 'Stale pull request message'
+        stale-issue-label: 'no-issue-activity'
+        stale-pr-label: 'no-pr-activity'
diff --git a/BAC0/core/devices/Device.py b/BAC0/core/devices/Device.py
index 21296fa3..417256ca 100755
--- a/BAC0/core/devices/Device.py
+++ b/BAC0/core/devices/Device.py
@@ -855,6 +855,7 @@ def connect(self, *, db=None):
                 self.new_state(RPDeviceConnected)
 
             except (NoResponseFromController, AttributeError) as error:
+                self._log.warning("Error connecting: %s", error)
                 if self.properties.db_name:
                     self.new_state(DeviceFromDB)
                 else:
diff --git a/BAC0/core/devices/mixins/read_mixin.py b/BAC0/core/devices/mixins/read_mixin.py
index 63f9860a..54b742c0 100755
--- a/BAC0/core/devices/mixins/read_mixin.py
+++ b/BAC0/core/devices/mixins/read_mixin.py
@@ -385,6 +385,8 @@ def _find_propid_index(key):
         for each in retrieve_type(objList, "trendLog"):
             point_address = str(each[1])
             tl = TrendLog(point_address, self, read_log_on_creation=False)
+            if tl.properties.log_device_object_property is None:
+                continue
             ldop_type, ldop_addr = (
                 tl.properties.log_device_object_property.objectIdentifier
             )
diff --git a/BAC0/core/functions/cov.py b/BAC0/core/functions/cov.py
index dd595a80..972e595e 100644
--- a/BAC0/core/functions/cov.py
+++ b/BAC0/core/functions/cov.py
@@ -24,8 +24,8 @@ class SubscriptionContext:
 
     def __init__(self, address, objectID, confirmed=None, lifetime=None, callback=None):
         self.address = address
-        self.subscriberProcessIdentifier = self.next_proc_id
-        self.next_proc_id += 1
+        self.subscriberProcessIdentifier = SubscriptionContext.next_proc_id
+        SubscriptionContext.next_proc_id += 1
         self.monitoredObjectIdentifier = objectID
         self.issueConfirmedNotifications = confirmed
         self.lifetime = lifetime
diff --git a/BAC0/infos.py b/BAC0/infos.py
index 126b36ef..97795312 100644
--- a/BAC0/infos.py
+++ b/BAC0/infos.py
@@ -12,5 +12,5 @@
 __email__ = "christian.tremblay@servisys.com"
 __url__ = "https://github.com/ChristianTremblay/BAC0"
 __download_url__ = "https://github.com/ChristianTremblay/BAC0/archive/master.zip"
-__version__ = "21.01.28"
+__version__ = "21.0204"
 __license__ = "LGPLv3"
diff --git a/BAC0/sql/sql.py b/BAC0/sql/sql.py
index 83620915..4dd3d4cb 100644
--- a/BAC0/sql/sql.py
+++ b/BAC0/sql/sql.py
@@ -155,7 +155,7 @@ def save(self, filename=None, resampling=None):
                 filename = filename.split(".")[0]
             self.properties.db_name = filename
         else:
-            self.properties.db_name = "{}".format(self.properties.name)
+            self.properties.db_name = "dev_{}".format(self.properties.device_id)
 
         if resampling is None:
             resampling = self.properties.save_resampling
diff --git a/README.rst b/README.rst
index ceded2ae..a4b90cbd 100644
--- a/README.rst
+++ b/README.rst
@@ -47,7 +47,7 @@ But also a really good tool to assist your startup, test and balancing. Using Ju
 even be able to create nice looking report right from your code.
 
 
-.. |build-status| image:: https://github.com/ChristianTremblay/BAC0/workflows/Python%20package/badge.svg?branch=master
+.. |build-status| image:: https://github.com/ChristianTremblay/BAC0/workflows/Build%20&%20Test/badge.svg?branch=master
    :target: https://github.com/ChristianTremblay/BAC0/actions
    :alt: Build status
      
diff --git a/doc/source/cov.rst b/doc/source/cov.rst
index 66dd68b2..831fffc7 100644
--- a/doc/source/cov.rst
+++ b/doc/source/cov.rst
@@ -39,7 +39,7 @@ the function as a callback to the subscription ::
 
     # elements is a dict containing all the information of the COV 
     def my_callback(elements):
-        print("Present value is : {}".format(elements['properties']['presentValue'])
+        print("Present value is : {}".format(elements['properties']['presentValue']))
 
 .. note:: 
     Here you can find a typical COV notification and the content of elements.


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3b51173d..464e56d9 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,7 +1,7 @@
 # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
 # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
 
-name: Python package
+name: Build & Test
 
 on:
   push:
@@ -15,7 +15,6 @@ jobs:
     strategy:
       matrix:
         python-version: [3.6, 3.7, 3.8, 3.9]
-
     steps:
     - uses: actions/checkout@v2
     - name: Set up Python ${{ matrix.python-version }}
@@ -48,3 +47,25 @@ jobs:
       run: |
         coverage run --source BAC0 -m pytest -v
         coverage report
+    - name: Upload coverage data to coveralls.io
+      if: matrix.python-version == '3.9'
+      run: coveralls
+      env:
+        GITHUB_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
+        COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
+
+        
+#  coveralls:
+#    name: Indicate completion to coveralls.io
+#    needs: build
+#    runs-on: ubuntu-latest
+#    container: python:3-slim
+#    steps:
+#    - name: Finished
+#      run: |
+#        pip3 install --upgrade coveralls
+#        coveralls --finish
+#      env:
+#        GITHUB_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
+#        COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
+#        COVERALLS_PARALLEL: true
\ No newline at end of file