diff --git a/README.md b/README.md index 6e659c9..4f7ad6a 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,19 @@ $ cat <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 diff --git a/pyproject.toml b/pyproject.toml index ce35669..535ca64 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 <3vilpenguin@gmail.com>"] license = "MIT" diff --git a/setup.py b/setup.py index 081f6ae..10cddaf 100644 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tests/mock_config_parser.py b/tests/mock_config_parser.py index 608226c..7166d1c 100644 --- a/tests/mock_config_parser.py +++ b/tests/mock_config_parser.py @@ -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' } diff --git a/tilty/tilty.py b/tilty/tilty.py index f228b1e..2cf90fe 100644 --- a/tilty/tilty.py +++ b/tilty/tilty.py @@ -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'],