Class: Tado::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/tado/device.rb

Overview

Class wrapping interaction with the Tado Device

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serial, data: nil, zone:) ⇒ Device

Create a device instance associated to the zone

Parameters:

  • serial (String)

    device serial number

  • zone (Zone)

    zone to which this device belongs

  • data (Hash{Symbol => Object}) (defaults to: nil)

    initialising data



80
81
82
83
84
85
# 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

Instance Attribute Details

#battery:NORMAL (readonly)

Battery status

Returns:

  • (:NORMAL)


50
51
52
# File 'lib/tado/device.rb', line 50

def battery
  @battery
end

#calibratednil, Time (readonly)

Time of device calilbration

Returns:

  • (nil)

    device was not calibrated

  • (Time)

    timestamp of device calibration



65
66
67
# File 'lib/tado/device.rb', line 65

def calibrated
  @calibrated
end

#capabilitiesArray<Symbol> (readonly)

Capabilities

Returns:

  • (Array<Symbol>)

    list of capabilities

    • :INSIDE_TEMPERATURE_MEASUREMENT

      temperature

    • :IDENTIFY

      identify



58
59
60
# File 'lib/tado/device.rb', line 58

def capabilities
  @capabilities
end

#connectionnil, Time (readonly)

Time of last connection

Returns:

  • (nil)

    device was not connected

  • (Time)

    timestamp of last device connection



72
73
74
# File 'lib/tado/device.rb', line 72

def connection
  @connection
end

#dutiesArray<Symbol> (readonly)

Duties performed by the device

Returns:

  • (Array<Symbol>)

    list of duties

    • :ZONE_UI

      user interface

    • :ZONE_DRIVER

      drive the heating/aircon

    • :ZONE_LEADER

      used as reference for temperature



44
45
46
# File 'lib/tado/device.rb', line 44

def duties
  @duties
end

#firmwareString (readonly)

Current firmware version

Returns:

  • (String)

    firmware version



35
36
37
# File 'lib/tado/device.rb', line 35

def firmware
  @firmware
end

#serialString (readonly)

Serial number of device

Returns:

  • (String)

    serial number



22
23
24
# File 'lib/tado/device.rb', line 22

def serial
  @serial
end

#type:HEATING, Symbol (readonly)

Type of device (heating, airconditioning)

Returns:

  • (:HEATING)

    heating device

  • (Symbol)


29
30
31
# File 'lib/tado/device.rb', line 29

def type
  @type
end

Class Method Details

.from_json(json, zone:) ⇒ Object

Create a device instance associated to the zone from the JSON returned by the Tado API

Parameters:

  • json (Object)

    json returned by the Tado API

  • zone (Zone)

    zone to which this device belongs



12
13
14
15
16
# 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