Class: Fritzbox::Smarthome::SmokeDetector
- Defined in:
- lib/fritzbox/smarthome/smoke_detector.rb
Constant Summary
Constants inherited from Actor
Instance Attribute Summary collapse
-
#alert_state ⇒ Object
Returns the value of attribute alert_state.
-
#last_alert ⇒ Object
Returns the value of attribute last_alert.
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
Instance Attribute Details
#alert_state ⇒ Object
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_alert ⇒ Object
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
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 |