plugins/slack_plugin.rb in ladder_drive-0.6.5 vs plugins/slack_plugin.rb in ladder_drive-0.6.6
- old
+ new
@@ -88,18 +88,19 @@
devices.each do |device|
triggered = false
v = nil
case event[:trigger][:type]
when "interval"
+
t = @times[event.object_id] || now
triggered = t <= now
if triggered
interval_triggered = true
t += event[:trigger][:interval] || 300
@times[event.object_id] = t
end
- v = device.send event[:value_type] || :device, event[:trigger][:text_length] || 8
+ v = device.send event[:value_type] || :value, event[:trigger][:text_length] || 8
else
v = device.send event[:value_type] || :value, event[:text_length] || 8
unless @values[device.name] == v
@values[device.name] = v
case event[:trigger][:type]
@@ -147,10 +148,18 @@
req = Net::HTTP::Post.new(uri.path)
req["Content-Type"] = "application/json"
format = event[:format] || "__comment__ occured at __time__"
- format = arg[:value] ? format[:raise] : format[:fall] unless format.is_a? String
+ case format
+ when Hash
+ case arg[:value]
+ when false, nil, 0
+ format = format[:fall]
+ else
+ format = format[:interval] || format[:raise]
+ end
+ end
device_name = arg[:device_name]
comment = @comments[device_name] || device_name
value = arg[:value].to_s
time = arg[:time].iso8601