Skip to content

Commit 4f59bfc

Browse files
committed
Changes to prepare for Indigo 2023.2 and code refinements.
1 parent 35bd927 commit 4f59bfc

16 files changed

+221
-194
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 DaveL17
3+
Copyright (c) 2023 DaveL17
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

_changelog.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### v2023.0.1
2+
- Changes to prepare for Indigo `v2023.2`.
3+
- Code enhancements.
4+
15
#### v2022.1.7
26
- Fixes bug where `Matplotlib Paramters Device` incorrectly labelled in error state.
37
- Fixes bug `PluginAction' object has no attribute 'PROPS'`.
@@ -436,7 +440,7 @@
436440

437441
#### v0.7.54
438442
- Fixes float error in the duration value for CSV refreshes.
439-
- Moves dev prop maintenance routine to deviceStartComm.
443+
- Moves dev prop maintenance routine to device_start_comm.
440444

441445
#### v0.7.53
442446
- Adds tests to alert the user that they're saving charts to the wrong location (when the Indigo version is updated.)
@@ -559,7 +563,7 @@
559563
settings are retained.
560564

561565
#### v0.7.24
562-
- Synchronize self.pluginPrefs in closedPrefsConfigUi().
566+
- Synchronize self.pluginPrefs in closed_prefs_config_ui().
563567

564568
#### v0.7.23
565569
- Adds choice to set bar width to make it simpler for first time device creation. If the value is set to zero, the

_to_do_list.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### TODO
2-
-
2+
- Vertical bar stock charts don't allow for setting annotation precision for bar 5. Others? see https://forums.indigodomo.com/viewtopic.php?f=219&t=27024
3+
- Do we still have to use x-axis label OR legend (but not both?) see https://forums.indigodomo.com/viewtopic.php?f=219&t=27024
34

45
#### NEW
56
- Combination device (line/bar to replicate weather devices).
@@ -11,6 +12,7 @@
1112
[See example](https://matplotlib.org/3.1.1/gallery/ticks_and_spines/multiple_yaxis_with_spines.html)
1213
- Create new STEP chart type as step is no longer a supported line style.
1314
[See example](https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.axes.Axes.step.html?highlight=steps%20post)
15+
- Add secondary X-axis tick labels to relevant charts. See https://forums.indigodomo.com/viewtopic.php?f=219&t=27024
1416

1517
#### Refinements
1618
- Try to address annotation collisions.

matplotlib.indigoPlugin/Contents/Info.plist

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
<plist version="1.0">
44
<dict>
55
<key>PluginVersion</key>
6-
<string>2022.1.7</string>
6+
<string>2023.0.1</string>
77
<key>ServerApiVersion</key>
88
<string>3.0</string>
9-
<key>IwsApiVersion</key>
10-
<string>1.0.0</string>
11-
<key>LoadPriority</key>
12-
<integer>105</integer>
139
<key>CFBundleDisplayName</key>
1410
<string>Matplotlib</string>
1511
<key>CFBundleName</key>

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

+39-50
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
__copyright__ = "Copyright 2017-2022 DaveL17"
2525
__license__ = "MIT"
2626
__title__ = "DLFramework"
27-
__version__ = "0.1.04"
27+
__version__ = "0.1.05"
2828

2929
# supported operators for eval expressions
3030
OPERATORS = {
@@ -63,17 +63,14 @@ def __init__(self, plugin):
6363
self.pluginPrefs = plugin.pluginPrefs
6464

6565
log_format = '%(asctime)s.%(msecs)03d\t%(levelname)-10s\t%(name)s.%(funcName)-28s %(msg)s'
66-
self.plugin.plugin_file_handler.setFormatter(
67-
logging.Formatter(fmt=log_format, datefmt='%Y-%m-%d %H:%M:%S')
68-
)
66+
self.plugin.plugin_file_handler.setFormatter(logging.Formatter(fmt=log_format, datefmt='%Y-%m-%d %H:%M:%S'))
6967

7068
# =============================================================================
7169
def pluginEnvironment(self): # noqa
7270
"""
73-
The pluginEnvironment method prints selected information about the pluginEnvironment that
74-
the plugin is running in. It pulls some of this information from the calling plugin and
75-
some from the server pluginEnvironment. It uses the legacy "indigo.server.log" method to
76-
write to the log.
71+
The pluginEnvironment method prints selected information about the pluginEnvironment that the plugin is running
72+
in. It pulls some of this information from the calling plugin and some from the server pluginEnvironment. It
73+
uses the legacy "indigo.server.log" method to write to the log.
7774
7875
:return:
7976
"""
@@ -98,10 +95,10 @@ def pluginEnvironment(self): # noqa
9895
# =============================================================================
9996
def pluginEnvironmentLogger(self): # noqa
10097
"""
101-
The pluginEnvironmentLogger method prints selected information about the pluginEnvironment
102-
that the plugin is running in. It pulls some of this information from the calling plugin
103-
and some from the server pluginEnvironment. This method differs from the pluginEnvironment()
104-
method in that it leverages Indigo's logging hooks using the Python Logger framework.
98+
The pluginEnvironmentLogger method prints selected information about the pluginEnvironment that the plugin is
99+
running in. It pulls some of this information from the calling plugin and some from the server
100+
pluginEnvironment. This method differs from the pluginEnvironment() method in that it leverages Indigo's
101+
logging hooks using the Python Logger framework.
105102
106103
:return:
107104
"""
@@ -128,13 +125,11 @@ def pluginErrorHandler(self, sub_error): # noqa
128125
"""
129126
Centralized handling of traceback messages
130127
131-
Centralized handling of traceback messages formatted for pretty display in the plugin log
132-
file. If sent here, they will not be displayed in the Indigo Events log. Use the following
133-
syntax to send exceptions here::
128+
Centralized handling of traceback messages formatted for pretty display in the plugin log file. If sent here,
129+
they will not be displayed in the Indigo Events log. Use the following syntax to send exceptions here:
134130
135131
self.pluginErrorHandler(traceback.format_exc())
136132
137-
138133
:param traceback object sub_error:
139134
:return:
140135
"""
@@ -150,10 +145,9 @@ def pluginErrorHandler(self, sub_error): # noqa
150145
# =============================================================================
151146
def convertDebugLevel(self, debug_val): # noqa
152147
"""
153-
The convertDebugLevel method is used to standardize the various implementations of debug
154-
level settings across plugins. Its main purpose is to convert an old string-based setting
155-
to account for older plugin versions. Over time, this method will become obsolete and
156-
should be deprecated.
148+
The convertDebugLevel method is used to standardize the various implementations of debug level settings across
149+
plugins. Its main purpose is to convert an old string-based setting to account for older plugin versions. Over
150+
time, this method will become obsolete and should be deprecated.
157151
158152
:param str debug_val:
159153
:return:
@@ -188,8 +182,8 @@ def deviceList(dev_filter=None): # noqa
188182
@staticmethod
189183
def deviceListEnabled(dev_filter=None): # noqa
190184
"""
191-
Returns a list of tuples containing Indigo devices for use in config dialogs (etc.) Returns
192-
enabled devices only.
185+
Returns a list of tuples containing Indigo devices for use in config dialogs (etc.) Returns enabled devices
186+
only.
193187
194188
:param str dev_filter:
195189
:return: [(ID, "Name"), (ID, "Name")]
@@ -237,8 +231,7 @@ def deviceAndVariableList(): # noqa
237231
@staticmethod
238232
def deviceAndVariableListClean(): # noqa
239233
"""
240-
Returns a list of tuples containing Indigo devices and variables for use in config dialogs
241-
(etc.)
234+
Returns a list of tuples containing Indigo devices and variables for use in config dialogs (etc.)
242235
243236
:return: [(ID, "(D) Name"), (ID, "(V) Name")]
244237
"""
@@ -255,8 +248,8 @@ def deviceAndVariableListClean(): # noqa
255248
@staticmethod
256249
def launchWebPage(launch_url): # noqa
257250
"""
258-
The launchWebPage method is used to direct a call to the registered default browser and
259-
open the page referenced by the parameter 'URL'.
251+
The launchWebPage method is used to direct a call to the registered default browser and open the page
252+
referenced by the parameter 'URL'.
260253
261254
:param str launch_url:
262255
:return:
@@ -267,8 +260,8 @@ def launchWebPage(launch_url): # noqa
267260
@staticmethod
268261
def generatorStateOrValue(dev_id): # noqa
269262
"""
270-
The generator_state_or_value() method returns a list to populate the relevant device
271-
states or variable value to populate a menu control.
263+
The generator_state_or_value() method returns a list to populate the relevant device states or variable value
264+
to populate a menu control.
272265
273266
:param int dev_id:
274267
:return:
@@ -302,8 +295,7 @@ def audit_server_version(self, min_ver):
302295
"""
303296
Audit Indigo Version
304297
305-
Compare current Indigo version to the minimum version required to successfully run the
306-
plugin.
298+
Compare current Indigo version to the minimum version required to successfully run the plugin.
307299
308300
309301
:param int min_ver:
@@ -312,9 +304,7 @@ def audit_server_version(self, min_ver):
312304

313305
ver = self.plugin.versStrToTuple(indigo.server.version)
314306
if ver[0] < min_ver:
315-
self.plugin.stopPlugin(
316-
f"This plugin requires Indigo version {min_ver} or above.", isError=True
317-
)
307+
self.plugin.stopPlugin(f"This plugin requires Indigo version {min_ver} or above.", isError=True)
318308

319309
self.plugin.logger.debug("Indigo server version OK.")
320310

@@ -323,8 +313,8 @@ def audit_os_version(self, min_ver):
323313
"""
324314
Audit Operating System Version
325315
326-
Compare current OS version to the minimum version required to successfully run the plugin.
327-
Thanks to FlyingDiver for improved audit code.
316+
Compare current OS version to the minimum version required to successfully run the plugin. Thanks to
317+
FlyingDiver for improved audit code.
328318
329319
:param float min_ver:
330320
:return:
@@ -335,9 +325,7 @@ def audit_os_version(self, min_ver):
335325
current_ver = tuple(map(int, (str(mac_os).split(".")))) # current version. i.e., (11, 4)
336326

337327
if current_ver < min_ver:
338-
self.plugin.stopPlugin(
339-
f"The plugin requires macOS version {min_ver} or above.", isError=True
340-
)
328+
self.plugin.stopPlugin(f"The plugin requires macOS version {min_ver} or above.", isError=True)
341329
else:
342330
self.plugin.logger.debug("macOS version OK.")
343331

@@ -362,8 +350,8 @@ def __init__(self, plugin):
362350
# =============================================================================
363351
def dateFormat(self): # noqa
364352
"""
365-
The dateFormat method takes the user configuration preference for date and time display and
366-
converts them to a valid datetime() format specifier.
353+
The dateFormat method takes the user configuration preference for date and time display and converts them to a
354+
valid datetime() format specifier.
367355
368356
:return:
369357
"""
@@ -378,8 +366,8 @@ def dateFormat(self): # noqa
378366
# =============================================================================
379367
def timeFormat(self): # noqa
380368
"""
381-
The timeFormat method takes the user configuration preference for date and time display and
382-
converts them to a valid datetime() format specifier.
369+
The timeFormat method takes the user configuration preference for date and time display and converts them to a
370+
valid datetime() format specifier.
383371
384372
:return:
385373
"""
@@ -391,8 +379,7 @@ def timeFormat(self): # noqa
391379
# =============================================================================
392380
class evalExpr: # noqa
393381
"""
394-
The evalExpr method evaluates mathematical expressions that are passed as strings and returns a
395-
numerical result.
382+
The evalExpr method evaluates mathematical expressions that are passed as strings and returns a numerical result.
396383
397384
This code is licensed under an MIT-compatible license.
398385
credit: jfs @ https://stackoverflow.com/a/9558001/2827397
@@ -434,8 +421,8 @@ def __eval(self, node):
434421
:return:
435422
"""
436423

437-
# See https://stackoverflow.com/q/71353183/2827397 (and the accompanying answer) for an
438-
# explanation of the code inspection warnings thrown by this method.
424+
# See https://stackoverflow.com/q/71353183/2827397 (and the accompanying answer) for an explanation of the code
425+
# inspection warnings thrown by this method.
439426
try:
440427
if isinstance(node, ast.Num): # <number>
441428
value = node.n
@@ -452,11 +439,13 @@ def __eval(self, node):
452439

453440

454441
class DummyClass:
455-
456-
def Dave(self, at1="foo", at2=0):
442+
"""
443+
Dummy class used for testing.
444+
"""
445+
@staticmethod
446+
def dave(at1="foo", at2=0):
457447
"""
458-
This docstring is loosely formatted to `PEP 287` with a nod towards PyCharm reStructured
459-
Text rendering.
448+
This docstring is loosely formatted to `PEP 287` with a nod towards PyCharm reStructured Text rendering.
460449
461450
:param str at1: This is a string attribute.
462451
:param int at2: This is an integer attribute.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@
11231123
</Field>
11241124

11251125
<Field id="yAxisMin" type="textfield" defaultValue="None"
1126-
visibleBindingId="settingsGroup" visibleBindingValue="truye"
1126+
visibleBindingId="settingsGroup" visibleBindingValue="y"
11271127
tooltip="The minimum Y axis value.">
11281128
<Label>Min:</Label>
11291129
</Field>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __init__():
6161
f"in the device configuration menu."
6262
)
6363

64-
# Plot the bars. If 'suppressBar{thing} is True, we skip it.
64+
# Plot the bars. If 'suppressBar{thing}' is True, we skip it.
6565
if P_DICT[f'bar{thing}Source'] not in ("", "None") and not suppress_bar:
6666

6767
# If the bar color is the same as the background color, alert the user.

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

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ def __init__():
117117
# If annotations desired, plot those too.
118118
annotate = P_DICT[f'bar{b_num}Annotate']
119119
precision = int(PROPS.get(f'bar{b_num}AnnotationPrecision', "0"))
120-
# if bar[f'annotate_{b_num}'] and not suppress_bar:
121120
if annotate and bar[f'annotate_{b_num}'] and not suppress_bar:
122121
ax.annotate(
123122
# ANNOTATION_VALUE[b_num - 1],

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ def __init__():
183183
if P_DICT['transparent_charts'] and P_DICT['transparent_filled']:
184184
ax.add_patch(
185185
patches.Rectangle(
186-
(0, 0), 1, 1,
187-
transform=ax.transAxes,
188-
facecolor=P_DICT['faceColor'],
189-
zorder=1
186+
(0, 0), 1, 1,
187+
transform=ax.transAxes,
188+
facecolor=P_DICT['faceColor'],
189+
zorder=1
190190
)
191191
)
192192

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__():
5050

5151

5252
# =============================================================================
53-
def convert_the_data(final_data, data_source, logger):
53+
def convert_the_data(final_data: list, data_source: str, logger: dict):
5454
"""
5555
Convert data into form that matplotlib can understand
5656
@@ -59,9 +59,9 @@ def convert_the_data(final_data, data_source, logger):
5959
example, the WUnderground plugin will present '-99.0' when WUnderground is not able to deliver a rational value.
6060
Therefore, we convert '-99.0' to NaN values.
6161
-----
62-
:param logger:
6362
:param list final_data: the data to be charted
6463
:param str data_source:
64+
:param dict logger:
6565
"""
6666

6767
LOG['Debug'].append(f"[{payload['props']['name']}] "
@@ -212,9 +212,9 @@ def format_axis(ax_obj):
212212
ax_cells = ax_props['children']
213213
for cell in ax_cells:
214214
cell.set_facecolor(payload['p_dict']['faceColor'])
215-
cell._text.set_color(payload['p_dict']['fontColor'])
216-
cell._text.set_fontname(payload['p_dict']['fontMain'])
217-
cell._text.set_fontsize(int(payload['props']['fontSize']))
215+
cell._text.set_color(payload['p_dict']['fontColor']) # noqa
216+
cell._text.set_fontname(payload['p_dict']['fontMain']) # noqa
217+
cell._text.set_fontsize(int(payload['props']['fontSize'])) # noqa
218218
cell.set_linewidth(int(plt.rcParams['lines.linewidth']))
219219

220220
# This may not be supportable without including fonts with the plugin.
@@ -680,11 +680,11 @@ def format_best_fit_line_segments(ax, dates_to_plot, line, p_dict, logger):
680680
fit lines are not appropriate for all chart types).
681681
-----
682682
:param class 'matplotlib.axes.AxesSubplot' ax:
683-
:return numpy.ndarray dates_to_plot:
683+
:param numpy.ndarray dates_to_plot:
684684
:param int line:
685685
:param dict p_dict: plotting parameters
686-
:return ax:
687686
:param dict logger:
687+
:return ax:
688688
"""
689689

690690
LOG['Debug'].append(f"[{payload['props']['name']}] Formatting best fit line segments.")
@@ -922,7 +922,7 @@ def get_data(data_source, logger):
922922

923923

924924
# =============================================================================
925-
def hide_anomalies(data, props=True, logger=[]):
925+
def hide_anomalies(data: tuple=None, props: dict=None, logger: dict=None):
926926
"""Detect outliers in data and replace them with 'NaN'.
927927
928928
Credit: https://gist.github.com/wmlba/89bc2f4556b8ee397ca7a5017b497657#file-outlier_std-py

0 commit comments

Comments
 (0)