class Tado::Device
Attributes
Battery status
@return [:NORMAL]
Time of device calilbration
@return [nil ] device was not calibrated @return [Time] timestamp of device calibration
Capabilities
@return [Array<Symbol>] list of capabilities
* [:INSIDE_TEMPERATURE_MEASUREMENT] temperature * [:IDENTIFY ] identify
Time of last connection
@return [nil ] device was not connected @return [Time] timestamp of last device connection
Duties performed by the device
@return [Array<Symbol>] list of duties
* [:ZONE_UI ] user interface * [:ZONE_DRIVER] drive the heating/aircon * [:ZONE_LEADER] used as reference for temperature
Current firmware version
@return [String] firmware version
Serial number of device
@return [String] serial number
Type of device (heating, airconditioning)
@return [:HEATING] heating device @return [Symbol]
Public Class Methods
Create a device instance associated to the zone from the JSON returned by the Tado
API
@param json [Object] json returned by the Tado
API @param zone [Zone ] zone to which this device belongs
# File lib/tado/device.rb, line 12 def self.from_json(json, zone:) self.new(json.dig('serialNo'), data: self.parse_from_json(json), zone: zone) end
Create a device instance associated to the zone
@param serial [String] device serial number @param zone [Zone ] zone to which this device belongs @param data [Hash{Symbol => Object}] initialising data
# File lib/tado/device.rb, line 80 def initialize(serial, data: nil, zone:) @zone = zone @serial = serial data&.each {|k, v| instance_variable_set("@#{k}", v) } end
Private Class Methods
# File lib/tado/device.rb, line 89 def self.parse_from_json(json) { :type => json.dig('deviceType'), :firmware => json.dig('currentFwVersion'), :duties => json.dig('duties').map(&:to_sym), :battery => json.dig('batteryState').to_sym, :capabilities => json.dig('characteristics', 'capabilities') .map(&:to_sym), :calibrated => if json.dig('mountingState', 'value') == 'CALIBRATED' Time.parse(json.dig('mountingState', 'timestamp')) end, :connection => if json.dig('connectionState', 'value') Time.parse(json.dig('connectionState', 'timestamp')) end, } end