saal 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62d7f9b51083356448d50bcb5ad66c729d84a38e152f85470ca4fa5f9f5fed15
4
- data.tar.gz: 73f51e4736d14ee249531535577a8ff0568e0c19fb3115a4cf76bb0801d8e504
3
+ metadata.gz: a8e07d635b3ad4c944de3ccbe81096f826754aa457b9ebf06854f01a760d715d
4
+ data.tar.gz: 766a7168fa122a72b388b6547b1f6b9531cd4afd5bc1df9df52673b9fd8291ce
5
5
  SHA512:
6
- metadata.gz: 349eed054b1fd37de656840840b92e1be279e77fe677b92cc47864fe96079f88e6dc784e608bf5a7843b08cc0025b1f141d1bf88be1cef553e18f104cc0c3d74
7
- data.tar.gz: e07a22761c8f4f6c01d631abb29b01c63d6888c449fd67762e558ddd7693cd1bdfdf5b8bd7cdc35575006c6cb2fc9cbef49329bf08b754d5101d5dfc20d3421d
6
+ metadata.gz: 1ada5f05af261f043ef3e871c21d61b3f1924b4b99d8059233f1202a8594c30ea9af425e3f62d75050ee2f6c8bc15782c1535e4fc4696c277d7619c0569e40dc
7
+ data.tar.gz: 39ece8cad43590608d9410d7ffdcab1449e1fcc309f123343ffa6872dd84b820a59635a0f3a1aaf5807d05e111394674aa1aa49d9dcc2589930477d5f3c10426
@@ -130,14 +130,15 @@ envoy = SAAL::Envoy::Inverters::new(
130
130
  :host => ARGV[0],
131
131
  :user => ARGV[1],
132
132
  :password => ARGV[2],
133
+ :types => ["w_now", "last_report_date", "w_max"],
133
134
  )
134
135
  envoy.set_all_inverters!
135
136
  inverters = envoy.create_sensors
136
- puts "Found #{envoy.inverters.size} inverters"
137
+ puts " Found #{envoy.inverters.size} inverters"
137
138
  envoy.inverters.each do |serial|
138
- puts "INVERTER: #{serial} \
139
- date:#{l(inverters,"inverter_#{serial}_last_report_date")} \
140
- lastWatts:#{l(inverters,"inverter_#{serial}_w_now")} \
141
- maxWatts:#{l(inverters,"inverter_#{serial}_w_max")} \
139
+ puts " INVERTER: #{serial} \
140
+ date:#{l(inverters,"inverters_#{serial}_last_report_date")} \
141
+ lastWatts:#{l(inverters,"inverters_#{serial}_w_now")} \
142
+ maxWatts:#{l(inverters,"inverters_#{serial}_w_max")} \
142
143
  "
143
144
  end
@@ -216,9 +216,10 @@ module SAAL
216
216
  DEFAULT_TIMEOUT = 2
217
217
  DEFAULT_CACHE_TIMEOUT = 50
218
218
  DEFAULT_SOURCES = []
219
- DEFAULT_TYPES = ["last_report_date", "watts_now", "watts_max"]
219
+ DEFAULT_TYPES = ["w_now"] # "last_report_date", "w_max"
220
220
  DEFAULT_USER = nil
221
221
  DEFAULT_PASSWORD = nil
222
+ DEFAULT_PREFIX = "inverters"
222
223
  attr_reader :inverters
223
224
 
224
225
  def initialize(defs, opts={})
@@ -232,6 +233,7 @@ module SAAL
232
233
  @inverters_list = {}
233
234
  @inverters = defs[:inverters] || defs['inverters'] || DEFAULT_SOURCES
234
235
  @types = defs[:types] || defs['types'] || DEFAULT_TYPES
236
+ @prefix = defs[:prefix] || defs['prefix'] || DEFAULT_PREFIX
235
237
  end
236
238
 
237
239
  def read_val(name)
@@ -254,7 +256,7 @@ module SAAL
254
256
  def create_sensors
255
257
  sensors = {}
256
258
  @inverters.product(@types).each do |source, type|
257
- key = "inverter_#{source}_#{type}"
259
+ key = "#{@prefix}_#{source}_#{type}"
258
260
  sensors[key] = InverterUnderlying.new(key, self)
259
261
  end
260
262
  sensors
@@ -268,12 +270,13 @@ module SAAL
268
270
  values = JSON.parse(response.body)
269
271
  inverters = {}
270
272
  values.each do |inverter|
273
+ serial = inverter["serialNumber"]
274
+ @inverters_list[serial] = true
271
275
  {"lastReportDate" => "last_report_date",
272
- "lastReportWatts" => "watts_now",
273
- "maxReportWatts" => "watts_max",
276
+ "lastReportWatts" => "w_now",
277
+ "maxReportWatts" => "w_max",
274
278
  }.each do |type, label|
275
- inverters["inverter_#{inverter["serialNumber"]}_#{label}"] = inverter[type]
276
- @inverters_list[inverter["serialNumber"]] = true
279
+ inverters["#{@prefix}_#{serial}_#{label}"] = inverter[type]
277
280
  end
278
281
  end
279
282
 
@@ -10,7 +10,7 @@ module SAAL
10
10
  DBCONF = CONFDIR+"database.yml"
11
11
  CHARTSCONF = CONFDIR+"charts.yml"
12
12
 
13
- VERSION = '0.3.1'
13
+ VERSION = '0.3.2'
14
14
  end
15
15
 
16
16
  require File.dirname(__FILE__)+'/dbstore.rb'
@@ -54,9 +54,15 @@ module SAAL
54
54
  return sensors.map do |name, underlying|
55
55
  Sensor.new(dbstore, name, underlying, defs, opts)
56
56
  end
57
+ elsif defs['envoy_inverters']
58
+ defs = defs['envoy_inverters'].merge('prefix' => name)
59
+ pe = SAAL::Envoy::Inverters::new(defs)
60
+ sensors = pe.create_sensors
61
+ return sensors.map do |name, underlying|
62
+ Sensor.new(dbstore, name, underlying, defs, opts)
63
+ end
57
64
  else
58
- p defs, name
59
- raise UnknownSensorType, "Couldn't figure out a valid sensor type for #{name}"
65
+ $stderror.puts "WARNING: Couldn't figure out a valid sensor type for #{name}"
60
66
  end
61
67
  end
62
68
  end
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.name = 'saal'
9
- s.version = '0.3.1'
10
- s.date = '2020-12-19'
9
+ s.version = '0.3.2'
10
+ s.date = '2020-12-25'
11
11
 
12
12
  s.summary = "Thin abstraction layer for interfacing and recording sensors (currently onewire) and actuators (currently dinrelay)"
13
13
  s.description = <<EOF
@@ -46,6 +46,7 @@ EOF
46
46
  bin/saal_chart
47
47
  bin/saal_daemon
48
48
  bin/saal_dump_database
49
+ bin/saal_envoy_generate_config
49
50
  bin/saal_envoy_read
50
51
  bin/saal_import_mysql
51
52
  bin/saal_readall
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Côrte-Real
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-19 00:00:00.000000000 Z
11
+ date: 2020-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ownet