diff --git a/obmc/sensors.py b/obmc/sensors.py
index 8e21a6e..c0aa0fe 100644
--- a/obmc/sensors.py
+++ b/obmc/sensors.py
@@ -40,95 +40,6 @@
         return self.Get(SensorValue.IFACE_NAME, 'value')
 
 
-class SensorThresholds(DbusProperties):
-    IFACE_NAME = 'org.openbmc.SensorThresholds'
-
-    def __init__(self, bus, name):
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'thresholds_enabled',
-            False)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'emergency_enabled',
-            False)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'warning_upper',
-            0)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'warning_lower',
-            0)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'critical_upper',
-            0)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'critical_lower',
-            0)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'critical_lower',
-            0)
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'threshold_state',
-            "NORMAL")
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'worst_threshold_state',
-            "NORMAL")
-
-    @dbus.service.method(
-        IFACE_NAME, in_signature='', out_signature='')
-    def resetThresholdState(self):
-        self.Set(
-            SensorThresholds.IFACE_NAME,
-            'worst_threshold_state',
-            "NORMAL")
-
-    def check_thresholds(self, value):
-        iface = SensorThresholds.IFACE_NAME
-        if (self.Get(iface, 'thresholds_enabled') is False):
-            return False
-        rtn = False
-        current_state = "NORMAL"
-        if (value >= self.properties[iface]['critical_upper']):
-            current_state = "CRITICAL"
-            rtn = True
-        elif (value <= self.properties[iface]['critical_lower']):
-            current_state = "CRITICAL"
-            rtn = True
-        elif (value >= self.properties[iface]['warning_upper']):
-            current_state = "WARNING"
-            rtn = True
-        elif (value <= self.properties[iface]['warning_lower']):
-            current_state = "WARNING"
-            rtn = True
-
-        if self.Get(iface, 'threshold_state') != current_state and \
-                current_state == "CRITICAL" and \
-                self.Get(iface, 'emergency_enabled') is True:
-            message = type(self).__name__ + \
-                ' SensorThresholds.check_thresholds(): trigger emergency' + \
-                ' signal, sensor value: ' + str(value)
-            self.Emergency(message)
-
-        self.Set(iface, 'threshold_state', current_state)
-        worst = self.properties[iface]['worst_threshold_state']
-        if (current_state == "CRITICAL" or
-           (current_state == "WARNING" and worst != "CRITICAL")):
-            self.Set(iface, 'worst_threshold_state', current_state)
-
-        return rtn
-
-    @dbus.service.signal(IFACE_NAME, signature='s')
-    def Emergency(self, message):
-        pass
-
-
 class VirtualSensor(SensorValue):
     def __init__(self, bus, name):
         DbusProperties.__init__(self)
@@ -136,76 +47,9 @@
         dbus.service.Object.__init__(self, bus, name)
 
 
-class HwmonSensor(SensorValue, SensorThresholds):
-    IFACE_NAME = 'org.openbmc.HwmonSensor'
-
-    def __init__(self, bus, name):
-        DbusProperties.__init__(self)
-        SensorValue.__init__(self, bus, name)
-        SensorThresholds.__init__(self, bus, name)
-        self.Set(HwmonSensor.IFACE_NAME, 'scale', 1)
-        self.Set(HwmonSensor.IFACE_NAME, 'offset', 0)
-        self.Set(HwmonSensor.IFACE_NAME, 'filename', '')
-        self.value_dirty = False
-
-        # need to cache value to know if changed
-        self.value = None
-        dbus.service.Object.__init__(self, bus, name)
-
-    @dbus.service.method(
-        SensorValue.IFACE_NAME, in_signature='v', out_signature='')
-    def setValue(self, value):
-        self.value_dirty = True
-        SensorValue.setValue(self, value)
-
-    ## Called by sensor process to update value from polling
-    ## if returns not None, then sensor process will update hwmon value
-    @dbus.service.method(
-        IFACE_NAME, in_signature='v', out_signature='(bv)')
-    def setByPoll(self, value):
-        scale = self.properties[HwmonSensor.IFACE_NAME]['scale']
-        offset = self.properties[HwmonSensor.IFACE_NAME]['offset']
-        try:
-            adjust = self.properties[HwmonSensor.IFACE_NAME]['adjust']
-            if adjust == 0:
-                adjust = 1
-        except:
-            adjust = 1
-
-        if self.value_dirty:
-            ## new value externally set, so just return to hwmon
-            ## process to write value
-            self.value_dirty = False
-            val = int((
-                self.properties[SensorValue.IFACE_NAME]['value']
-                - offset) * adjust)
-            return [True, val]
-        else:
-            # Keep the val as integer. adjust may be floating point
-            val = int(value/adjust + offset)
-            if (val != self.value):
-                SensorValue.setValue(self, val)
-                # scale the value to check threshold
-                self.check_thresholds(val * (10 ** scale))
-                self.value = val
-
-            return [False, 0]
-
-
 CONTROL_IFACE = 'org.openbmc.Control'
 
 
-class PowerCap(VirtualSensor):
-    def __init__(self, bus, name):
-        VirtualSensor.__init__(self, bus, name)
-        SensorValue.setValue(self, 0)
-
-    ##override setValue method
-    @dbus.service.method(
-        SensorValue.IFACE_NAME, in_signature='v', out_signature='')
-    def setValue(self, value):
-         raise Exception("ERROR: Setting Power Cap is not allowed")
-
 class BootProgressSensor(VirtualSensor):
     def __init__(self, bus, name):
         VirtualSensor.__init__(self, bus, name)
@@ -236,39 +80,6 @@
         pass
 
 
-class OccStatusSensor(VirtualSensor):
-    def __init__(self, bus, name, sysfs=None):
-        ## default path. can be override
-        if sysfs is None:
-            self.sysfs_attr = "/sys/class/i2c-adapter/i2c-3/3-0050/online"
-        else:
-            self.sysfs_attr = sysfs
-        VirtualSensor.__init__(self, bus, name)
-        self.setValue("Disabled")
-        bus.add_signal_receiver(
-            self.SystemStateHandler, signal_name="GotoSystemState")
-
-    def SystemStateHandler(self, state):
-        if (state == "HOST_POWERED_OFF"):
-            self.setValue("Disabled")
-
-    ##override setValue method
-    @dbus.service.method(
-        SensorValue.IFACE_NAME, in_signature='v', out_signature='')
-    def setValue(self, value):
-        if (value == "Enabled"):
-            print "Installing OCC device"
-            os.system("echo 1 > " + self.sysfs_attr)
-        else:
-            print "Deleting OCC device"
-            os.system("echo 0 > " + self.sysfs_attr)
-        SensorValue.setValue(self, value)
-
-    @dbus.service.signal(CONTROL_IFACE, signature='s')
-    def GotoSystemState(self, state):
-        pass
-
-
 class BootCountSensor(VirtualSensor):
     def __init__(self, bus, name):
         VirtualSensor.__init__(self, bus, name)
