Class: Fritzbox::Smarthome::SmokeDetector

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

Constant Summary

Constants inherited from Actor

Actor::ResourceNotFound

Instance Attribute Summary collapse

Attributes inherited from Actor

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Actor

all, find_by!, new_from_api, #reload

Methods inherited from Resource

get, parse

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

Instance Method Details

#assign_from_api(data) ⇒ Object



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

def assign_from_api(data)
  super(data)

  assign_attributes(
    alert_state: data.dig('alert', 'state').to_i,
    last_alert:  Time.at(data.dig('alert', 'lastalertchgtimestamp').to_i)
  )
end