lightwaverf 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/lightwaverf.rb +18 -3
  2. metadata +2 -2
@@ -793,6 +793,11 @@ class LightWaveRF
793
793
  # populate the dates
794
794
  event['date'] = start_dt
795
795
  # handle device entries without explicit on/off state
796
+
797
+ # has a PROBLEM with a calendar event set to turn lights to 50% say - automatically adds an off!
798
+ # fix this with something like
799
+ # if self.get_state event['state'] ! starts with F
800
+
796
801
  if event['type'] == 'device' and ( event['state'].nil? or ( event['state'] != 'on' and event['state'] != 'off' ))
797
802
  debug and ( p 'Duplicating event without explicit on/off state...' )
798
803
  # if not state was given, assume we meant 'on'
@@ -1013,6 +1018,17 @@ class LightWaveRF
1013
1018
  content.to_s
1014
1019
  end
1015
1020
 
1021
+ def self.get_json file
1022
+ json = { }
1023
+ content = self.get_contents file
1024
+ begin
1025
+ json = JSON.parse content
1026
+ rescue
1027
+ STDERR.puts 'cannot parse ' + file.to_s
1028
+ end
1029
+ json
1030
+ end
1031
+
1016
1032
  def build_web_page debug = nil
1017
1033
 
1018
1034
  rooms = self.class.get_rooms self.get_config
@@ -1085,9 +1101,8 @@ class LightWaveRF
1085
1101
  def summarise days = 7, debug = nil
1086
1102
  days = days.to_i
1087
1103
  data = [ ]
1088
- file = self.get_summary_file.gsub 'summary', 'daily'
1089
- json = self.class.get_contents file
1090
- daily = JSON.parse json
1104
+ file = self.get_summary_file.gsub 'summary', 'daily'
1105
+ daily = self.class.get_json file
1091
1106
  start_date = 0
1092
1107
  d = nil
1093
1108
  File.open( self.get_log_file, 'r' ).each_line do | line |
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightwaverf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-10-01 00:00:00.000000000 Z
14
+ date: 2013-10-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: htmlentities