<commit_before># == Schema Information
#
# Table name: sensor_devices
#
#  id      :integer          not null, primary key
#  sensors :text
#

class SensorDevice < ActiveRecord::Base

  inherit DeviceBase
  include WlanDevice

  acts_as :device

  # [{ type: <sensor-type>, min: minimum value, max: maximum value }, ...]
  serialize :sensors

  def self.attr_accessible
    Device.attr_accessible
  end

  def self.small_icon()
    '16/thermometer.png'
  end

  def self.large_icon()
    '32/thermometer.png'
  end

  def update_attributes_from_registration params
    num_sensors = params[0]
    sensor_defs = params[1..-1].in_groups_of(3).take num_sensors
    update_attributes sensors: sensor_defs.each_with_index.map { |d| { type: d[0], min: d[1], max: d[2] } }
  end

  def states
    @states ||= Array.new(sensors.count, 0.0)
  end

  def update<commit_msg>fix: Convert sensor device registration parameters to integer<commit_after># == Schema Information
#
# Table name: sensor_devices
#
#  id      :integer          not null, primary key
#  sensors :text
#

class SensorDevice < ActiveRecord::Base

  inherit DeviceBase
  include WlanDevice

  acts_as :device

  # [{ type: <sensor-type>, min: minimum value, max: maximum value }, ...]
  serialize :sensors

  def self.attr_accessible
    Device.attr_accessible
  end

  def self.small_icon()
    '16/thermometer.png'
  end

  def self.large_icon()
    '32/thermometer.png'
  end

  def update_attributes_from_registration params
    num_sensors = params[0].to_i
    sensor_defs = params[1..-1].in_groups_of(3).take num_sensors
    update_attributes sensors: sensor_defs.each_with_index.map { |d| { type: d[0].to_i, min: d[1].to_i, max: d[2].to_i } }
  end

  def states
    @states ||= Array.new(sensors.count, 0.0)
  end

  def update
{'fraction_non_alphanumeric': 0.1109253065774805, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 3.3995098039215685, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3499977', 'n_tokens_mistral': 641, 'n_tokens_neox': 600, 'n_words': 150}