diff --git a/apps/hasensors/ChangeLog b/apps/hasensors/ChangeLog index 759f68777..2c904fc71 100644 --- a/apps/hasensors/ChangeLog +++ b/apps/hasensors/ChangeLog @@ -1 +1,2 @@ -0.01: New app! \ No newline at end of file +0.01: New app! +0.02: Customize code directly, remove config file diff --git a/apps/hasensors/custom.html b/apps/hasensors/custom.html index 805001701..1fd1bcc3c 100644 --- a/apps/hasensors/custom.html +++ b/apps/hasensors/custom.html @@ -39,14 +39,27 @@ your user profile.

- +

diff --git a/apps/hasensors/lib.js b/apps/hasensors/lib.js index 60cfb6da4..555e52dce 100644 --- a/apps/hasensors/lib.js +++ b/apps/hasensors/lib.js @@ -1,16 +1,13 @@ // split out into a separate file to keep bootcode short. -function s(key) { - return (require('Storage').readJSON('hasensors.settings.js', true) || {})[key]; -} - +// placeholders are replaced by custom.html before upload function post(sensor, data) { - const url = s('url') + '/api/states/sensor.' + s('id') + '_' + sensor; + const url = '{url}/api/states/sensor.{id}_' + sensor; Bangle.http(url, { method: 'POST', body: JSON.stringify(data), headers: { 'Content-Type': 'application/json', - Authorization: 'Bearer ' + s('token'), + Authorization: 'Bearer {token}', } }); } @@ -20,7 +17,7 @@ exports.sendBattery = function () { post('battery_level', { state: E.getBattery(), attributes: { - friendly_name: s('name') + " Battery Level", + friendly_name: "{name} Battery Level", unit_of_measurement: "%", device_class: "battery", state_class: "measurement", @@ -29,7 +26,7 @@ exports.sendBattery = function () { post('battery_state', { state: Bangle.isCharging() ? 'charging' : 'discharging', attributes: { - friendly_name: s('name') + " Battery State", + friendly_name: "{name} Battery State", } }); } \ No newline at end of file diff --git a/apps/hasensors/metadata.json b/apps/hasensors/metadata.json index 7713fadc7..106f11407 100644 --- a/apps/hasensors/metadata.json +++ b/apps/hasensors/metadata.json @@ -2,7 +2,7 @@ "id": "hasensors", "name": "Home Assistant Sensors", "shortName": "HA sensors", - "version": "0.01", + "version": "0.02", "description": "Send sensor values to Home Assistant using the Android Integration.", "icon": "ha.png", "type": "bootloader", @@ -14,8 +14,5 @@ "storage": [ {"name":"hasensors","url":"lib.js"}, {"name":"hasensors.boot.js","url":"boot.js"} - ], - "data": [ - {"name":"hasensors.settings.json"} ] }