Skip to content

Commit 5dd8dc2

Browse files
committed
- Fixed bug where custom Y axis tick marks and locations were sometimes not plotted properly.
- Fixed bug where `rcParamsDevice` devices were not skipped when user elects to redraw all charts from the plugin menu. - Adds module filename to chart error tracebacks to make it easier to find the error. - Adds new module `validate` and moves validation code to that module. - Code refinements. - Minor UI refinements.
1 parent d36ad43 commit 5dd8dc2

21 files changed

+242
-412
lines changed

_changelog.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
#### v2022.1.6
2+
- Fixed bug where custom Y axis tick marks and locations were sometimes not plotted properly.
3+
- Fixed bug where `rcParamsDevice` devices were not skipped when user elects to redraw all charts from the plugin menu.
4+
- Adds module filename to chart error tracebacks to make it easier to find the error.
5+
- Adds new module `validate` and moves validation code to that module.
6+
- Code refinements.
7+
- Minor UI refinements.
8+
19
#### v2022.1.5
210
- Charts
311
- Annotation value precision controls added to Area, Bar Flow Vertical, Bar Stock Horizontal, Bar Stock Vertical,

_to_do_list.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### TODO
2-
- x
2+
-
33

44
#### NEW
55
- Combination device (line/bar to replicate weather devices).
@@ -11,6 +11,7 @@
1111
[See example](https://matplotlib.org/3.1.1/gallery/ticks_and_spines/multiple_yaxis_with_spines.html)
1212
- Create new STEP chart type as step is no longer a supported line style.
1313
[See example](https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.axes.Axes.step.html?highlight=steps%20post)
14+
1415
#### Refinements
1516
- Try to address annotation collisions.
1617
- Allow scripting control or a tool to repopulate color controls so that you can change all bars/lines/scatter etc. in

matplotlib.indigoPlugin/Contents/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>PluginVersion</key>
6-
<string>2022.1.5</string>
6+
<string>2022.1.6</string>
77
<key>ServerApiVersion</key>
88
<string>3.0</string>
99
<key>IwsApiVersion</key>

matplotlib.indigoPlugin/Contents/Server Plugin/Devices.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2896,7 +2896,7 @@
28962896

28972897
<Field id="filterAnomalies" type="textfield" defaultValue="0"
28982898
visibleBindingId="settingsGroup" visibleBindingValue="ch"
2899-
tooltip="If checked, the plugin will hide anomalous data when plotting charts.">
2899+
tooltip="The number of standard deviations to contain anomalous data. Set to zero (the default) to display all data.">
29002900
<Label>Hide Anomalies:</Label>
29012901
</Field>
29022902

@@ -4279,7 +4279,7 @@
42794279
<!-- Filter Anomalies -->
42804280
<Field id="filterAnomalies" type="textfield" defaultValue="0"
42814281
visibleBindingId="settingsGroup" visibleBindingValue="ch"
4282-
tooltip="If checked, the plugin will hide anomalous data when plotting charts.">
4282+
tooltip="The number of standard deviations to contain anomalous data. Set to zero (the default) to display all data.">
42834283
<Label>Hide Anomalies:</Label>
42844284
<CallbackMethod>dummyCallback</CallbackMethod>
42854285
<Description/>

matplotlib.indigoPlugin/Contents/Server Plugin/chart_area.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,6 @@ def __init__():
336336
tb = traceback.format_exc()
337337
tb_type = sys.exc_info()[1]
338338
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
339-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
339+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
340340

341341
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_bar_flow.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,6 @@ def __init__():
257257
tb = traceback.format_exc()
258258
tb_type = sys.exc_info()[1]
259259
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
260-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
260+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
261261

262262
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_bar_radial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ def __init__():
103103
tb = traceback.format_exc()
104104
tb_type = sys.exc_info()[1]
105105
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
106-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
106+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
107107

108108
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_bar_stock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,6 @@ def __init__():
225225
tb = traceback.format_exc()
226226
tb_type = sys.exc_info()[1]
227227
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
228-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
228+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
229229

230230
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_bar_stock_horizontal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,6 @@ def __init__():
221221
tb = traceback.format_exc()
222222
tb_type = sys.exc_info()[1]
223223
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
224-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
224+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
225225

226226
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_batteryhealth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,6 @@
209209
tb = traceback.format_exc()
210210
tb_type = sys.exc_info()[1]
211211
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
212-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
212+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
213213

214214
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_calendar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ def __init__():
122122
tb = traceback.format_exc()
123123
tb_type = sys.exc_info()[1]
124124
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
125-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
125+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
126126

127127
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_line.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,6 @@ def __init__():
302302
tb = traceback.format_exc()
303303
tb_type = sys.exc_info()[1]
304304
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
305-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
305+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
306306

307307
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_multiline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,6 @@ def clean_string(val):
155155
tb = traceback.format_exc()
156156
tb_type = sys.exc_info()[1]
157157
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
158-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
158+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
159159

160160
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_polar.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,6 @@ def __init__():
282282
tb = traceback.format_exc()
283283
tb_type = sys.exc_info()[1]
284284
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
285-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
285+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
286286

287287
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_scatter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,6 @@ def __init__():
276276
tb = traceback.format_exc()
277277
tb_type = sys.exc_info()[1]
278278
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
279-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
279+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
280280

281281
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_tools.py

+6-11
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,9 @@ def format_axis_y_ticks(p_dict, k_dict, logger):
446446
:param dict logger:
447447
"""
448448

449-
# custom_ticks_marks = p_dict['customTicksY'].strip()
450-
# custom_ticks_labels = p_dict['customTicksLabelY'].strip()
451-
custom_ticks_marks = [_.strip() for _ in p_dict['customTicksY']]
452-
custom_ticks_labels = [_.strip() for _ in p_dict['customTicksLabelY']]
453-
454449
try:
450+
custom_ticks_marks = [float(_) for _ in p_dict['customTicksY'].split(',')]
451+
custom_ticks_labels = [_ for _ in p_dict['customTicksLabelY'].split(',')]
455452
# Get the default tick values and labels (which we'll replace as needed.)
456453
marks, labels = plt.yticks()
457454

@@ -464,14 +461,12 @@ def format_axis_y_ticks(p_dict, k_dict, logger):
464461
custom_ticks_labels = custom_ticks_marks
465462

466463
# Replace default Y tick values with the custom ones.
467-
# if custom_ticks_marks.lower() not in ('none', '') \
468-
# and not custom_ticks_marks.isspace():
469-
# marks = [float(_) for _ in custom_ticks_marks.split(",")]
464+
if custom_ticks_marks not in ('none', ''):
465+
marks = custom_ticks_marks
470466

471467
# Replace the default Y tick labels with the custom ones.
472-
# if custom_ticks_labels.lower() not in ('none', '') \
473-
# and not custom_ticks_labels.isspace():
474-
# labels = [f"{_.strip()}" for _ in custom_ticks_labels.split(",")]
468+
if custom_ticks_labels not in ('none', ''):
469+
labels = custom_ticks_labels
475470

476471
plt.yticks(marks, labels)
477472

matplotlib.indigoPlugin/Contents/Server Plugin/chart_weather_composite.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,6 @@ def transparent_chart_fill(s):
359359
tb = traceback.format_exc()
360360
tb_type = sys.exc_info()[1]
361361
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
362-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
362+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
363363

364364
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/chart_weather_forecast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,6 @@ def __init__():
475475
tb = traceback.format_exc()
476476
tb_type = sys.exc_info()[1]
477477
LOG['Debug'].append(f"[{CHART_NAME}] {tb}")
478-
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type}")
478+
LOG['Critical'].append(f"[{CHART_NAME}] Error type: {tb_type} in {__file__.split('/')[-1]}")
479479

480480
json.dump(LOG, sys.stdout, indent=4)

matplotlib.indigoPlugin/Contents/Server Plugin/maintenance.py

+16-26
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
__title__ = "maintenance"
2525
__version__ = "0.1.02"
2626

27-
2827
class Maintain:
2928
"""
3029
Title Placeholder
@@ -41,14 +40,13 @@ def __init__(self, plugin):
4140
"""
4241
self.plugin = plugin
4342
self.pluginPrefs = plugin.pluginPrefs
43+
self.my_logger = logging.getLogger("Plugin.Maintain")
4444

45-
fmt = '%(asctime)s.%(msecs)03d\t%(levelname)-10s\t%(name)s.%(funcName)-28s %(msg)s'
46-
self.plugin.plugin_file_handler.setFormatter(logging.Formatter(fmt,
47-
datefmt='%Y-%m-%d %H:%M:%S'
48-
)
49-
)
45+
# fmt = '%(asctime)s.%(msecs)03d\t%(levelname)-10s\t%(name)s.%(funcName)-28s %(msg)s'
46+
# self.plugin.plugin_file_handler.setFormatter(logging.Formatter(fmt,datefmt='%Y-%m-%d %H:%M:%S'))
5047

51-
self.plugin.logger.threaddebug("Initializing maintenance framework.")
48+
# my_logger.threaddebug("Initializing maintenance framework.")
49+
self.my_logger.debug("Initializing maintenance framework.x")
5250

5351
def clean_prefs(self, dev_name, prefs):
5452
"""
@@ -361,9 +359,9 @@ def clean_prefs(self, dev_name, prefs):
361359

362360
# Log list of removed keys
363361
if list_of_removed_keys:
364-
self.plugin.logger.debug(
365-
f"[{dev_name}] Performing maintenance - removing unneeded keys: "
366-
f"{list_of_removed_keys}")
362+
self.my_logger.debug(
363+
f"[{dev_name}] Performing maintenance - removing unneeded keys: {list_of_removed_keys}"
364+
)
367365

368366
return prefs
369367

@@ -375,7 +373,6 @@ def clean_props(self, dev):
375373
376374
:return:
377375
"""
378-
379376
props = dev.pluginProps
380377

381378
# ================================ All Devices ================================
@@ -423,9 +420,7 @@ def clean_props(self, dev):
423420
ui_value = 'Manual'
424421
else:
425422
ui_value = " "
426-
dev.updateStatesOnServer(
427-
[{'key': 'onOffState', 'value': True, 'uiValue': ui_value}]
428-
)
423+
dev.updateStatesOnServer([{'key': 'onOffState', 'value': True, 'uiValue': ui_value}])
429424

430425
# ============================= Non-chart Devices =============================
431426
if dev.deviceTypeId in ('csvEngine', 'rcParamsDevice'):
@@ -437,7 +432,7 @@ def clean_props(self, dev):
437432
# If chartLastUpdated is empty, set it to the epoch
438433
if dev.deviceTypeId != 'csvEngine' and dev.states['chartLastUpdated'] == "":
439434
dev.updateStateOnServer(key='chartLastUpdated', value='1970-01-01 00:00:00.000000')
440-
self.plugin.logger.threaddebug("CSV last update unknown. Coercing update.")
435+
self.my_logger.threaddebug("CSV last update unknown. Coercing update.")
441436

442437
# =============================== Chart Devices ===============================
443438
elif dev.deviceTypeId not in ('csvEngine', 'rcParamsDevice'):
@@ -457,9 +452,7 @@ def clean_props(self, dev):
457452
# For all chart device types
458453
# Update legacy color values from hex to raw (#FFFFFF --> FF FF FF)
459454
if re.search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', str(props[prop])):
460-
self.plugin.logger.debug(
461-
f"[{dev.name}] Refactoring color property: ({prop})"
462-
)
455+
self.my_logger.debug(f"[{dev.name}] Refactoring color property: ({prop})")
463456
props[prop] = f"{prop[0:3]} {prop[3:5]} {prop[5:7]}".replace('#', '')
464457

465458
# ============================== Fix Line Styles ==============================
@@ -470,9 +463,8 @@ def clean_props(self, dev):
470463
# If unsupported style in dev props
471464
if props[prop] in ('steps', 'steps-mid', 'steps-post'):
472465
# Change style to `solid`
473-
self.plugin.logger.warning(
474-
f"Converting deprecated line style setting to solid line style for "
475-
f"device [{dev.name}]."
466+
self.my_logger.warning(
467+
f"Converting deprecated line style setting to solid line style for device [{dev.name}]."
476468
)
477469
props[prop] = '-'
478470

@@ -486,7 +478,7 @@ def clean_props(self, dev):
486478
if 'color' in prop.lower():
487479
if props[prop] in ('#custom', 'custom'):
488480

489-
self.plugin.logger.debug(
481+
self.my_logger.debug(
490482
"Resetting legacy device preferences for custom colors to new "
491483
"color picker.")
492484

@@ -559,17 +551,15 @@ def clean_props(self, dev):
559551
# =============== Establish Refresh Interval for Legacy Devices ===============
560552
# Establish refresh interval for legacy devices. If the prop isn't present, we set it equal to the
561553
# user's current global refresh rate.
562-
# if 'refreshInterval' not in props.keys():
563554
if 'refreshInterval' not in props:
564-
self.plugin.logger.debug(
565-
"Adding refresh interval to legacy device. Set to 900 seconds.")
555+
self.my_logger.debug("Adding refresh interval to legacy device. Set to 900 seconds.")
566556
props['refreshInterval'] = self.pluginPrefs.get('refreshInterval', 900)
567557

568558
# ============================= Update the Server =============================
569559
dev.replacePluginPropsOnServer(props)
570560

571561
if self.plugin.pluginPrefs['verboseLogging']:
572-
self.plugin.logger.threaddebug(f"[{dev.name}] prefs cleaned.")
562+
self.my_logger.threaddebug(f"[{dev.name}] prefs cleaned.")
573563

574564
except Exception as err:
575565
indigo.server.log(str(err), isError=True)

0 commit comments

Comments
 (0)