ansible4ozw 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/lib/ansible.rb +47 -0
  2. data/lib/ansible/ansible_callback.rb +142 -0
  3. data/lib/ansible/ansible_device.rb +68 -0
  4. data/lib/ansible/ansible_value.rb +179 -0
  5. data/lib/ansible/config.rb +92 -0
  6. data/lib/ansible/devices/ansible_dimmer.rb +80 -0
  7. data/lib/ansible/devices/ansible_switch.rb +66 -0
  8. data/lib/ansible/knx/EIBConnection.rb +2371 -0
  9. data/lib/ansible/knx/dpt/canonical_1bit.rb +54 -0
  10. data/lib/ansible/knx/dpt/dpt1.rb +224 -0
  11. data/lib/ansible/knx/dpt/dpt10.rb +85 -0
  12. data/lib/ansible/knx/dpt/dpt11.rb +72 -0
  13. data/lib/ansible/knx/dpt/dpt12.rb +61 -0
  14. data/lib/ansible/knx/dpt/dpt13.rb +100 -0
  15. data/lib/ansible/knx/dpt/dpt14.rb +87 -0
  16. data/lib/ansible/knx/dpt/dpt15.rb +72 -0
  17. data/lib/ansible/knx/dpt/dpt16.rb +67 -0
  18. data/lib/ansible/knx/dpt/dpt17.rb +65 -0
  19. data/lib/ansible/knx/dpt/dpt18.rb +66 -0
  20. data/lib/ansible/knx/dpt/dpt19.rb +100 -0
  21. data/lib/ansible/knx/dpt/dpt2.rb +156 -0
  22. data/lib/ansible/knx/dpt/dpt3.rb +104 -0
  23. data/lib/ansible/knx/dpt/dpt4.rb +75 -0
  24. data/lib/ansible/knx/dpt/dpt5.rb +124 -0
  25. data/lib/ansible/knx/dpt/dpt6.rb +73 -0
  26. data/lib/ansible/knx/dpt/dpt7.rb +146 -0
  27. data/lib/ansible/knx/dpt/dpt8.rb +118 -0
  28. data/lib/ansible/knx/dpt/dpt9.rb +204 -0
  29. data/lib/ansible/knx/dpt/tests/test_dpt10.rb +45 -0
  30. data/lib/ansible/knx/dpt/tests/test_dpt9.rb +60 -0
  31. data/lib/ansible/knx/hexdump.rb +113 -0
  32. data/lib/ansible/knx/knx_dpt.rb +58 -0
  33. data/lib/ansible/knx/knx_dpt_scalar.rb +62 -0
  34. data/lib/ansible/knx/knx_eistypes.rb +76 -0
  35. data/lib/ansible/knx/knx_protocol.rb +99 -0
  36. data/lib/ansible/knx/knx_scene.rb +48 -0
  37. data/lib/ansible/knx/knx_tools.rb +76 -0
  38. data/lib/ansible/knx/knx_transceiver.rb +237 -0
  39. data/lib/ansible/knx/knx_value.rb +327 -0
  40. data/lib/ansible/openzwave/ozw_constants.rb +11 -0
  41. data/lib/ansible/openzwave/ozw_headers.rb +80 -0
  42. data/lib/ansible/openzwave/ozw_remote_manager.rb +7615 -0
  43. data/lib/ansible/openzwave/ozw_types.rb +406 -0
  44. data/lib/ansible/orbiter_proxy.rb +12 -0
  45. data/lib/ansible/transceiver.rb +63 -0
  46. data/lib/ansible/zwave/types/valuetype_bool.rb +74 -0
  47. data/lib/ansible/zwave/types/valuetype_button.rb +63 -0
  48. data/lib/ansible/zwave/types/valuetype_byte.rb +78 -0
  49. data/lib/ansible/zwave/types/valuetype_decimal.rb +64 -0
  50. data/lib/ansible/zwave/types/valuetype_int.rb +63 -0
  51. data/lib/ansible/zwave/types/valuetype_list.rb +64 -0
  52. data/lib/ansible/zwave/types/valuetype_short.rb +63 -0
  53. data/lib/ansible/zwave/types/valuetype_string.rb +61 -0
  54. data/lib/ansible/zwave/zwave_command_classes.rb +113 -0
  55. data/lib/ansible/zwave/zwave_node.rb +5 -0
  56. data/lib/ansible/zwave/zwave_protocol.rb +52 -0
  57. data/lib/ansible/zwave/zwave_transceiver.rb +435 -0
  58. data/lib/ansible/zwave/zwave_value.rb +193 -0
  59. metadata +108 -0
@@ -0,0 +1,73 @@
1
+ =begin
2
+ Project Ansible - An extensible home automation scripting framework
3
+ ----------------------------------------------------
4
+ Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
5
+
6
+ SOFTWARE NOTICE AND LICENSE
7
+
8
+ Project Ansible is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU Lesser General Public License as published
10
+ by the Free Software Foundation, either version 3 of the License,
11
+ or (at your option) any later version.
12
+
13
+ Project Ansible is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public License
19
+ along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ for more information on the LGPL, see:
22
+ http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
23
+ =end
24
+
25
+ #
26
+ # DPT6.*: 8-bit signed value
27
+ #
28
+
29
+ module Ansible
30
+
31
+ module KNX
32
+
33
+ module DPT6
34
+
35
+ # Bitstruct to parse a DPT6 frame.
36
+ # Always 8-bit aligned.
37
+ class DPT6_Frame < DPTFrame
38
+ int8 :data, :display_name => "Signed value -128..127"
39
+ end
40
+
41
+ # DPT Basetype info
42
+ Basetype = {
43
+ :bitlength => 8,
44
+ :valuetype => :basic,
45
+ :desc => "8-bit signed value",
46
+ :range => -128..127
47
+ }
48
+ # DPT subtypes info
49
+ Subtypes = {
50
+ # 6.001 percentage (-128%..127%)
51
+ "001" => {
52
+ :name => "DPT_Switch", :desc => "percent",
53
+ :unit => "%",
54
+ },
55
+
56
+ # 6.002 counter pulses (-128..127)
57
+ "002" => {
58
+ :name => "DPT_Bool", :desc => "counter pulses",
59
+ :unit => "pulses"
60
+ },
61
+ #
62
+ }
63
+
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ =begin
70
+ puts KNX_DPT6.bit_length
71
+ puts KNX_DPT6.new([0x32].pack('c')).inspect # 50
72
+ puts KNX_DPT6.new([0xce].pack('c')).inspect # -50
73
+ =end
@@ -0,0 +1,146 @@
1
+ =begin
2
+ Project Ansible - An extensible home automation scripting framework
3
+ ----------------------------------------------------
4
+ Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
5
+
6
+ SOFTWARE NOTICE AND LICENSE
7
+
8
+ Project Ansible is free software: you can redistribute it and/or modify
9
+ it under the terms of the GNU Lesser General Public License as published
10
+ by the Free Software Foundation, either version 3 of the License,
11
+ or (at your option) any later version.
12
+
13
+ Project Ansible is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU Lesser General Public License for more details.
17
+
18
+ You should have received a copy of the GNU Lesser General Public License
19
+ along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+ for more information on the LGPL, see:
22
+ http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
23
+ =end
24
+
25
+ #
26
+ # DPT7.*: 2-byte unsigned value
27
+ #
28
+
29
+ module Ansible
30
+
31
+ module KNX
32
+
33
+ module DPT7
34
+
35
+ # Bitstruct to parse a DPT7 frame.
36
+ # Always 8-bit aligned.
37
+ class DPT7_Frame < DPTFrame
38
+ uint16 :data, :display_name => "Value"
39
+ end
40
+
41
+ # DPT basetype info
42
+ Basetype = {
43
+ :bitlength => 16,
44
+ :valuetype => :basic,
45
+ :desc => "16-bit unsigned value"
46
+ }
47
+
48
+ # DPT subtypes info
49
+ Subtypes = {
50
+ # 7.001 pulses
51
+ "001" => { :use => "G",
52
+ :name => "DPT_Value_2_Ucount",
53
+ :desc => "pulses",
54
+ :unit => "pulses"
55
+ },
56
+
57
+ # 7.002 time(ms)
58
+ "002" => { :use => "G",
59
+ :name => "DPT_TimePeriodMsec",
60
+ :desc => "time (ms)",
61
+ :unit => "milliseconds"
62
+ },
63
+
64
+ # 7.003 time (10ms)
65
+ "003" => { :use => "G",
66
+ :name => "DPT_TimePeriod10Msec",
67
+ :desc => "time (10ms)",
68
+ :unit => "centiseconds"
69
+ },
70
+
71
+ # 7.004 time (100ms)
72
+ "004" => { :use => "G",
73
+ :name => "DPT_TimePeriod100Msec",
74
+ :desc => "time (100ms)",
75
+ :unit => "deciseconds"
76
+ },
77
+
78
+ # 7.005 time (sec)
79
+ "005" => { :use => "G",
80
+ :name => "DPT_TimePeriodSec",
81
+ :desc => "time (s)",
82
+ :unit => "seconds"
83
+ },
84
+
85
+ # 7.006 time (min)
86
+ "006" => { :use => "G",
87
+ :name => "DPT_TimePeriodMin",
88
+ :desc => "time (min)",
89
+ :unit => "minutes"
90
+ },
91
+
92
+ # 7.007 time (hour)
93
+ "007" => { :use => "G",
94
+ :name => "DPT_TimePeriodHrs",
95
+ :desc => "time (hrs)",
96
+ :unit => "hours"
97
+ },
98
+
99
+ # 7.010 DPT_PropDataType
100
+ # not to be used in runtime communications!
101
+ "010" => { :use => "FB",
102
+ :name => "DPT_PropDataType",
103
+ :desc => "Identifier Interface Object Property data type "
104
+ },
105
+
106
+ # 7.011
107
+ "011" => { :use => "FB SAB",
108
+ :name => "DPT_Length_mm",
109
+ :desc => "Length in mm",
110
+ :unit => "mm"
111
+ },
112
+
113
+ # 7.012
114
+ "012" => { :use => "FB",
115
+ :name => "DPT_UEICurrentmA",
116
+ :desc => "bus power supply current (mA)",
117
+ :unit => "mA"
118
+ },
119
+
120
+ # 7.013
121
+ "013" => { :use => "FB",
122
+ :name => "DPT_Brightness",
123
+ :desc => "interior brightness",
124
+ :unit => "lux"
125
+ }
126
+ }
127
+
128
+ end
129
+
130
+ end
131
+
132
+ end
133
+
134
+
135
+ =begin
136
+ puts KNX_DPT2.bit_length
137
+ puts KNX_DPT2.new([0x00].pack('c')).inspect #
138
+ puts KNX_DPT2.new([0x01].pack('c')).inspect #
139
+ puts KNX_DPT2.new([0x02].pack('c')).inspect #
140
+ puts KNX_DPT2.new([0x03].pack('c')).inspect #
141
+
142
+ puts [0x02].pack('c').inspect
143
+
144
+ =begin
145
+
146
+ =end
@@ -0,0 +1,118 @@
1
+ # encoding: ISO-8859-1
2
+ =begin
3
+ Project Ansible - An extensible home automation scripting framework
4
+ ----------------------------------------------------
5
+ Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
6
+
7
+ SOFTWARE NOTICE AND LICENSE
8
+
9
+ Project Ansible is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU Lesser General Public License as published
11
+ by the Free Software Foundation, either version 3 of the License,
12
+ or (at your option) any later version.
13
+
14
+ Project Ansible is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General Public License
20
+ along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
21
+
22
+ for more information on the LGPL, see:
23
+ http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
24
+ =end
25
+
26
+ module Ansible
27
+
28
+ module KNX
29
+
30
+ #
31
+ # DPT8.*: 2-byte signed value
32
+ #
33
+ module DPT8
34
+
35
+ # Bitstruct to parse a DPT8 frame.
36
+ # Always 8-bit aligned.
37
+ class DPT8_Frame < DPTFrame
38
+ int16 :data, :display_name => "Value"
39
+ end
40
+
41
+ # DPT8 basetype info
42
+ Basetype = {
43
+ :bitlength => 16,
44
+ :valuetype => :basic,
45
+ :desc => "16-bit signed value"
46
+ }
47
+
48
+ # DPT8 subtypes info
49
+ Subtypes = {
50
+ # 8.001 pulses difference
51
+ "001" => {
52
+ :name => "DPT_Value_2_Count",
53
+ :desc => "pulses",
54
+ :unit => "pulses"
55
+ },
56
+
57
+ # 8.002 time lag (ms)
58
+ "002" => {
59
+ :name => "DPT_DeltaTimeMsec",
60
+ :desc => "time lag(ms)",
61
+ :unit => "milliseconds"
62
+ },
63
+
64
+ # 8.003 time lag (10ms)
65
+ "003" => {
66
+ :name => "DPT_DeltaTime10Msec",
67
+ :desc => "time lag(10ms)",
68
+ :unit => "centiseconds"
69
+ },
70
+
71
+ # 8.004 time lag (100ms)
72
+ "004" => {
73
+ :name => "DPT_DeltaTime100Msec",
74
+ :desc => "time lag(100ms)",
75
+ :unit => "deciseconds"
76
+ },
77
+
78
+ # 8.005 time lag (sec)
79
+ "005" => {
80
+ :name => "DPT_DeltaTimeSec",
81
+ :desc => "time lag(s)",
82
+ :unit => "seconds"
83
+ },
84
+
85
+ # 8.006 time lag (min)
86
+ "006" => {
87
+ :name => "DPT_DeltaTimeMin",
88
+ :desc => "time lag(min)",
89
+ :unit => "minutes"
90
+ },
91
+
92
+ # 8.007 time lag (hour)
93
+ "007" => {
94
+ :name => "DPT_DeltaTimeHrs",
95
+ :desc => "time lag(hrs)",
96
+ :unit => "hours"
97
+ },
98
+
99
+ # 8.010 percentage difference (%)
100
+ "010" => {
101
+ :name => "DPT_Percent_V16",
102
+ :desc => "percentage difference",
103
+ :unit => "%"
104
+ },
105
+
106
+ # 8.011 rotation angle (deg)
107
+ "011" => {
108
+ :name => "DPT_RotationAngle",
109
+ :desc => "angle(degrees)",
110
+ :unit => "°"
111
+ },
112
+ }
113
+
114
+ end
115
+
116
+ end
117
+
118
+ end
@@ -0,0 +1,204 @@
1
+ # encoding: ISO-8859-1
2
+ =begin
3
+ Project Ansible - An extensible home automation scripting framework
4
+ ----------------------------------------------------
5
+ Copyright (c) 2011 Elias Karakoulakis <elias.karakoulakis@gmail.com>
6
+
7
+ SOFTWARE NOTICE AND LICENSE
8
+
9
+ Project Ansible is free software: you can redistribute it and/or modify
10
+ it under the terms of the GNU Lesser General Public License as published
11
+ by the Free Software Foundation, either version 3 of the License,
12
+ or (at your option) any later version.
13
+
14
+ Project Ansible is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ GNU Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General Public License
20
+ along with Project Ansible. If not, see <http://www.gnu.org/licenses/>.
21
+
22
+ for more information on the LGPL, see:
23
+ http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
24
+ =end
25
+
26
+ module Ansible
27
+
28
+ module KNX
29
+
30
+ #
31
+ # DPT9.*: 2-byte floating point value
32
+ #
33
+ module DPT9
34
+
35
+ # special Bindata::Primitive class required
36
+ # for non-standard 16-bit floats used by DPT9
37
+ class DPT9_Float < BinData::Primitive
38
+ endian :big
39
+ #
40
+ bit1 :sign, :display_name => "Sign"
41
+ bit4 :exp, :display_name => "Exponent"
42
+ bit11 :mant, :display_name => "Mantissa"
43
+ #
44
+ def get
45
+ # puts "sign=#{sign} exp=#{exp} mant=#{mant}"
46
+ mantissa = (self.sign==1) ? ~(self.mant^2047) : self.mant
47
+ return Math.ldexp((0.01*mantissa), self.exp)
48
+ end
49
+ #
50
+ DPT9_Range = -671088.64..670760.96
51
+ #
52
+ def set(v)
53
+ raise "Value (#{v}) out of range" unless DPT9_Range === v
54
+ mantissa, exponent = Math.frexp(v)
55
+ #puts "#{self}.set(#{v}) with initial mantissa=#{mantissa}, exponent=#{exponent}"
56
+ # find the minimum exponent that will upsize the normalized mantissa (0,5 to 1 range)
57
+ # in order to fit in 11 bits (-2048..2047)
58
+ max_mantissa = 0
59
+ minimum_exp = exponent.downto(-15).find{ | e |
60
+ max_mantissa = Math.ldexp(100*mantissa, e).to_i
61
+ max_mantissa.between?(-2048, 2047)
62
+ }
63
+ self.sign = (mantissa < 0) ? 1 : 0
64
+ self.mant = (mantissa < 0) ? ~(max_mantissa^2047) : max_mantissa
65
+ self.exp = exponent - minimum_exp
66
+ end # set
67
+ end
68
+
69
+ # DPTFrame to parse a DPT9 frame.
70
+ # Always 8-bit aligned.
71
+ class DPT9_Frame < DPTFrame
72
+ dpt9_float :data
73
+ end
74
+
75
+ # DPT9 basetype info
76
+ Basetype = {
77
+ :bitlength => 16,
78
+ :valuetype => :basic,
79
+ :desc => "16-bit floating point value"
80
+ }
81
+
82
+ # DPT9 subtypes
83
+ Subtypes = {
84
+ # 9.001 temperature (oC)
85
+ "001" => {
86
+ :name => "DPT_Value_Temp", :desc => "temperature",
87
+ :unit => "°C", :range => -273..670760
88
+ },
89
+
90
+ # 9.002 temperature difference (oC)
91
+ "002" => {
92
+ :name => "DPT_Value_Tempd", :desc => "temperature difference",
93
+ :unit => "°C", :range => -670760..670760
94
+ },
95
+
96
+ # 9.003 kelvin/hour (K/h)
97
+ "003" => {
98
+ :name => "DPT_Value_Tempa", :desc => "kelvin/hour",
99
+ :unit => "°K/h", :range => -670760..670760
100
+ },
101
+
102
+ # 9.004 lux (Lux)
103
+ "004" => {
104
+ :name => "DPT_Value_Lux", :desc => "lux",
105
+ :unit => " lux", :range => 0..670760
106
+ },
107
+
108
+ # 9.005 speed (m/s)
109
+ "005" => {
110
+ :name => "DPT_Value_Wsp", :desc => "wind speed",
111
+ :unit => "m/s", :range => 0..670760
112
+ },
113
+
114
+ # 9.006 pressure (Pa)
115
+ "006" => {
116
+ :name => "DPT_Value_Pres", :desc => "pressure",
117
+ :unit => "Pa", :range => 0..670760
118
+ },
119
+
120
+ # 9.007 humidity (%)
121
+ "007" => {
122
+ :name => "DPT_Value_Humidity", :desc => "humidity",
123
+ :unit => "%", :range => 0..670760
124
+ },
125
+
126
+ # 9.008 parts/million (ppm)
127
+ "008" => {
128
+ :name => "DPT_Value_AirQuality", :desc => "air quality",
129
+ :unit => "ppm", :range => 0..670760
130
+ },
131
+
132
+ # 9.010 time (s)
133
+ "010" => {
134
+ :name => "DPT_Value_Time1", :desc => "time(sec)",
135
+ :unit => "s", :range => -670760..670760
136
+ },
137
+
138
+ # 9.011 time (ms)
139
+ "011" => {
140
+ :name => "DPT_Value_Time2", :desc => "time(msec)",
141
+ :unit => "ms", :range => -670760..670760
142
+ },
143
+
144
+ # 9.020 voltage (mV)
145
+ "020" => {
146
+ :name => "DPT_Value_Volt", :desc => "voltage",
147
+ :unit => "mV", :range => -670760..670760
148
+ },
149
+
150
+ # 9.021 current (mA)
151
+ "021" => {
152
+ :name => "DPT_Value_Curr", :desc => "current",
153
+ :unit => "mA", :range => -670760..670760
154
+ },
155
+
156
+ # 9.022 power density (W/m2)
157
+ "022" => {
158
+ :name => "DPT_PowerDensity", :desc => "power density",
159
+ :unit => "W/m²", :range => -670760..670760
160
+ },
161
+
162
+ # 9.023 kelvin/percent (K/%)
163
+ "023" => {
164
+ :name => "DPT_KelvinPerPercent", :desc => "Kelvin / %",
165
+ :unit => "K/%", :range => -670760..670760
166
+ },
167
+
168
+ # 9.024 power (kW)
169
+ "024" => {
170
+ :name => "DPT_Power", :desc => "power (kW)",
171
+ :unit => "kW", :range => -670760..670760
172
+ },
173
+
174
+ # 9.025 volume flow (l/h)
175
+ "025" => {
176
+ :name => "DPT_Value_Volume_Flow", :desc => "volume flow",
177
+ :unit => "l/h", :range => -670760..670760
178
+ },
179
+
180
+ # 9.026 rain amount (l/m2)
181
+ "026" => {
182
+ :name => "DPT_Rain_Amount", :desc => "rain amount",
183
+ :unit => "l/m²", :range => -670760..670760
184
+ },
185
+
186
+ # 9.027 temperature (Fahrenheit)
187
+ "027" => {
188
+ :name => "DPT_Value_Temp_F", :desc => "temperature (F)",
189
+ :unit => "°F", :range => -459.6..670760
190
+ },
191
+
192
+ # 9.028 wind speed (km/h)
193
+ "028" => {
194
+ :name => "DPT_Value_Wsp_kmh", :desc => "wind speed (km/h)",
195
+ :unit => "km/h", :range => 0..670760
196
+ },
197
+ }
198
+
199
+ end
200
+
201
+ end
202
+
203
+ end
204
+