ansible4ozw 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ansible.rb +47 -0
- data/lib/ansible/ansible_callback.rb +142 -0
- data/lib/ansible/ansible_device.rb +68 -0
- data/lib/ansible/ansible_value.rb +179 -0
- data/lib/ansible/config.rb +92 -0
- data/lib/ansible/devices/ansible_dimmer.rb +80 -0
- data/lib/ansible/devices/ansible_switch.rb +66 -0
- data/lib/ansible/knx/EIBConnection.rb +2371 -0
- data/lib/ansible/knx/dpt/canonical_1bit.rb +54 -0
- data/lib/ansible/knx/dpt/dpt1.rb +224 -0
- data/lib/ansible/knx/dpt/dpt10.rb +85 -0
- data/lib/ansible/knx/dpt/dpt11.rb +72 -0
- data/lib/ansible/knx/dpt/dpt12.rb +61 -0
- data/lib/ansible/knx/dpt/dpt13.rb +100 -0
- data/lib/ansible/knx/dpt/dpt14.rb +87 -0
- data/lib/ansible/knx/dpt/dpt15.rb +72 -0
- data/lib/ansible/knx/dpt/dpt16.rb +67 -0
- data/lib/ansible/knx/dpt/dpt17.rb +65 -0
- data/lib/ansible/knx/dpt/dpt18.rb +66 -0
- data/lib/ansible/knx/dpt/dpt19.rb +100 -0
- data/lib/ansible/knx/dpt/dpt2.rb +156 -0
- data/lib/ansible/knx/dpt/dpt3.rb +104 -0
- data/lib/ansible/knx/dpt/dpt4.rb +75 -0
- data/lib/ansible/knx/dpt/dpt5.rb +124 -0
- data/lib/ansible/knx/dpt/dpt6.rb +73 -0
- data/lib/ansible/knx/dpt/dpt7.rb +146 -0
- data/lib/ansible/knx/dpt/dpt8.rb +118 -0
- data/lib/ansible/knx/dpt/dpt9.rb +204 -0
- data/lib/ansible/knx/dpt/tests/test_dpt10.rb +45 -0
- data/lib/ansible/knx/dpt/tests/test_dpt9.rb +60 -0
- data/lib/ansible/knx/hexdump.rb +113 -0
- data/lib/ansible/knx/knx_dpt.rb +58 -0
- data/lib/ansible/knx/knx_dpt_scalar.rb +62 -0
- data/lib/ansible/knx/knx_eistypes.rb +76 -0
- data/lib/ansible/knx/knx_protocol.rb +99 -0
- data/lib/ansible/knx/knx_scene.rb +48 -0
- data/lib/ansible/knx/knx_tools.rb +76 -0
- data/lib/ansible/knx/knx_transceiver.rb +237 -0
- data/lib/ansible/knx/knx_value.rb +327 -0
- data/lib/ansible/openzwave/ozw_constants.rb +11 -0
- data/lib/ansible/openzwave/ozw_headers.rb +80 -0
- data/lib/ansible/openzwave/ozw_remote_manager.rb +7615 -0
- data/lib/ansible/openzwave/ozw_types.rb +406 -0
- data/lib/ansible/orbiter_proxy.rb +12 -0
- data/lib/ansible/transceiver.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_bool.rb +74 -0
- data/lib/ansible/zwave/types/valuetype_button.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_byte.rb +78 -0
- data/lib/ansible/zwave/types/valuetype_decimal.rb +64 -0
- data/lib/ansible/zwave/types/valuetype_int.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_list.rb +64 -0
- data/lib/ansible/zwave/types/valuetype_short.rb +63 -0
- data/lib/ansible/zwave/types/valuetype_string.rb +61 -0
- data/lib/ansible/zwave/zwave_command_classes.rb +113 -0
- data/lib/ansible/zwave/zwave_node.rb +5 -0
- data/lib/ansible/zwave/zwave_protocol.rb +52 -0
- data/lib/ansible/zwave/zwave_transceiver.rb +435 -0
- data/lib/ansible/zwave/zwave_value.rb +193 -0
- metadata +108 -0
@@ -0,0 +1,193 @@
|
|
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
|
+
# load thrift-generated code
|
26
|
+
require 'thrift'
|
27
|
+
require 'ozw_constants'
|
28
|
+
require 'ozw_headers'
|
29
|
+
require "ozw_remote_manager"
|
30
|
+
|
31
|
+
require 'ansible_value'
|
32
|
+
require 'ansible_callback'
|
33
|
+
|
34
|
+
require 'zwave_protocol'
|
35
|
+
require 'zwave_command_classes'
|
36
|
+
|
37
|
+
module Ansible
|
38
|
+
|
39
|
+
module ZWave
|
40
|
+
|
41
|
+
RefreshedNodes = {}
|
42
|
+
|
43
|
+
# extend the Thrift ValueID interface with some interesting stuff
|
44
|
+
class ValueID < OpenZWave::RemoteValueID
|
45
|
+
include AnsibleValue
|
46
|
+
include AnsibleCallback
|
47
|
+
|
48
|
+
#
|
49
|
+
# ------ CLASS VARIABLES & METHODS
|
50
|
+
#
|
51
|
+
@@transceiver = nil
|
52
|
+
def ValueID.transceiver; return @@transceiver; end
|
53
|
+
def ValueID.transceiver=(other);
|
54
|
+
@@transceiver = other if other.is_a? Ansible::ZWave::ZWave_Transceiver
|
55
|
+
end
|
56
|
+
|
57
|
+
# get existing ValueID object, or else create it
|
58
|
+
def ValueID.get_or_create(homeid_str, valueid_str)
|
59
|
+
query = AnsibleValue[:_homeId => homeid_str.to_i(16), :valueId => valueid_str.to_i(16)]
|
60
|
+
value = (query.is_a?Array and query.size>0 and query[0]) or
|
61
|
+
ValueID.new(homeid_str, valueid_str)
|
62
|
+
return value
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# ----- INSTANCE VARIABLES & METHODS
|
67
|
+
#
|
68
|
+
|
69
|
+
attr_reader :valueId
|
70
|
+
|
71
|
+
# equality checking
|
72
|
+
def == (other)
|
73
|
+
return (
|
74
|
+
other.is_a?(ValueID) and
|
75
|
+
(@_homeId == other._homeId) and (@valueId == other.valueId)
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# initialize ValueID by home and value id (both hex strings)
|
80
|
+
def initialize( homeid_str, valueid_str)
|
81
|
+
raise 'both arguments must be strings' if [homeid_str, valueid_str].find{|s| not s.is_a?String}
|
82
|
+
|
83
|
+
# wARNING: instance variable naming must be consistent with ozw_types.rb (Thrift interface)
|
84
|
+
@_homeId = homeid_str.to_i(16)
|
85
|
+
@valueId = valueid_str.to_i(16)
|
86
|
+
# parse all fields
|
87
|
+
m_id = OZW_ValueID_id.read([valueid_str.delete(' ')[-8..-1].to_i(16)].pack("N"))
|
88
|
+
m_id1 = OZW_ValueID_id1.read([valueid_str.delete(' ')[0..-9].to_i(16)].pack("N"))
|
89
|
+
# and store them
|
90
|
+
@_nodeId = m_id.node_id
|
91
|
+
@_genre = m_id.value_genre
|
92
|
+
@_type = m_id.value_type
|
93
|
+
@_valueIndex = m_id.value_idx
|
94
|
+
@_commandClassId = m_id.cmd_class
|
95
|
+
@_instance = m_id1.cmd_class_instance
|
96
|
+
# access flags, default R/W
|
97
|
+
@flags = {:r => true, :w => true}
|
98
|
+
puts "NEW ZWAVE VALUE CREATED: #{self.inspect}" if $DEBUG
|
99
|
+
|
100
|
+
if @_homeId > 0 then
|
101
|
+
# fill in some useful info so as not to query OpenZWave all the time
|
102
|
+
@flags[:readonly] = @@transceiver.manager_send(:IsValueReadOnly, self)
|
103
|
+
@flags[:writeonly] = @@transceiver.manager_send(:IsValueWriteOnly, self)
|
104
|
+
end
|
105
|
+
|
106
|
+
# time of last update
|
107
|
+
@last_update = nil
|
108
|
+
|
109
|
+
# a boolean flag set to true so as to know all subsequent notifications
|
110
|
+
# by OpenZWave regarding this value have been caused by us
|
111
|
+
@poll_delayed = false
|
112
|
+
|
113
|
+
# dynamic binding to the corresponding OpenZWave data type
|
114
|
+
@typename, @typedescr = OpenZWave::ValueTypes[@_type]
|
115
|
+
@typemod = Ansible::ZWave.module_eval(@typename)
|
116
|
+
raise "unknown/undeclared ZWave type module #{@typename}" unless @typemod.is_a?Module
|
117
|
+
# extend this ValueID with type-specific module
|
118
|
+
self.extend(@typemod)
|
119
|
+
# store this ZWave ValueID in the Ansible database
|
120
|
+
AnsibleValue.insert(self)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
# is this ZWave value read only?
|
125
|
+
def read_only?
|
126
|
+
(defined?@flags) and @flags[:readonly]
|
127
|
+
end
|
128
|
+
|
129
|
+
# is this ZWave value write only?
|
130
|
+
def write_only?
|
131
|
+
(defined?@flags) and @flags[:writeonly]
|
132
|
+
end
|
133
|
+
|
134
|
+
#
|
135
|
+
# ZWave-specific: read value from the bus
|
136
|
+
#
|
137
|
+
def read_value()
|
138
|
+
return(false) unless respond_to? :read_operation
|
139
|
+
result = @@transceiver.manager_send(read_operation, self)
|
140
|
+
if result and result.retval then
|
141
|
+
puts "#{self}.read_value() result == #{result.o_value}, Refreshed=#{RefreshedNodes[@_nodeId]}"
|
142
|
+
update(result.o_value)
|
143
|
+
return(true)
|
144
|
+
else
|
145
|
+
return(false)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# ZWave-specific: write new value to OpenZWave
|
151
|
+
# new_val must be in protocol form
|
152
|
+
# return true if successful, false otherwise
|
153
|
+
def write_value(new_val)
|
154
|
+
return(false) unless respond_to? :write_operation
|
155
|
+
if @@transceiver.manager_send(write_operation, self, new_val) then
|
156
|
+
# value can also be updated by ValueChanged notification
|
157
|
+
update(new_val)
|
158
|
+
return(true)
|
159
|
+
else
|
160
|
+
return(false)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# return a reasonable string representation of the ZWave value
|
165
|
+
def to_s
|
166
|
+
return "ZWaveValue[n:#{@_nodeId} g:#{@_genre} cc:#{@_commandClassId} i:#{@_instance} vi:#{@_valueIndex} t:#{@_type}]==#{@current_value}(#{@current_value.class})"
|
167
|
+
end
|
168
|
+
|
169
|
+
# fetch all available ValueID info from OpenZWave
|
170
|
+
def explain
|
171
|
+
return(%Q{
|
172
|
+
Value Label: #{ @@transceiver.manager_send(:GetValueLabel, self)}
|
173
|
+
Value Help: #{ @@transceiver.manager_send(:GetValueHelp, self)}
|
174
|
+
|
175
|
+
Value Units: #{ @@transceiver.manager_send(:GetValueUnits, self)}
|
176
|
+
Value Min: #{ @@transceiver.manager_send(:GetValueMin, self)}
|
177
|
+
Value Max: #{ @@transceiver.manager_send(:GetValueMax, self)}
|
178
|
+
|
179
|
+
Value read-only? #{ @@transceiver.manager_send(:IsValueReadOnly, self)}
|
180
|
+
Value write-only? #{ @@transceiver.manager_send(:IsValueWriteOnly, self)}
|
181
|
+
Value set? #{ @@transceiver.manager_send(:IsValueSet, self)}
|
182
|
+
})
|
183
|
+
end
|
184
|
+
|
185
|
+
end # class
|
186
|
+
|
187
|
+
#
|
188
|
+
# load all known ZWave type modules
|
189
|
+
Dir["lib/ansible/zwave/types/*.rb"].each { |f| load f }
|
190
|
+
|
191
|
+
end #module ZWave
|
192
|
+
|
193
|
+
end #module Ansible
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ansible4ozw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Elias Karakoulakis (ekarak)
|
9
|
+
- Justin Grevich (jgrevich)
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: A simple hello world gem
|
16
|
+
email:
|
17
|
+
- elias.karakoulakis@gmail.com
|
18
|
+
- justin@grevi.ch
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- lib/ansible/ansible_callback.rb
|
24
|
+
- lib/ansible/ansible_device.rb
|
25
|
+
- lib/ansible/ansible_value.rb
|
26
|
+
- lib/ansible/config.rb
|
27
|
+
- lib/ansible/devices/ansible_dimmer.rb
|
28
|
+
- lib/ansible/devices/ansible_switch.rb
|
29
|
+
- lib/ansible/knx/dpt/canonical_1bit.rb
|
30
|
+
- lib/ansible/knx/dpt/dpt1.rb
|
31
|
+
- lib/ansible/knx/dpt/dpt10.rb
|
32
|
+
- lib/ansible/knx/dpt/dpt11.rb
|
33
|
+
- lib/ansible/knx/dpt/dpt12.rb
|
34
|
+
- lib/ansible/knx/dpt/dpt13.rb
|
35
|
+
- lib/ansible/knx/dpt/dpt14.rb
|
36
|
+
- lib/ansible/knx/dpt/dpt15.rb
|
37
|
+
- lib/ansible/knx/dpt/dpt16.rb
|
38
|
+
- lib/ansible/knx/dpt/dpt17.rb
|
39
|
+
- lib/ansible/knx/dpt/dpt18.rb
|
40
|
+
- lib/ansible/knx/dpt/dpt19.rb
|
41
|
+
- lib/ansible/knx/dpt/dpt2.rb
|
42
|
+
- lib/ansible/knx/dpt/dpt3.rb
|
43
|
+
- lib/ansible/knx/dpt/dpt4.rb
|
44
|
+
- lib/ansible/knx/dpt/dpt5.rb
|
45
|
+
- lib/ansible/knx/dpt/dpt6.rb
|
46
|
+
- lib/ansible/knx/dpt/dpt7.rb
|
47
|
+
- lib/ansible/knx/dpt/dpt8.rb
|
48
|
+
- lib/ansible/knx/dpt/dpt9.rb
|
49
|
+
- lib/ansible/knx/dpt/tests/test_dpt10.rb
|
50
|
+
- lib/ansible/knx/dpt/tests/test_dpt9.rb
|
51
|
+
- lib/ansible/knx/EIBConnection.rb
|
52
|
+
- lib/ansible/knx/hexdump.rb
|
53
|
+
- lib/ansible/knx/knx_dpt.rb
|
54
|
+
- lib/ansible/knx/knx_dpt_scalar.rb
|
55
|
+
- lib/ansible/knx/knx_eistypes.rb
|
56
|
+
- lib/ansible/knx/knx_protocol.rb
|
57
|
+
- lib/ansible/knx/knx_scene.rb
|
58
|
+
- lib/ansible/knx/knx_tools.rb
|
59
|
+
- lib/ansible/knx/knx_transceiver.rb
|
60
|
+
- lib/ansible/knx/knx_value.rb
|
61
|
+
- lib/ansible/openzwave/ozw_constants.rb
|
62
|
+
- lib/ansible/openzwave/ozw_headers.rb
|
63
|
+
- lib/ansible/openzwave/ozw_remote_manager.rb
|
64
|
+
- lib/ansible/openzwave/ozw_types.rb
|
65
|
+
- lib/ansible/orbiter_proxy.rb
|
66
|
+
- lib/ansible/transceiver.rb
|
67
|
+
- lib/ansible/zwave/types/valuetype_bool.rb
|
68
|
+
- lib/ansible/zwave/types/valuetype_button.rb
|
69
|
+
- lib/ansible/zwave/types/valuetype_byte.rb
|
70
|
+
- lib/ansible/zwave/types/valuetype_decimal.rb
|
71
|
+
- lib/ansible/zwave/types/valuetype_int.rb
|
72
|
+
- lib/ansible/zwave/types/valuetype_list.rb
|
73
|
+
- lib/ansible/zwave/types/valuetype_short.rb
|
74
|
+
- lib/ansible/zwave/types/valuetype_string.rb
|
75
|
+
- lib/ansible/zwave/zwave_command_classes.rb
|
76
|
+
- lib/ansible/zwave/zwave_node.rb
|
77
|
+
- lib/ansible/zwave/zwave_protocol.rb
|
78
|
+
- lib/ansible/zwave/zwave_transceiver.rb
|
79
|
+
- lib/ansible/zwave/zwave_value.rb
|
80
|
+
- lib/ansible.rb
|
81
|
+
homepage: https://github.com/jgrevich/ansible
|
82
|
+
licenses: []
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements:
|
100
|
+
- KNX or ZWave controller + Devices
|
101
|
+
- stompserver_ng
|
102
|
+
- Thrift4OZW
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.8.24
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: Ruby-based home automation scripting framework for KNX and ZWave devices.
|
108
|
+
test_files: []
|