Method: MQTT::Homie::Property#unpublish

Defined in:
lib/mqtt/homie/property.rb

#unpublishObject



207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/mqtt/homie/property.rb', line 207

def unpublish
  return unless published?

  @published = false

  mqtt.publish("#{topic}/$name", retain: true, qos: 0)
  mqtt.publish("#{topic}/$datatype", retain: true, qos: 0)
  mqtt.publish("#{topic}/$format", retain: true, qos: 0) if format
  mqtt.publish("#{topic}/$settable", retain: true, qos: 0) if settable?
  mqtt.publish("#{topic}/$retained", retain: true, qos: 0) unless retained?
  mqtt.publish("#{topic}/$unit", retain: true, qos: 0) if unit
  mqtt.unsubscribe("#{topic}/set") if settable?
  mqtt.publish(topic, retain: retained?, qos: 0) if !value.nil? && retained?
end