Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Bugfix: json.loads(headers) from config. Add brewstat.us webhook exam…
Browse files Browse the repository at this point in the history
…ple.
  • Loading branch information
myoung34 committed Feb 28, 2020
1 parent 98a662c commit 7a7a910
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ $ cat <<EOF >config.ini
[general]
sleep_interval = 1
# Generic application/json example
[webhook]
url = http://www.foo.com
headers = {"Content-Type": "application/json"}
payload_template = {"color": "{{ color }}", "gravity": {{ gravity }}, "temp": {{ temp }}, "timestamp": "{{ timestamp }}"}
method = GET
method = POST
# Brewstat.us example
[webhook]
url = https://www.brewstat.us/tilt/0yjRbGd2/log
headers = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"}
payload_template = {"Color": "{{ color }}", "SG": {{ gravity }}, "Temp": {{ temp }}, "Timepoint": "{{ timestamp }}"}
method = POST
[influxdb]
url = influxdb.corp.com
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Tilty"
version = "0.3.0"
version = "0.3.1"
description = "A pluggable system to receive and transmit bluetooth events from the Tilt Hydrometer"
authors = ["Marcus Young <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
long_description=long_description,
long_description_content_type="text/markdown",
py_modules=['tilty', 'blescan'],
version='0.3.0',
version='0.3.1',
packages=find_packages(exclude=['tests*']),
install_requires=[
'Click',
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __getitem__(self, key):
if self.section == 'webhook':
return {
'url': 'http://www.google.com',
'headers': {'Content-Type': 'application/json'},
'headers': '{"Content-Type": "application/json"}',
'payload_template': '{"color": "{{ color }}", "gravity": {{ gravity }}, "temp": {{ temp }}, "timestamp": "{{ timestamp }}"}', # noqa
'method': 'GET'
}
Expand Down
2 changes: 1 addition & 1 deletion tilty/tilty.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def emit(config, tilt_data):
_template = Template(config['webhook']['payload_template'])
_config = {
'url': config['webhook']['url'],
'headers': config['webhook'].get('headers'),
'headers': json.loads(config['webhook'].get('headers')),
'method': config['webhook']['method'],
'payload': json.loads(_template.render(
color=tilt_data['color'],
Expand Down

0 comments on commit 7a7a910

Please sign in to comment.