---------------------------------------------------------------------------------------------------------------local AUTH_TOKEN = 'xxxxxxxxxxxxxx' -- Fill in here your Mindergas authentication token---------------------------------------------------------------------------------------------------------------return { active = true, on = { timer = {'at 23:59'}, httpResponses = {'UploadToMindergas'} }, logging = { level = domoticz.LOG_DEBUG, marker = 'Mindergas' }, execute = function(domoticz, item) if item.isTimer then local GasUsageCounter = domoticz.devices('Gas (P1)').counter local TodaysDate = tostring(domoticz.time.rawDate) domoticz.log('The gas usage is ' .. GasUsageCounter, domoticz.LOG_INFO) domoticz.log('The date is ' .. TodaysDate, domoticz.LOG_INFO ) domoticz.openURL({ url = 'https://www.mindergas.nl/api/gas_meter_readings', method = 'POST', headers = { ['Content-Type'] = 'application/json', ['AUTH-TOKEN'] = AUTH_TOKEN }, callback = 'UploadToMindergas', postData = { ['date'] = TodaysDate, ['reading'] = GasUsageCounter }, }) elseif (item.isHTTPResponse) then if item.ok then -- self.statusCode >= 200 and self.statusCode <= 299 domoticz.log('Gas usage data is sucessfully upoaded to Mindergas.nl.', domoticz.LOG_INFO) else if (item.statusCode == 401) then domoticz.log('There was an authorisation problem with the Mindergas.nl database.', domoticz.LOG_ERROR) end if (item.statusCode == 422) then domoticz.log('There was an unprocessable enrty while trying to upload the gas usage data to Mindergas.nl', domoticz.LOG_ERROR) end domoticz.notify('Domoticz error', 'An error occured while trying to upload the gas usage data to Mindergas.nl', PRIORITY_NORMAL) end end end}