package OwfsSensors;

use strict;

my %sensors  = ("stigare", "/tmp/1wire/bus.0/10.627F7C010800/temperature",
                "ute"    , "/tmp/1wire/bus.0/10.29877C010800/temperature",
           	"inne"   , "/tmp/1wire/bus.0/10.057C7C010800/temperature",
                "rokgas" , "/tmp/1wire/bus.0/30.FFDF61120000/typeK/temperature");

sub names {
  my @sensor_names = keys %sensors;
  return @sensor_names;
}

sub file {
  my $name = shift @_;
  return $sensors{$name};
}

sub temp {
  my $n = shift @_;
  my $f = file($n);
  my $t = `cat $f`;
  $t =~ s/^\s+//;
  $t =~ s/\s+$//;
  return int($t + .5 * ($t <=> 0));
}

1;