Skip to content

Commit

Permalink
feat(interface/sensor): add type modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Mar 13, 2024
1 parent 8ae6bdf commit 257cb18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: placeos-driver
version: 6.9.18
version: 6.9.19
crystal: ">= 1.0.0"

dependencies:
Expand Down
9 changes: 8 additions & 1 deletion src/placeos-driver/interface/sensor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ abstract class PlaceOS::Driver
def initialize(
@type, @value, @last_seen, @mac, @id, @name, @raw = nil, @loc = nil,
@status = Status::Normal, @limit_high = nil, @limit_low = nil,
@resolution = nil, @module_id = nil, @binding = nil, @unit = nil
@resolution = nil, @module_id = nil, @binding = nil, @unit = nil,
@modifier = nil
)
end

property status : Status
property modifier : String?
property type : SensorType

property value : Float64
Expand Down Expand Up @@ -167,6 +169,11 @@ abstract class PlaceOS::Driver

Units::Measurement.new(self.value, this_unit).convert_to(other_unit).to_f
end

def modified_type : String
return "#{@modifier} #{@type}" if @modifier.presence
@type.to_s
end
end
end
end

0 comments on commit 257cb18

Please sign in to comment.