Skip to content

Commit

Permalink
Added debugging feature. Reduced logging output in normal mode. Updat…
Browse files Browse the repository at this point in the history
…ed README
  • Loading branch information
mwittig committed Apr 13, 2015
1 parent 467ee74 commit 165c2ca
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ To be able to read the SV data records with pimatic-solarview, the TCP-Server op

You can load the plugin by editing your `config.json` to include the following in the `plugins` section. The properties
`host` and `port` denote the hostname (or IP address) and port of the SV TCP server. The property `interval` specifies
the time interval in seconds for updating the data set.
the time interval in seconds for updating the data set. For debugging purposes you may set property `debug` to true.
This will write additional debug messages to the pimatic log.

{
"plugin": "solarview"
Expand All @@ -36,7 +37,7 @@ Then you need to add a device in the `devices` section. The plugin offers three
* SolarViewInverterWithMPPTracker: This type of device is for PV systems with a MPP tracking system. It
additionally provides you with data on voltage and amperage for up to three DC strings.

As part of the device definition you need to provide the inverterId which is a digit `[0-9]` to identify the number of
As part of the device definition you need to provide the `inverterId` which is a digit `[0-9]` to identify the number of
the inverter attached to the SV logger (see example below). The digit `0`depicts the sum of all inverters attached to
the SV logger.

Expand Down Expand Up @@ -66,9 +67,9 @@ History

* 20150406, V0.0.1
* Initial Version

* 20150406, V0.0.2
* Removed some test code. Fixed typo

* 20150406, V0.0.3
* NPM issues. Removed npm-debug.log
* NPM issues. Removed npm-debug.log
* 20150413, V0.0.4
* Added debugging feature. Reduced logging output in normal mode. Updated README
2 changes: 1 addition & 1 deletion device-config-schema.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
title: "SolarView"
title: "pimatic-solarview device config schemas"
SolarViewInverterSimple: {
title: "SolarView Inverter Simplified View"
description: "Provides energy earnings and current power values. Use this for the sum if you more than one inverter"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"device-config-schema.coffee",
"LICENSE"
],
"version": "0.0.3",
"version": "0.0.4",
"homepage": "https://github.com/mwittig/pimatic-solarview",
"keywords": [
"pimatic",
Expand Down
4 changes: 4 additions & 0 deletions solarview-config-schema.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ module.exports = {
description: "Polling interval for data requests"
type: "number"
default: 10
debug:
description: "Debug mode. Writes debug message to the piamtic log"
type: "boolean"
default: false
}
18 changes: 10 additions & 8 deletions solarview.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ module.exports = (env) ->
class SolarViewInverterBaseDevice extends env.devices.Device
# Initialize device by reading entity definition from middleware
constructor: (@config, @plugin) ->
env.logger.debug("SolarViewInverterBaseDevice Initialization")
env.logger.debug("SolarViewInverterBaseDevice Initialization") if @debug
@host = plugin.config.host
@port = plugin.config.port
@id = config.id
@name = config.name
@interval = 1000 * (config.interval or plugin.config.interval)
@inverterId = config.inverterId
@debug = plugin.config.debug;
super()

# keep updating
Expand All @@ -68,12 +69,13 @@ module.exports = (env) ->
socket = net.createConnection port, host
socket.setNoDelay true

socket.on 'connect', () ->
env.logger.debug("Opened connection to #{host}:#{port}.")
socket.on 'connect', (() ->
env.logger.debug("Opened connection to #{host}:#{port}.") if @debug
socket.write "0" + inverterId + "*\r\n"
).bind(@)

socket.on 'data', ((data) ->
env.logger.debug("Received raw data: #{data}")
env.logger.debug("Received raw data: #{data}") if @debug

rawData = data.toString 'utf8'
values = rawData.split ","
Expand Down Expand Up @@ -133,7 +135,7 @@ module.exports = (env) ->

# Initialize device by reading entity definition from middleware
constructor: (@config, @plugin) ->
env.logger.debug("SolarViewInverterSimpleDevice Initialization")
env.logger.debug("SolarViewInverterSimpleDevice Initialization") if @debug

@on 'solarViewData', ((values) ->
@emit "energyToday", Number values[6]
Expand Down Expand Up @@ -201,12 +203,12 @@ module.exports = (env) ->

# Initialize device by reading entity definition from middleware
constructor: (@config, @plugin) ->
env.logger.debug("SolarViewInverterDevice Initialization")
env.logger.debug("SolarViewInverterDevice Initialization") if @debug

@on 'solarViewData', ((values) ->
@emit "gridVoltage", Number values[17]
@emit "gridAmperage", Number values[18]
@emit "inverterTemperature", Number values[19].replace /\}+$/g, ""
@emit "inverterTemperature", Number values[19].replace /}+$/g, ""
)
super(@config, @plugin)

Expand Down Expand Up @@ -299,7 +301,7 @@ module.exports = (env) ->

# Initialize device by reading entity definition from middleware
constructor: (@config, @plugin) ->
env.logger.debug("SolarViewInverterWithMPPTrackerDevice Initialization")
env.logger.debug("SolarViewInverterWithMPPTrackerDevice Initialization") if @debug

@on 'solarViewData', ((values) ->
@emit "dcVoltageStringA", Number values[11]
Expand Down

0 comments on commit 165c2ca

Please sign in to comment.