Class: Fritzbox::Smarthome::SmokeDetector
- Defined in:
- lib/fritzbox/smarthome/smoke_detector.rb
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
Methods inherited from Actor
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 |
.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 |