module MQTT::HomeAssistant::Homie::Property

Public Class Methods

new(*args, hass: nil, **kwargs) click to toggle source
Calls superclass method
# File lib/mqtt/home_assistant/homie/property.rb, line 7
def initialize(*args, hass: nil, **kwargs)
  super(*args, **kwargs)

  return unless hass

  case hass
  when Symbol
    public_send("hass_#{hass}")
  when Hash
    raise ArgumentError, "hass must only contain one item" unless hass.length == 1

    public_send("hass_#{hass.first.first}", **hass.first.last)
  else
    raise ArgumentError, "hass must be a Symbol or a Hash of HASS device type to additional HASS options"
  end
end

Public Instance Methods

publish() click to toggle source
Calls superclass method
# File lib/mqtt/home_assistant/homie/property.rb, line 42
def publish
  super.tap do
    @pending_hass_registrations&.each do |entity|
      method = entity.delete(:method)
      HomeAssistant.public_send(method, self, **entity)
    end
    @pending_hass_registrations = nil
  end
end

Private Instance Methods

pending_hass_registrations() click to toggle source
# File lib/mqtt/home_assistant/homie/property.rb, line 54
def pending_hass_registrations
  @pending_hass_registrations ||= []
end