Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 152 lines (126 sloc) 5.03 kb
d545344 a first working version of the state mapper
Elias Karakoulakis authored
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
c01aec0 major rehaul of the KNX Datapoint type system: now using bindata instead...
Elias Karakoulakis authored
25 GC::Profiler.enable
26 Thread.new {
61b6211 I think I'll default now...
Elias Karakoulakis authored
27 while(true) do
28 sleep(600)
29 GC.start
30 puts '--- GC Profiler report:'
31 puts GC::Profiler.report
32 end
c01aec0 major rehaul of the KNX Datapoint type system: now using bindata instead...
Elias Karakoulakis authored
33 }
34
d545344 a first working version of the state mapper
Elias Karakoulakis authored
35 $:.push(Dir.getwd)
36 $:.push(File.join(Dir.getwd, 'knx'))
37 $:.push(File.join(Dir.getwd, 'zwave'))
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
38 $:.push(File.join(Dir.getwd, 'devices'))
d545344 a first working version of the state mapper
Elias Karakoulakis authored
39
61b6211 I think I'll default now...
Elias Karakoulakis authored
40 require 'transceiver'
41 require 'zwave_transceiver'
42 require 'zwave_command_classes'
d545344 a first working version of the state mapper
Elias Karakoulakis authored
43
61b6211 I think I'll default now...
Elias Karakoulakis authored
44 require 'knx_transceiver'
45 require 'knx_tools'
46 require 'knx_value'
d545344 a first working version of the state mapper
Elias Karakoulakis authored
47
61b6211 I think I'll default now...
Elias Karakoulakis authored
48 require 'ansible_device'
c01aec0 major rehaul of the KNX Datapoint type system: now using bindata instead...
Elias Karakoulakis authored
49
61b6211 I think I'll default now...
Elias Karakoulakis authored
50 require 'config'
51 #
d545344 a first working version of the state mapper
Elias Karakoulakis authored
52
c01aec0 major rehaul of the KNX Datapoint type system: now using bindata instead...
Elias Karakoulakis authored
53 include Ansible
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
54 include Ansible::ZWave
55 include Ansible::KNX
c01aec0 major rehaul of the KNX Datapoint type system: now using bindata instead...
Elias Karakoulakis authored
56
61b6211 I think I'll default now...
Elias Karakoulakis authored
57 begin
58
59 ZWT = ZWave::ZWave_Transceiver.new(STOMP_URL, THRIFT_URL)
60 ZWT.manager.SendAllValues
61 sleep(2)
62
63 ZWSwitch = AnsibleValue[
64 :_nodeId => 2,
65 :_genre => OpenZWave::RemoteValueGenre::ValueGenre_Basic][0]
66 ZWDimmer = AnsibleValue[
67 :_nodeId => 5,
68 :_genre => OpenZWave::RemoteValueGenre::ValueGenre_User,
69 :_commandClassId => 38, #SWITCH_MULTILEVEL
70 :_valueIndex => 0][0]
71
72 ZWKouzina = AnsibleValue[
73 :_nodeId => 6,
74 :_genre => OpenZWave::RemoteValueGenre::ValueGenre_User]
75
76 #KNX = Ansible::KNX::KNX_Transceiver.new("ip:192.168.0.10")
77 KNX = KNX::KNX_Transceiver.new(KNX_URL)
78
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
79 # map my ACT HomePro Appliance module to KNX
80 SWITCH = Switch.new(
81 :master_control => ZWSwitch,
82 :switch => KNXValue.new("1.001", "1/0/20"),
83 :switch_status => KNXValue.new("1.001", "1/0/21")
7e5d6f7 sync with OZW r488 value notification new behaviour
Elias Karakoulakis authored
84 ) if ZWSwitch
61b6211 I think I'll default now...
Elias Karakoulakis authored
85
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
86 # map my ACT HomePro Lamp module to KNX
87 DIMMER = Dimmer.new(
88 :master_control => ZWDimmer,
89 :switch => KNXValue.new("1.001", "1/0/40"),
90 :switch_status => KNXValue.new("1.001", "1/0/41"),
91 :dimming => KNXValue.new('5.001', "1/0/42"),
92 :dimming_status => KNXValue.new('5.001', "1/0/43"),
93 :scene => KNXValue.new('18.001', "1/0/44")
94 )
61b6211 I think I'll default now...
Elias Karakoulakis authored
95
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
96 # map my garden lights to ZWave
97 GARDEN = Switch.new(
98 :master_control => KNXValue.new("1.001", "1/0/1"),
99 :switch => ZWSwitch
7e5d6f7 sync with OZW r488 value notification new behaviour
Elias Karakoulakis authored
100 ) if ZWSwitch
61b6211 I think I'll default now...
Elias Karakoulakis authored
101
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
102 KOUZINA1 = Switch.new(
103 :master_control => ZWKouzina[0],
104 :switch => KNXValue.new("1.001", "1/0/60"),
105 :switch_status => KNXValue.new("1.001", "1/0/61")
106 )
61b6211 I think I'll default now...
Elias Karakoulakis authored
107
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
108 KOUZINA2 = Switch.new(
109 :master_control => ZWKouzina[1],
110 :switch => KNXValue.new("1.001", "1/0/62"),
7e5d6f7 sync with OZW r488 value notification new behaviour
Elias Karakoulakis authored
111 #:switch => KNXValue.new("1.001", "5/0/2"), # fancy radar
aceb8c4 - HomeID set by OZW notification (was static config var)
Elias Karakoulakis authored
112 :switch_status => KNXValue.new("1.001", "1/0/63")
113 )
61b6211 I think I'll default now...
Elias Karakoulakis authored
114
115 rescue Exception => e
116 puts e.to_s+"\n\t"+e.backtrace.join("\n\t")
117 end
c01aec0 major rehaul of the KNX Datapoint type system: now using bindata instead...
Elias Karakoulakis authored
118 =begin
61b6211 I think I'll default now...
Elias Karakoulakis authored
119 knx1_0_20.add_callback(:onUpdate) { |sender, cb, args|
d545344 a first working version of the state mapper
Elias Karakoulakis authored
120 puts "KNX value 1/0/20 updated! args=#{args}"
34625ec improved API interoperability between KNX and OZW
Elias Karakoulakis authored
121 zwval = sender.current_value == 0 ? 0 : 1
122 Switch.set(zwval) # FIXME convert value domains
d545344 a first working version of the state mapper
Elias Karakoulakis authored
123 }
61b6211 I think I'll default now...
Elias Karakoulakis authored
124 Switch.add_callback(:onUpdate) { | sender, cb, args|
d545344 a first working version of the state mapper
Elias Karakoulakis authored
125 puts "ZWave Switch HAS CHANGED #{args}"
126 knxval = sender.current_value == 0 ? 0 : 1
127 KNX.send_apdu_raw(str2addr("1/0/21"), [0, 0x80 | knxval])
128 }
129
61b6211 I think I'll default now...
Elias Karakoulakis authored
130 Ansible::KNX::KNXValue.new('1.001', "1/0/40") ).add_callback(:onUpdate) { |sender, cb, args|
d545344 a first working version of the state mapper
Elias Karakoulakis authored
131 puts "KNX value 1/0/40 updated! args=#{args}"
34625ec improved API interoperability between KNX and OZW
Elias Karakoulakis authored
132 zwval = sender.current_value == 0 ? 0 : 99
133 Dimmer.set(zwval) # FIXME convert value domains
d545344 a first working version of the state mapper
Elias Karakoulakis authored
134 }
61b6211 I think I'll default now...
Elias Karakoulakis authored
135 Dimmer.add_callback(:onUpdate) { | sender, cb, args|
d545344 a first working version of the state mapper
Elias Karakoulakis authored
136 puts "ZWave DimerOnOff HAS CHANGED #{args}"
137 knxval = sender.current_value == 0 ? 0 : 1
138 KNX.send_apdu_raw(str2addr("1/0/41"), [0, 0x80 | knxval])
139 }
140
61b6211 I think I'll default now...
Elias Karakoulakis authored
141 Ansible::KNX::KNXValue.new('5.001', "1/0/42") ).add_callback(:onUpdate) { |sender, cb, args|
d545344 a first working version of the state mapper
Elias Karakoulakis authored
142 puts "KNX value 1/0/42 updated! args=#{args}"
143 zwval = sender.current_value * 99 / 255
144 DimmerAbsolute.set(zwval.round) # FIXME convert value domains
145 }
61b6211 I think I'll default now...
Elias Karakoulakis authored
146 DimmerAbsolute.add_callback(:onUpdate) { | sender, cb, args|
d545344 a first working version of the state mapper
Elias Karakoulakis authored
147 puts "ZWave DimmerAbsolute HAS CHANGED #{args}"
148 knxval = sender.current_value * 255 / 99
149 KNX.send_apdu_raw(str2addr("1/0/43"), [0, 0x80, knxval.round]) ## NOTICE apdu
150 }
c06716a eib tests: use local pipe instead of socket
Elias Karakoulakis authored
151 =end
Something went wrong with that request. Please try again.