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,100 @@
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
+ module Ansible
26
+
27
+ module KNX
28
+
29
+ #
30
+ # DPT13: 4-byte signed value
31
+ #
32
+ module DPT13
33
+
34
+ class DPT13_Frame < DPTFrame
35
+ int32 :data, {
36
+ :display_name => "32-bit signed value",
37
+ :range => -2**31..2**31-1
38
+ }
39
+ end
40
+
41
+ # DPT13 base type info
42
+ Basetype = {
43
+ :bitlength => 32,
44
+ :valuetype => :basic,
45
+ :desc => "4-byte signed value"
46
+ }
47
+
48
+ # DPT13 subtypes
49
+ Subtypes = {
50
+ # 13.001 counter pulses (signed)
51
+ "001" => {
52
+ :name => "DPT_Value_4_Count", :desc => "counter pulses (signed)",
53
+ :unit => "pulses"
54
+ },
55
+
56
+ # 13.010 active energy (Wh)
57
+ "010" => {
58
+ :name => "DPT_ActiveEnergy", :desc => "active energy (Wh)",
59
+ :unit => "Wh"
60
+ },
61
+
62
+ # 13.011 apparent energy (VAh)
63
+ "011" => {
64
+ :name => "DPT_ApparantEnergy", :desc => "apparent energy (VAh)",
65
+ :unit => "VAh"
66
+ },
67
+
68
+ # 13.012 reactive energy (VARh)
69
+ "012" => {
70
+ :name => "DPT_ReactiveEnergy", :desc => "reactive energy (VARh)",
71
+ :unit => "VARh"
72
+ },
73
+
74
+ # 13.013 active energy (KWh)
75
+ "013" => {
76
+ :name => "DPT_ActiveEnergy_kWh", :desc => "active energy (kWh)",
77
+ :unit => "kWh"
78
+ },
79
+
80
+ # 13.014 apparent energy (kVAh)
81
+ "014" => {
82
+ :name => "DPT_ApparantEnergy_kVAh", :desc => "apparent energy (kVAh)",
83
+ :unit => "VAh"
84
+ },
85
+
86
+ # 13.015 reactive energy (kVARh)
87
+ "015" => {
88
+ :name => "DPT_ReactiveEnergy_kVARh", :desc => "reactive energy (kVARh)",
89
+ :unit => "kVARh"
90
+ },
91
+
92
+ # 13.100 time lag(s)
93
+ "100" => {
94
+ :name => "DPT_LongDeltaTimeSec", :desc => "time lag(s)",
95
+ :unit => "s"
96
+ },
97
+ }
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,87 @@
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
+ module Ansible
26
+
27
+ module KNX
28
+
29
+ #
30
+ # DPT14.*: 4-byte floating point value
31
+ #
32
+ module DPT14
33
+
34
+ # special Bindata::Primitive class required
35
+ # for non-standard 32-bit floats used by DPT14
36
+ class DPT14_Float < BinData::Primitive
37
+ endian :big
38
+ #
39
+ bit1 :sign, :display_name => "Sign"
40
+ bit8 :exp, :display_name => "Exponent"
41
+ bit23 :mant, :display_name => "Mantissa"
42
+ #
43
+ def get
44
+ # puts "sign=#{sign} exp=#{exp} mant=#{mant}"
45
+ mantissa = (self.sign==1) ? ~(self.mant^8388607) : self.mant
46
+ return Math.ldexp(mantissa, self.exp)
47
+ end
48
+ #
49
+ #DPT9_Range = -671088.64..670760.96
50
+ #
51
+ def set(v)
52
+ #raise "Value (#{v}) out of range" unless DPT9_Range === v
53
+ mantissa, exponent = Math.frexp(v)
54
+ #puts "#{self}.set(#{v}) with initial mantissa=#{mantissa}, exponent=#{exponent}"
55
+ # find the minimum exponent that will upsize the normalized mantissa (0,5 to 1 range)
56
+ # in order to fit in 11 bits (-2048..2047)
57
+ max_mantissa = 0
58
+ minimum_exp = exponent.downto(-127).find{ | e |
59
+ max_mantissa = Math.ldexp(100*mantissa, e).to_i
60
+ max_mantissa.between?(-8388608, 8388607)
61
+ }
62
+ self.sign = (mantissa < 0) ? 1 : 0
63
+ self.mant = (mantissa < 0) ? ~(max_mantissa^8388607) : max_mantissa
64
+ self.exp = exponent - minimum_exp
65
+ end # set
66
+ end
67
+
68
+ # Bitstruct to parse a DPT9 frame.
69
+ # Always 8-bit aligned.
70
+ class DPT14_Frame < BinData::Record
71
+ dpt14_float :data
72
+ end
73
+
74
+ # DPT14 base type info
75
+ Basetype = {
76
+ :bitlength => 32,
77
+ :valuetype => :basic,
78
+ :desc => "32-bit floating point value"
79
+ }
80
+
81
+ # DPT14 subtypes info
82
+ Subtypes = {
83
+ # TODO: so fucking many of them!
84
+ }
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,72 @@
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
+ module Ansible
26
+
27
+ module KNX
28
+
29
+ #
30
+ # DPT15.*: Access data
31
+ #
32
+ module DPT15
33
+
34
+ # Bitstruct to parse a DPT4 frame.
35
+ # Always 8-bit aligned.
36
+ class DPT15_Frame < DPTFrame
37
+ bit4 :d6, :display_name => "D6"
38
+ bit4 :d5, :display_name => "D5"
39
+ #
40
+ bit4 :d4, :display_name => "D4"
41
+ bit4 :d3, :display_name => "D3"
42
+ #
43
+ bit4 :d2, :display_name => "D2"
44
+ bit4 :d1, :display_name => "D1"
45
+ #
46
+ bit1 :e
47
+ bit1 :p
48
+ bit1 :d
49
+ bit1 :c
50
+ bit4 :idx
51
+ end
52
+
53
+ # DPT15 base type info
54
+ Basetype = {
55
+ :bitlength => 32,
56
+ :valuetype => :basic,
57
+ :desc => "4-byte access control data"
58
+ }
59
+
60
+ # DPT8 subtypes info
61
+ Subtypes = {
62
+ "000" => {
63
+ :name => "DPT_Access_Data"
64
+ }
65
+ }
66
+
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
@@ -0,0 +1,67 @@
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
+ module Ansible
26
+
27
+ module KNX
28
+
29
+ #
30
+ # DPT16: ASCII string
31
+ #
32
+ module DPT16
33
+
34
+ # Bitstruct to parse a DPT16 frame.
35
+ # Always 8-bit aligned.
36
+ class DPT16_Frame < DPTFrame
37
+ string :data, :length => 14
38
+ end
39
+
40
+ # DPT16 basetype info
41
+ Basetype = {
42
+ :bitlength => 14*8,
43
+ :valuetype => :basic,
44
+ :desc => "14-character string"
45
+ }
46
+
47
+ # DPT9 subtypes
48
+ Subtypes = {
49
+ # 16.000 ASCII string
50
+ "000" => { :use => "G",
51
+ :name => "DPT_String_ASCII", :desc => "ASCII string",
52
+ :force_encoding => "US-ASCII"
53
+ },
54
+
55
+ # 16.001 ISO-8859-1 string
56
+ "001" => { :use => "G",
57
+ :name => "DPT_String_8859_1", :desc => "ISO-8859-1 string",
58
+ :force_encoding => "ISO-8859-1"
59
+ },
60
+ }
61
+
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
@@ -0,0 +1,65 @@
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
+ require 'bindata'
26
+
27
+ module Ansible
28
+
29
+ module KNX
30
+
31
+ #
32
+ # DPT17: Scene number
33
+ #
34
+ module DPT17
35
+
36
+ # Bitstruct to parse a DPT17 frame.
37
+ # Always 8-bit aligned.
38
+ class DPT17_Frame < DPTFrame
39
+ bit2 :pad
40
+ bit6 :data, {
41
+ :display_name => "Scene number"
42
+ }
43
+ end
44
+
45
+ # DPT16 basetype info
46
+ Basetype = {
47
+ :bitlength => 8,
48
+ :valuetype => :basic,
49
+ :desc => "scene number"
50
+ }
51
+
52
+ # DPT9 subtypes
53
+ Subtypes = {
54
+ # 17.001 Scene number
55
+ "001" => { :use => "G",
56
+ :name => "DPT_SceneNumber", :desc => "Scene Number",
57
+ },
58
+ }
59
+
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+
@@ -0,0 +1,66 @@
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
+ module Ansible
26
+
27
+ module KNX
28
+
29
+ #
30
+ # DPT18: 8-bit Scene Control
31
+ #
32
+ module DPT18
33
+
34
+ class DPT18_Frame < DPTFrame
35
+ bit1 :exec_learn, {
36
+ :display_name => "Execute=0, Learn = 1"
37
+ }
38
+ bit1 :pad, {
39
+ :display_name => "Reserved bit"
40
+ }
41
+ bit6 :data, {
42
+ :display_name => "Scene number"
43
+ }
44
+ end
45
+
46
+ # DPT18 basetype info
47
+ Basetype = {
48
+ :bitlength => 8,
49
+ :valuetype => :composite,
50
+ :desc => "8-bit Scene Activate/Learn + number"
51
+ }
52
+
53
+ # DPT9 subtypes
54
+ Subtypes = {
55
+ # 9.001 temperature (oC)
56
+ "001" => {
57
+ :name => "DPT_SceneControl", :desc => "scene control"
58
+ },
59
+ }
60
+
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+