Skip to content

Commit

Permalink
Improved handling an empty 'measurement.yaml' file
Browse files Browse the repository at this point in the history
  • Loading branch information
darkrain-nl committed Apr 7, 2024
1 parent 36446ae commit 9a22377
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.4] - 2024-04-07
### Changed
- Improved handling an empty 'measurement.yaml' file

## [0.8.3] - 2024-04-06
### Added
- Added a check to prevent 'NoneType' is not iterable errors
Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "S0PCM Reader"
description: "S0PCM reader based on docker-s0pcm-reader"
version: "0.8.3"
version: "0.8.4"
slug: "s0pcm_reader"
url: "https://github.com/darkrain-nl/home-assistant-addon-s0pcm-reader"
codenotary: jan@darkrain.nl
Expand Down
7 changes: 4 additions & 3 deletions rootfs/usr/src/s0pcm-reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
config = {}
measurement = {}
measurementshare = {}
s0pcmreaderversion = '2024.04.06'
s0pcmreaderversion = '2024.04.07'

# ------------------------------------------------------------------------------------
# Parameters
Expand Down Expand Up @@ -247,7 +247,7 @@ def ReadMeasurement():
except FileNotFoundError:
logger.warning('No \'%s\' found, using defaults.', measurementname)

# check if measurement['date'] is None
# check if measurement is None
if measurement is not None:
# check date format
if 'date' in measurement:
Expand All @@ -263,7 +263,8 @@ def ReadMeasurement():

logger.debug('Measurement: %s', str(measurement))
else:
logger.error('measurement is None %s', str(measurement))
logger.error('\'%s\' is empty: \'%s\' fix this by removing the file or restoring a backup if you have one...', measurementname, str(measurement))
raise SystemExit('Cannot continue, the error above needs to be fixed first')

# ------------------------------------------------------------------------------------
# Task to read the serial port. We continue to try to open the serialport, because
Expand Down

0 comments on commit 9a22377

Please sign in to comment.