Class: Fritzbox::Smarthome::SmokeDetector

Inherits:
Actor show all
Defined in:
lib/fritzbox/smarthome/smoke_detector.rb

Instance Attribute Summary collapse

Attributes inherited from Actor

#ain, #group_members, #id, #manufacturer, #name, #present, #type

Class Method Summary collapse

Methods inherited from Actor

all

Methods inherited from Resource

get

Instance Attribute Details

#alert_stateObject

Returns the value of attribute alert_state.



5
6
7
# File 'lib/fritzbox/smarthome/smoke_detector.rb', line 5

def alert_state
  @alert_state
end

#last_alertObject

Returns the value of attribute last_alert.



5
6
7
# File 'lib/fritzbox/smarthome/smoke_detector.rb', line 5

def last_alert
  @last_alert
end

Class Method Details

.match?(data) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/fritzbox/smarthome/smoke_detector.rb', line 10

def match?(data)
  data.key?('alert')
end

.new_from_api(data) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/fritzbox/smarthome/smoke_detector.rb', line 14

def new_from_api(data)
  instance = super
  instance.assign_attributes(
     alert_state: data.dig('alert', 'state').to_i,
     last_alert:  Time.at(data.dig('alert', 'lastalertchgtimestamp').to_i)
  )
  instance
end