tinderfridge 0.2.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinderfridge/device.rb +95 -1
- data/lib/tinderfridge/device_collection.rb +69 -0
- data/lib/tinderfridge/device_info.txt +5 -0
- data/lib/tinderfridge/devices/brick_hat/brick_hat.json +11 -0
- data/lib/tinderfridge/devices/brick_hat/brick_hat.rb +18 -0
- data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.json +11 -0
- data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.rb +14 -0
- data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json +10 -0
- data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.rb +20 -0
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb +19 -0
- data/lib/tinderfridge/devices/bricklet_analog_in_v3/bricklet_analog_in_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_analog_out_v3/bricklet_analog_out_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_can_v2/bricklet_can_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.rb +31 -0
- data/lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json +10 -0
- data/lib/tinderfridge/devices/bricklet_dc_v2/bricklet_dc_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_distance_us_v2/bricklet_distance_us_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.json +10 -0
- data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.rb +18 -0
- data/lib/tinderfridge/devices/bricklet_e_paper_296x128/bricklet_e_paper_296x128.json +10 -0
- data/lib/tinderfridge/devices/bricklet_energy_monitor/bricklet_energy_monitor.json +10 -0
- data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_gps_v2.rb → bricklet_gps_v2/bricklet_gps_v2.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_hall_effect_v2/bricklet_hall_effect_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_humidity_v2/bricklet_humidity_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_imu_v3/bricklet_imu_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_industrial_counter/bricklet_industrial_counter.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_digital_in_4_v2/bricklet_industrial_digital_in_4_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_digital_out_4_v2/bricklet_industrial_digital_out_4_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.json +10 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb +20 -0
- data/lib/tinderfridge/devices/bricklet_industrial_ptc/bricklet_industrial_ptc.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_quad_relay_v2/bricklet_industrial_quad_relay_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.json +10 -0
- data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.rb +17 -0
- data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.rb +15 -0
- data/lib/tinderfridge/devices/bricklet_laser_range_finder_v2/bricklet_laser_range_finder_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_lcd_128x64.rb → bricklet_lcd_128x64/bricklet_lcd_128x64.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_led_strip_v2/bricklet_led_strip_v2.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_led_strip_v2.rb → bricklet_led_strip_v2/bricklet_led_strip_v2.rb} +12 -0
- data/lib/tinderfridge/devices/bricklet_linear_poti_v2/bricklet_linear_poti_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.rb +22 -0
- data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.json +10 -0
- data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb +42 -0
- data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.rb +16 -0
- data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.json +10 -0
- data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.rb +16 -0
- data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_outdoor_weather.rb → bricklet_outdoor_weather/bricklet_outdoor_weather.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_performance_dc/bricklet_performance_dc.json +11 -0
- data/lib/tinderfridge/devices/bricklet_piezo_speaker_v2/bricklet_piezo_speaker_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_real_time_clock_v2/bricklet_real_time_clock_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.rb +15 -0
- data/lib/tinderfridge/devices/bricklet_rgb_led_button/bricklet_rgb_led_button.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_rgb_led_button.rb → bricklet_rgb_led_button/bricklet_rgb_led_button.rb} +9 -0
- data/lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_rgb_led_v2.rb → bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb} +7 -0
- data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.rb +20 -0
- data/lib/tinderfridge/devices/bricklet_rotary_poti_v2/bricklet_rotary_poti_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_rs232_v2/bricklet_rs232_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_rs485/bricklet_rs485.json +11 -0
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +128 -0
- data/lib/tinderfridge/devices/bricklet_servo_v2/bricklet_servo_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json +10 -0
- data/lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_thermal_imaging/bricklet_thermal_imaging.json +10 -0
- data/lib/tinderfridge/devices/bricklet_thermocouple_v2/bricklet_thermocouple_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_uv_light_v2/bricklet_uv_light_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.rb +18 -0
- data/lib/tinderfridge/devices/bricklet_xmc1400_breakout/bricklet_xmc1400_breakout.json +10 -0
- data/lib/tinderfridge/ip_connection.rb +66 -10
- data/lib/tinderfridge/tinkerforge.rb +3 -0
- data/lib/tinderfridge/version.rb +1 -1
- metadata +98 -17
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61c196b035feb056ef219545b4fb18b0d31143ec45dce191fd24abba736c6c06
|
4
|
+
data.tar.gz: b8f7e262293e0c1f42648f57360818bc160bef744d3bf4e1424c31f81658fe84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68b64abcf925c879f4962b505c4ae06b9cdf3d4fad9964c34e1d33cbe1dc72fffee805a7a1651fe9b4d0cdc3c2c93a53a593dafdc0ad28f8fea93e20a3fc2c0b
|
7
|
+
data.tar.gz: b3a2980b1f8d21b9044b59b8e40b62bf148fc5a18505b3391f1c7047796df5139e2782e50872cac01acf1a29bb8b52cfe14fea0fca8b706c9a6fb3d120ebbfc5
|
data/lib/tinderfridge/device.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'tinkerforge/ip_connection'
|
2
2
|
|
3
3
|
module Tinkerforge
|
4
|
+
|
4
5
|
class Device
|
5
6
|
|
6
7
|
#----------------------------------------------------------------------#
|
@@ -41,7 +42,7 @@ module Tinkerforge
|
|
41
42
|
def inherited(klass)
|
42
43
|
if info = Tinkerforge.device_info(klass)
|
43
44
|
begin
|
44
|
-
require("tinderfridge/devices/#{info[2][1]}")
|
45
|
+
require("tinderfridge/devices/#{info[2][1]}/#{info[2][1]}")
|
45
46
|
rescue LoadError
|
46
47
|
# No extension found for this device
|
47
48
|
end
|
@@ -54,14 +55,80 @@ module Tinkerforge
|
|
54
55
|
# Instance Methods #
|
55
56
|
#----------------------------------------------------------------------#
|
56
57
|
|
58
|
+
# Returns the device's UID. Not to be confused with #uid, which returns the numeric UID.
|
59
|
+
attr_reader :uid_string
|
60
|
+
|
61
|
+
# Returns the device's numeric Device Identifier.
|
62
|
+
attr_reader :device_identifier
|
63
|
+
|
64
|
+
# Returns the device's Display Name.
|
65
|
+
attr_reader :device_display_name
|
66
|
+
|
57
67
|
# Returns the device's IPConnection object.
|
58
68
|
attr_reader :ipcon
|
59
69
|
|
70
|
+
# Returns device information.
|
71
|
+
#
|
72
|
+
# Device information is an array:
|
73
|
+
# - 0 : Device Identifier
|
74
|
+
# - 1 : Device Display Name
|
75
|
+
# - 2 : Associated class name and source file
|
76
|
+
def device_info
|
77
|
+
Tinkerforge.device_info device_identifier
|
78
|
+
end
|
79
|
+
|
60
80
|
# Returns a programmer-friendly representation of the device.
|
61
81
|
def inspect
|
62
82
|
"%s (%s@%s:%s)" % [self.class, @uid_string, ipcon.host, ipcon.port]
|
63
83
|
end
|
64
84
|
|
85
|
+
# Returns the device's properties.
|
86
|
+
def properties
|
87
|
+
@properties ||= {
|
88
|
+
'device_identifier' => device_identifier,
|
89
|
+
'device_display_name' => device_display_name,
|
90
|
+
}.merge load_properties
|
91
|
+
end
|
92
|
+
|
93
|
+
alias props properties
|
94
|
+
|
95
|
+
# Returns the device's state.
|
96
|
+
def state
|
97
|
+
|
98
|
+
# BrickDaemon inherits from Device, but has no #get_identity.
|
99
|
+
return {} unless respond_to? 'get_identity'
|
100
|
+
|
101
|
+
identity = get_identity
|
102
|
+
|
103
|
+
[
|
104
|
+
[ 'uid' , uid_string ],
|
105
|
+
[ 'update_time' , Time.now.gmtime ],
|
106
|
+
[ 'firmware_version' , identity[4].join('.') ],
|
107
|
+
|
108
|
+
[ 'connected', { 'uid' => identity[1], 'position' => identity[2] } ],
|
109
|
+
[ 'ipcon' , { 'host' => ipcon.host , 'port' => ipcon.port } ],
|
110
|
+
|
111
|
+
respond_to?('get_chip_temperature' ) ? [ 'chip_temperature' , get_chip_temperature ] : nil,
|
112
|
+
respond_to?('get_spitfp_error_count') ? [ 'spitfp_error_count', get_spitfp_error_count ] : nil,
|
113
|
+
respond_to?('get_status_led_config' ) ? [ 'status_led_config' , get_status_led_config ] : nil,
|
114
|
+
|
115
|
+
].compact.to_h
|
116
|
+
end
|
117
|
+
|
118
|
+
# Opens the online documentation for the device (Mac OS only).
|
119
|
+
#
|
120
|
+
# When the URL for the documentation is not known, does nothing.
|
121
|
+
def open_documentation
|
122
|
+
if properties['documentation_en_url'] and ( RUBY_PLATFORM =~ /darwin/ )
|
123
|
+
`open #{properties['documentation_en_url']}`
|
124
|
+
properties['documentation_en_url']
|
125
|
+
else
|
126
|
+
nil
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
alias doc open_documentation
|
131
|
+
|
65
132
|
# Identifies a Tinkerforge device by blinking its status led.
|
66
133
|
#
|
67
134
|
# Supports recent devices. When invoked on older devices, does nothing.
|
@@ -82,5 +149,32 @@ module Tinkerforge
|
|
82
149
|
end
|
83
150
|
end
|
84
151
|
|
152
|
+
private
|
153
|
+
|
154
|
+
def load_properties
|
155
|
+
if device_info
|
156
|
+
properties_file = File.join(
|
157
|
+
File.dirname(__FILE__),
|
158
|
+
'devices',
|
159
|
+
device_info[2][1],
|
160
|
+
device_info[2][1],
|
161
|
+
) + '.json'
|
162
|
+
|
163
|
+
if File.readable? properties_file
|
164
|
+
begin
|
165
|
+
require 'json'
|
166
|
+
JSON.load File.read properties_file
|
167
|
+
rescue
|
168
|
+
{}
|
169
|
+
end
|
170
|
+
else
|
171
|
+
{}
|
172
|
+
end
|
173
|
+
else
|
174
|
+
{}
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
85
178
|
end
|
179
|
+
|
86
180
|
end
|
@@ -63,6 +63,75 @@ module Tinkerforge
|
|
63
63
|
end.size
|
64
64
|
end
|
65
65
|
|
66
|
+
# Returns the properties of devices in the collection.
|
67
|
+
def properties
|
68
|
+
smap 'properties'
|
69
|
+
end
|
70
|
+
|
71
|
+
alias props properties
|
72
|
+
|
73
|
+
# Returns the state of devices in the collection.
|
74
|
+
def state
|
75
|
+
smap 'state'
|
76
|
+
end
|
77
|
+
|
78
|
+
# Opens the online documentation for the devices in the collection (Mac OS only).
|
79
|
+
#
|
80
|
+
# When the URL for a device's documentation is not known, does nothing.
|
81
|
+
def open_documentation
|
82
|
+
smap 'open_documentation'
|
83
|
+
end
|
84
|
+
|
85
|
+
alias doc open_documentation
|
86
|
+
|
87
|
+
# Turns off light sources such as screens and RGB LEDs for devices in the collection.
|
88
|
+
#
|
89
|
+
# Ignores devices that do not support the blackout method.
|
90
|
+
def blackout
|
91
|
+
smap 'blackout'
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns a list of unique IP Connections used by devices in the collection.
|
95
|
+
def ipcons
|
96
|
+
smap('ipcon').values.compact.uniq
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns an array of devices in the collection matching the selector.
|
100
|
+
#
|
101
|
+
# Selector argument can be:
|
102
|
+
# - Device Identifier
|
103
|
+
# - Class name or Device Display Name (Regexp)
|
104
|
+
# Selection by regular expression is case-insensitive by default.
|
105
|
+
#
|
106
|
+
# @example Select by class name and Device Display Name
|
107
|
+
# # All 'analog' devices
|
108
|
+
# tf = Tinkerforge.connect.discover(1)
|
109
|
+
# tf.find_all /analog/
|
110
|
+
def find_all(selector)
|
111
|
+
case selector
|
112
|
+
when Integer
|
113
|
+
values.select { |v| v.device_identifier == selector}
|
114
|
+
when Regexp
|
115
|
+
r = Regexp.new selector.source, Regexp::IGNORECASE
|
116
|
+
values.select { |v| v.class.to_s.split('::').last =~ r || v.device_display_name =~ r }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns the first device in the collection matching the selector.
|
121
|
+
#
|
122
|
+
# Selector argument can be:
|
123
|
+
# - Device Identifier
|
124
|
+
# - Class name or Device Display Name (Regexp)
|
125
|
+
# Selection by regular expression is case-insensitive by default.
|
126
|
+
#
|
127
|
+
# @example Select by Device Identifier
|
128
|
+
# # Remote Switch Bricklet 2.0
|
129
|
+
# tf = Tinkerforge.connect('myhost.local').discover(1)
|
130
|
+
# tf.find 289
|
131
|
+
def find(selector)
|
132
|
+
find_all(selector).first
|
133
|
+
end
|
134
|
+
|
66
135
|
private
|
67
136
|
|
68
137
|
def smap(m)
|
@@ -135,5 +135,10 @@
|
|
135
135
|
2147 CO2 Bricklet 2.0 Tinkerforge::BrickletCO2V2 bricklet_co2_v2
|
136
136
|
2152 Energy Monitor Bricklet Tinkerforge::BrickletEnergyMonitor bricklet_energy_monitor
|
137
137
|
2153 Compass Bricklet Tinkerforge::BrickletCompass bricklet_compass
|
138
|
+
2156 Performance DC Bricklet Tinkerforge::BrickletPerformanceDC bricklet_performance_dc
|
139
|
+
2157 Servo Bricklet 2.0 Tinkerforge::BrickletServoV2 bricklet_servo_v2
|
138
140
|
2161 IMU Bricklet 3.0 Tinkerforge::BrickletIMUV3 bricklet_imu_v3
|
139
141
|
2162 Industrial Dual AC Relay Bricklet Tinkerforge::BrickletIndustrialDualACRelay bricklet_industrial_dual_ac_relay
|
142
|
+
2164 Industrial PTC Bricklet Tinkerforge::BrickletIndustrialPTC bricklet_industrial_ptc
|
143
|
+
2165 DC Bricklet 2.0 Tinkerforge::BrickletDCV2 bricklet_dc_v2
|
144
|
+
2166 Silent Stepper Bricklet 2.0 Tinkerforge::BrickletSilentStepperV2 bricklet_silent_stepper_v2
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickHAT
|
4
|
+
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
volts = get_voltages
|
8
|
+
super.merge(
|
9
|
+
'bricklet_power' => get_bricklet_power,
|
10
|
+
'usb_voltage' => volts[0],
|
11
|
+
'dc_voltage' => volts[1],
|
12
|
+
'sleep_mode' => get_sleep_mode,
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletAirQuality
|
4
|
+
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
av = get_all_values
|
8
|
+
super.merge(
|
9
|
+
'iaq_index' => av[0],
|
10
|
+
'iaq_index_accuracy' => av[1],
|
11
|
+
'temperature' => av[2],
|
12
|
+
'temperature_offset' => get_temperature_offset,
|
13
|
+
'humidity' => av[3],
|
14
|
+
'air_pressure' => av[4],
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletAmbientLightV3
|
4
|
+
|
5
|
+
ILLUMINANCE_RANGES = [ 64000, 32000, 16000, 8000, 1300, 600, 100000 ]
|
6
|
+
|
7
|
+
# Returns the device's state.
|
8
|
+
def state
|
9
|
+
super.merge(
|
10
|
+
'configuration' => conf = get_configuration,
|
11
|
+
'illuminance_range' => ILLUMINANCE_RANGES[ conf[0] ],
|
12
|
+
'integration_time' => 50 + conf[1] * 50,
|
13
|
+
'illuminance_raw' => get_illuminance,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletColorV2
|
4
|
+
|
5
|
+
GAINS = [1, 4, 16, 60]
|
6
|
+
INTEGRATION_TIMES = [2.4, 24, 101, 154, 700]
|
7
|
+
|
8
|
+
# Switches off the Bricklet's white LED.
|
9
|
+
def blackout
|
10
|
+
set_light false
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
# Returns the device's state.
|
15
|
+
def state
|
16
|
+
super.merge(
|
17
|
+
'configuration' => config = get_configuration,
|
18
|
+
'gain' => GAINS[ config[0] ],
|
19
|
+
'integration_time' => INTEGRATION_TIMES[ config[1] ],
|
20
|
+
'color_rgbc' => color = get_color,
|
21
|
+
'illuminance_raw' => illum = get_illuminance,
|
22
|
+
'illuminance' => illum * 700.0 / GAINS[ config[0] ] / INTEGRATION_TIMES[ config[1] ],
|
23
|
+
'color_temperature' => get_color_temperature,
|
24
|
+
'saturated' => color[0,3].include?(65535),
|
25
|
+
'light' => get_light,
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|