Commit ef8a9e06 authored by Peter Müller's avatar Peter Müller

Pause polling while setup of all devices related to a PCF8574IC device is not done, v1.0.6

parent d3ba617e
Pipeline #231 passed with stages
in 29 seconds
## 1.0.6 2018-12-20
- Pause polling while setup of all devices related to a PCF8574IC device is not done
## v1.0.5 2018-12-14
- Log input/output init errors
......
......@@ -26,7 +26,7 @@
"pcf8574.coffee",
"README.md"
],
"version": "1.0.5",
"version": "1.0.6",
"homepage": "https://git.cryhost.de/crycode/pimatic-pcf8574",
"license": "GPL-2.0",
"repository": {
......
......@@ -78,6 +78,8 @@ module.exports = (env) ->
# Promise chain for setup
@setupChain = Promise.resolve()
@setupChainDone = false
# parse and check the address
@address = parseInt @config.address
assert @address >= 0 and @address <= 255, 'The address must be between 0x00 (0) and 0xFF (255)'
......@@ -104,6 +106,9 @@ module.exports = (env) ->
assert typeof @config.pollingInterval is 'number'
env.logger.debug "#{@id} polling for input changes every #{@config.pollingInterval} ms"
@pollingInterval = setInterval ( =>
unless @setupChainDone
env.logger.debug "#{@id} Polling paused while setup of this device is not done"
return
@ic.doPoll()
.catch( (err) =>
env.logger.warn "#{@id} Error while polling:", err
......@@ -116,6 +121,12 @@ module.exports = (env) ->
if @framework.deviceManager.deviceClasses[device].configDef.properties[deviceEnum]?.enum?
@framework.deviceManager.deviceClasses[device].configDef.properties[deviceEnum].enum = _.union @framework.deviceManager.deviceClasses[device].configDef.properties[deviceEnum].enum, [@id]
# add final promise to setup chain to keep track when setup is done
process.nextTick =>
@setupChain = @setupChain.finally =>
env.logger.debug "#{@id} setup done"
@setupChainDone = true
destroy: ->
env.logger.debug "destroy #{@id}"
super()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment