-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.py
More file actions
141 lines (114 loc) · 5.07 KB
/
install.py
File metadata and controls
141 lines (114 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#
# Copyright (c) 2023 - 2025 Rich Bell <bellrichm@gmail.com>
#
# See the file LICENSE.txt for your full rights.
#
""" Installer for notify extension. """
from io import StringIO
import configobj
from weecfg.extension import ExtensionInstaller
VERSION = '0.3.0'
EXTENSION_CONFIG = """
[Notify]
# Whether the service is enabled or not.
# Valid values: True or False
# Default is True.
enable = False
# The name of the notification provider.
# There must be a matching section within '[Notify]'.
# The default is Pushover.
notifier = Pushover
# Configuration data for the notification provider.
# The value of this section name must match the value of the 'notifier =' option.
[[Pushover]]
# The extension (service) to use.
extension = user.pushover.Pushover
# The number of seconds to wait for the notification to be sent and processed.
# Default is None
notification_timeout = None
# Controls if notifications are sent.
# Valid values: True or False
# Default is True.
send = True
# Controls if notifications are written to the log.
# Valid values: True or False
# Default is True.
log = True
# The server to send the pushover request to.
# Default is api.pushover.net:443.
server = api.pushover.net:443
# The endpoint/API to use.
# Default is /1/messages.json.
api = /1/messages.json
# The API token that is returned when registering the application
app_token = REPLACE_ME
# The user key.
user_key = REPLACE_ME
# Pushover returns a status code in the range of 400 to 499 when the http request is bad.
# In this case, WeeWX-Pushover will stop sending requests.
# (On the assumption that all future requests will have the same error.)
# An error will be logged every 'client_error_log_frequency' seconds.
# The default is 3600 seconds.
client_error_log_frequency = 3600
# Pushover returns a status code in the range of 500 to 599 when something went wrong on the server.
# In this case WeeWX-Pushover will wait 'server_error_wait_period' before resuming sending requests.
# (On the assumption that the server needs some time to be fixed.)
# The default is 3600 seconds.
server_error_wait_period = 3600
# Whether to monitor the loop or archive data.
# With two sections [[loop]] and [[archive]], both loop and archive data can be monitored.
[['loop' or 'archive']]
# Each subsection is the name of WeeWX observation being monitored.
# These can be any value, but must be unique.
# For example, aqi_100, aqi_150, outTemp
[[[REPLACE_ME]]]
# The WeeWX name.
# Defaults to the section name.
# If the section name is not a WeeWX name, this must be set.
# weewx_name = REPLACE_ME
# A more human readable 'name' for this observation.
# Default value is 'empty'/no value.
# label =
# The type of noitifcation.
# Specify one or more.
[[[[ 'min' or 'max' or 'equal' or 'missing']]]]
# The value to monitor.
# A notification is sent when:
# the section is 'min' and the observation is less than 'value
# the section is 'max' and the observation is greater than 'value
# the section is 'equal' and the observation is not equal to 'value
# Does not need to be set when the section is 'missing'.
# The value is an integer.
value = REPLACE_ME
# The number of times the threshold needs to be reached before sending a notification.
# The default is 10.
count = 10
# The time in seconds to wait before sending another notification.
# This is used to throttle the number of notifications.
# The default is 3600 seconds.
wait_time = 3600
# Whether to send a notification when the value is back within the threshold.
# Valid values: True or False
# Default is True.
return_notification = True
"""
def loader():
""" Load and return the extension installer. """
return NotifyInstaller()
class NotifyInstaller(ExtensionInstaller):
""" The extension installer. """
def __init__(self):
install_dict = {
'version': VERSION,
'name': 'Notify',
'description': 'Monitor observation values and send alerts.',
'author': "Rich Bell",
'author_email': "bellrichm@gmail.com",
'files': [
('bin/user', ['bin/user/notify.py']),
('bin/user', ['bin/user/pushover.py']),
]
}
install_dict['config'] = configobj.ConfigObj(StringIO(EXTENSION_CONFIG))
install_dict['restful_services'] = 'user.notify.Notify'
super().__init__(install_dict)