Class: SDN::CLI::MQTT::Group

Inherits:
Struct
  • Object
show all
Defined in:
lib/sdn/cli/mqtt/group.rb

Overview

In-memory state container for a discovered group and its aggregated MQTT attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGroup

Returns a new instance of Group.



16
17
18
19
# File 'lib/sdn/cli/mqtt/group.rb', line 16

def initialize(*)
  members.each { |k| self[k] = :nil }
  super
end

Instance Attribute Details

#addrObject

Returns the value of attribute addr

Returns:

  • (Object)

    the current value of addr



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def addr
  @addr
end

#bridgeObject

Returns the value of attribute bridge

Returns:

  • (Object)

    the current value of bridge



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def bridge
  @bridge
end

#hass_stateObject

Returns the value of attribute hass_state

Returns:

  • (Object)

    the current value of hass_state



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def hass_state
  @hass_state
end

#ipObject

Returns the value of attribute ip

Returns:

  • (Object)

    the current value of ip



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def ip
  @ip
end

#last_directionObject

Returns the value of attribute last_direction

Returns:

  • (Object)

    the current value of last_direction



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def last_direction
  @last_direction
end

#motor_objects<SDN::CLI::MQTT::Motor> (readonly)

Returns:



37
38
39
# File 'lib/sdn/cli/mqtt/group.rb', line 37

def motor_objects
  bridge.motors.select { |_addr, motor| motor.groups_string.include?(printed_addr) }.values
end

#motorsObject

Returns the value of attribute motors

Returns:

  • (Object)

    the current value of motors



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def motors
  @motors
end

#motors_stringString (readonly)

Returns the current group membership as a comma-separated motor address list.

Returns:

  • (String)


46
47
48
# File 'lib/sdn/cli/mqtt/group.rb', line 46

def motors_string
  motor_objects.map { |m| Message.print_address(Message.parse_address(m.addr)) }.sort.join(",")
end

#position_percentObject

Returns the value of attribute position_percent

Returns:

  • (Object)

    the current value of position_percent



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def position_percent
  @position_percent
end

#position_pulsesObject

Returns the value of attribute position_pulses

Returns:

  • (Object)

    the current value of position_pulses



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def position_pulses
  @position_pulses
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



7
8
9
# File 'lib/sdn/cli/mqtt/group.rb', line 7

def state
  @state
end

Instance Method Details

#printed_addrString

Returns:

  • (String)


30
31
32
# File 'lib/sdn/cli/mqtt/group.rb', line 30

def printed_addr
  Message.print_address(Message.parse_address(addr))
end