Class: Tinkerforge::BrickletOutdoorWeather
- Inherits:
-
Object
- Object
- Tinkerforge::BrickletOutdoorWeather
- Defined in:
- lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.rb
Instance Method Summary collapse
-
#sensors ⇒ Object
Returns the last measured data for all sensors.
-
#state ⇒ Object
Returns the device’s state.
Instance Method Details
#sensors ⇒ Object
Returns the last measured data for all sensors.
The result is a Hash, with sensor identifiers (or their mapped values) as the keys. Values per sensor are:
-
0: Temperature (°C)
-
1: Relative humidity (%RH)
-
2: Last change (seconds)
Sensor identifiers can be mapped to descriptive strings or other values:
22 23 24 25 26 27 |
# File 'lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.rb', line 22 def sensors sensormap = (config['sensormap'].class == Hash) ? config['sensormap'] : {} get_sensor_identifiers.map do |id| [ (sensormap[id] || id), get_sensor_data(id).each_with_index.map { |v,i| i == 0 ? v/10.0 : v } ] end.to_h end |
#state ⇒ Object
Returns the device’s state.
6 7 8 9 10 |
# File 'lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.rb', line 6 def state super.merge( 'sensor_data' => sensors, ) end |