support InterfaceAdded signal
diff --git a/bin/Openbmc.py b/bin/Openbmc.py
index b370d8b..b87fec8 100755
--- a/bin/Openbmc.py
+++ b/bin/Openbmc.py
@@ -5,17 +5,11 @@
 GPIO_DEV = '/sys/class/gpio'
 BUS = "system"
 
-ENUMS = {
-	'org.openbmc.SensorIntegerThreshold.state' : 
-		['NOT_SET','NORMAL','LOWER_CRITICAL','LOWER_WARNING','UPPER_WARNING','UPPER_CRITICAL'],
-}
-
 def getSystemName():
 	#use filename as system name, strip off path and ext
 	parts = __file__.replace('.pyc','').replace('.py','').split('/')
 	return parts[len(parts)-1]
 
-
 def getDBus():
 	bus = None
 	if (BUS == "session"):
@@ -24,18 +18,11 @@
 		bus = dbus.SystemBus()
 	return bus
 
-
-def getManagerInterface(bus,manager):
-	bus_name = "org.openbmc.managers."+manager
-	obj_name = "/org/openbmc/managers/"+manager
-	obj = bus.get_object(bus_name,obj_name)
-	return dbus.Interface(obj,bus_name)
-
-
 class DbusProperties(dbus.service.Object):
 	def __init__(self):
 		dbus.service.Object.__init__(self)
 		self.properties = {}
+		self.object_path = ""
 
 	@dbus.service.method(dbus.PROPERTIES_IFACE,
 		in_signature='ss', out_signature='v')
@@ -94,17 +81,66 @@
 		if (value_changed == True):
 			self.PropertiesChanged(interface_name, prop_dict, [])
 	
-
 	@dbus.service.signal(dbus.PROPERTIES_IFACE,
 		signature='sa{sv}as')
 	def PropertiesChanged(self, interface_name, changed_properties,
 		invalidated_properties):
 		pass
 
+class DbusObjectManager(dbus.service.Object):
+	def __init__(self):
+		dbus.service.Object.__init__(self)
+		self.objects = {}
+
+	def add(self,object_path,obj):
+		self.objects[object_path] = obj
+		self.InterfacesAdded(object_path,obj.properties)
+
+	def remove(self,object_path):
+		obj = self.objects.pop(object_path,None)
+		obj.remove_from_connection()
+		self.InterfacesRemoved(object_path,obj.properties.keys())
+
+	def get(self,object_path):
+		return self.objects[object_path]
+
+	@dbus.service.method("org.freedesktop.DBus.ObjectManager",
+		in_signature='', out_signature='a{oa{sa{sv}}}')
+	def GetManagedObjects(self):
+		data = {}
+		for objpath in self.objects.keys():
+			data[objpath] = self.objects[objpath].properties
+		return data
+
+	@dbus.service.signal("org.freedesktop.DBus.ObjectManager",
+		signature='oa{sa{sv}}')
+	def InterfacesAdded(self,object_path,properties):
+		self.ObjectAdded(object_path,"")
+
+	@dbus.service.signal("org.freedesktop.DBus.ObjectManager",
+		signature='oas')
+	def InterfacesRemoved(self,object_path,interfaces):
+		pass
+
+	## Legacy support, need to eventually refactor out
 	@dbus.service.signal("org.openbmc.Object.ObjectMapper",
 		signature='ss')
 	def ObjectAdded(self,object_path,interface_name):
 		pass
 
+	## flattens interfaces
+	@dbus.service.method('org.openbmc.Object.Enumerate',
+		in_signature='', out_signature='a{sa{sv}}')
+	def enumerate(self):
+		data = {}
+		for objpath in self.objects.keys():
+			props = self.objects[objpath].properties
+			data[objpath] = { }
+			for iface in props.keys():
+				data[objpath].update(props[iface])
+				
+		return data
+		
+
 
 
diff --git a/bin/Sensors.py b/bin/Sensors.py
new file mode 100755
index 0000000..e2b79ac
--- /dev/null
+++ b/bin/Sensors.py
@@ -0,0 +1,202 @@
+#!/usr/bin/python -u
+
+import sys
+#from gi.repository import GObject
+import gobject
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import os
+import Openbmc
+
+## Abstract class, must subclass
+class SensorValue(Openbmc.DbusProperties):
+	IFACE_NAME = 'org.openbmc.SensorValue'
+	def __init__(self,bus,name):
+		#Openbmc.DbusProperties.__init__(self)
+		self.Set(SensorValue.IFACE_NAME,'units',"")
+		self.Set(SensorValue.IFACE_NAME,'error',False)
+		
+	@dbus.service.method(IFACE_NAME,
+		in_signature='v', out_signature='')
+	def setValue(self,value):
+		self.Set(SensorValue.IFACE_NAME,'value',value)
+
+	@dbus.service.method(IFACE_NAME,
+		in_signature='', out_signature='v')
+	def getValue(self):
+		return self.Get(SensorValue.IFACE_NAME,'value')
+
+class SensorThresholds(Openbmc.DbusProperties):
+	IFACE_NAME = 'org.openbmc.SensorThresholds'
+	def __init__(self,bus,name):
+		self.Set(SensorThresholds.IFACE_NAME,'thresholds_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') == 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
+		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
+
+class VirtualSensor(SensorValue):
+	def __init__(self,bus,name):
+		Openbmc.DbusProperties.__init__(self)
+		SensorValue.__init__(self,bus,name)
+		dbus.service.Object.__init__(self,bus,name)
+
+class HwmonSensor(SensorValue,SensorThresholds):
+	IFACE_NAME = 'org.openbmc.HwmonSensor'
+	def __init__(self,bus,name):
+		Openbmc.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']
+		if (self.value_dirty == True):
+			## new value externally set, so just return to hwmon
+			## process to write value
+			self.value_dirty = False
+			val = (self.properties[SensorValue.IFACE_NAME]['value']-offset) * scale
+			return [True,val]
+		else:
+			val = (value/scale) + offset
+			if (val != self.value):
+				SensorValue.setValue(self,val)
+				self.check_thresholds(val)
+				self.value = val
+
+			return [False,0]
+		
+CONTROL_IFACE = 'org.openbmc.Control'
+class HostStatusSensor(VirtualSensor):
+	def __init__(self,bus,name):
+		VirtualSensor.__init__(self,bus,name)
+		self.setValue("Off")
+
+	##override setValue method
+	@dbus.service.method(SensorValue.IFACE_NAME,
+		in_signature='v', out_signature='')
+	def setValue(self,value):
+		SensorValue.setValue(self,value)
+			
+	@dbus.service.signal(CONTROL_IFACE,signature='s')
+	def GotoSystemState(self,state):
+		pass
+		
+class BootProgressSensor(VirtualSensor):
+	def __init__(self,bus,name):
+		VirtualSensor.__init__(self,bus,name)
+		self.setValue("Off")
+		bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState")
+
+	def SystemStateHandler(self,state):
+		if (state == "HOST_POWERED_OFF"):
+			self.setValue("Off")
+
+
+	##override setValue method
+	@dbus.service.method(SensorValue.IFACE_NAME,
+		in_signature='v', out_signature='')
+	def setValue(self,value):
+		SensorValue.setValue(self,value)
+		if (value == "FW Progress, Starting OS"):
+			self.GotoSystemState("HOST_BOOTED")
+			
+	@dbus.service.signal(CONTROL_IFACE,signature='s')
+	def GotoSystemState(self,state):
+		pass
+		
+class OccStatusSensor(VirtualSensor):
+	def __init__(self,bus,name):
+		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 occ-i2c 0x50 >  /sys/bus/i2c/devices/i2c-3/new_device")
+			os.system("echo occ-i2c 0x51 >  /sys/bus/i2c/devices/i2c-3/new_device")
+		else:
+			print "Deleting OCC device"
+			os.system("echo 0x50 >  /sys/bus/i2c/devices/i2c-3/delete_device")
+			os.system("echo 0x51 >  /sys/bus/i2c/devices/i2c-3/delete_device")
+
+
+		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)
+		self.setValue(0)
+
+class OperatingSystemStatusSensor(VirtualSensor):
+	def __init__(self,bus,name):
+		VirtualSensor.__init__(self,bus,name)
+		self.setValue("Off")
+	
+
diff --git a/bin/chassis_control.py b/bin/chassis_control.py
index 6a3b9f5..aa656fd 100755
--- a/bin/chassis_control.py
+++ b/bin/chassis_control.py
@@ -18,10 +18,11 @@
 
 BOOTED = 100
 
-class ChassisControlObject(Openbmc.DbusProperties):
+class ChassisControlObject(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 	def __init__(self,bus,name):
 		self.dbus_objects = { }
 		Openbmc.DbusProperties.__init__(self)
+		Openbmc.DbusObjectManager.__init__(self)
 		dbus.service.Object.__init__(self,bus,name)
 		## load utilized objects
 		self.dbus_objects = {
@@ -51,7 +52,7 @@
 		self.Set(DBUS_NAME,"uuid",str(uuid.uuid1()))
 		self.Set(DBUS_NAME,"reboot",0)
 		self.Set(DBUS_NAME,"power_policy",0)	
-		self.Set(DBUS_NAME,"last_system_state","")	
+		self.Set(DBUS_NAME,"last_system_state","")
 
 		bus.add_signal_receiver(self.power_button_signal_handler, 
 					dbus_interface = "org.openbmc.Button", signal_name = "Released", 
@@ -63,7 +64,7 @@
     		bus.add_signal_receiver(self.host_watchdog_signal_handler, 
 					dbus_interface = "org.openbmc.Watchdog", signal_name = "WatchdogError")
 		bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState")
-		self.ObjectAdded(name,CONTROL_INTF)
+		self.InterfacesAdded(name,self.properties)
 
 
 	def getInterface(self,name):
diff --git a/bin/fan_control.py b/bin/fan_control.py
index 7a75d62..1a528fd 100755
--- a/bin/fan_control.py
+++ b/bin/fan_control.py
@@ -12,7 +12,7 @@
 OBJ_PATH = '/org/openbmc/control/fans'
 IFACE_NAME = 'org.openbmc.control.Fans'
 
-FAN_BUS = 'org.openbmc.sensors.hwmon'
+FAN_BUS = 'org.openbmc.Sensors'
 FAN_OBJS = [
 	'/org/openbmc/sensors/speed/fan0',
 	'/org/openbmc/sensors/speed/fan1',
@@ -23,11 +23,11 @@
 ]
 FAN_IFACE = 'org.openbmc.SensorValue'
 
-class FanControl(Openbmc.DbusProperties):
+class FanControl(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 	def __init__(self,bus,name):
 		Openbmc.DbusProperties.__init__(self)
+		Openbmc.DbusObjectManager.__init__(self)
 		dbus.service.Object.__init__(self,bus,name)
-		self.ObjectAdded(name,IFACE_NAME)
 		self.Set(IFACE_NAME,"floor",250)
 		self.Set(IFACE_NAME,"ceiling",255)
 		self.fan_intf = []
@@ -36,6 +36,7 @@
 			print "Initializing fan: "+fan
 			obj = bus.get_object(FAN_BUS,fan)
 			self.fan_intf.append(dbus.Interface(obj,FAN_IFACE))
+		self.InterfacesAdded(name,self.properties)
 			
 	@dbus.service.method(DBUS_NAME,
 		in_signature='', out_signature='')
diff --git a/bin/hwmon.py b/bin/hwmon.py
new file mode 100755
index 0000000..513c760
--- /dev/null
+++ b/bin/hwmon.py
@@ -0,0 +1,153 @@
+#!/usr/bin/python -u
+
+import sys
+import os
+import gobject
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import Openbmc
+from Sensors import SensorValue as SensorValue
+from Sensors import HwmonSensor as HwmonSensor
+from Sensors import SensorThresholds as SensorThresholds
+if (len(sys.argv) < 2):
+	print "Usage:  sensors_hwmon.py [system name]"
+	exit(1)
+
+System = __import__(sys.argv[1])
+
+SENSOR_BUS = 'org.openbmc.Sensors'
+SENSOR_PATH = '/org/openbmc/sensors'
+DIR_POLL_INTERVAL = 10000
+HWMON_PATH = '/sys/class/hwmon'
+
+## static define which interface each property is under
+## need a better way that is not slow
+IFACE_LOOKUP = {
+	'units' : SensorValue.IFACE_NAME,
+	'scale' : HwmonSensor.IFACE_NAME,
+	'offset' : HwmonSensor.IFACE_NAME,
+	'critical_upper' : SensorThresholds.IFACE_NAME,
+	'warning_upper' : SensorThresholds.IFACE_NAME,
+	'critical_lower' : SensorThresholds.IFACE_NAME,
+	'warning_lower' : SensorThresholds.IFACE_NAME,
+}
+
+class Hwmons():
+	def __init__(self,bus):
+		self.sensors = { }
+		self.hwmon_root = { }
+		self.scanDirectory()
+		gobject.timeout_add(DIR_POLL_INTERVAL, self.scanDirectory)   
+
+	def readAttribute(self,filename):
+		val = ""
+		with open(filename, 'r') as f:
+			for line in f:
+				val = line.rstrip('\n')
+		return val
+
+	def writeAttribute(self,filename,value):
+		with open(filename, 'w') as f:
+			f.write(str(value)+'\n')
+
+
+	def poll(self,objpath,attribute):
+		try:
+			raw_value = int(self.readAttribute(attribute))
+			obj = bus.get_object(SENSOR_BUS,objpath)
+			intf = dbus.Interface(obj,HwmonSensor.IFACE_NAME)
+			rtn = intf.setByPoll(raw_value)
+			if (rtn[0] == True):
+				self.writeAttribute(attribute,rtn[1])
+		except:
+			print "HWMON: Attibute no longer exists: "+attribute
+			return False
+
+
+		return True
+
+
+	def addObject(self,dpath,instance_name,attribute):
+		hwmon = System.HWMON_CONFIG[instance_name][attribute]
+		objsuf = hwmon['object_path']
+		try:
+			if (objsuf.find('<label>') > -1):
+				label_file = attribute.replace('_input','_label')
+				label = self.readAttribute(dpath+label_file)
+				objsuf = objsuf.replace('<label>',label)
+		except Exception as e:
+			print e
+			return
+
+		objpath = SENSOR_PATH+'/'+objsuf
+		spath = dpath+attribute
+		if (self.sensors.has_key(objpath) == False):
+			if os.path.isfile(spath):
+				print "HWMON add: "+objpath+" : "+spath
+				obj = bus.get_object(SENSOR_BUS,SENSOR_PATH)
+				intf = dbus.Interface(obj,SENSOR_BUS)
+				intf.register("HwmonSensor",objpath)
+			
+				obj = bus.get_object(SENSOR_BUS,objpath)
+				intf = dbus.Interface(obj,dbus.PROPERTIES_IFACE)
+				intf.Set(HwmonSensor.IFACE_NAME,'filename',spath)
+				
+				## check if one of thresholds is defined to know
+				## whether to enable thresholds or not
+				if (hwmon.has_key('critical_upper')):
+					intf.Set(SensorThresholds.IFACE_NAME,'thresholds_enabled',True)
+
+				for prop in hwmon.keys():
+					if (IFACE_LOOKUP.has_key(prop)):
+						intf.Set(IFACE_LOOKUP[prop],prop,hwmon[prop])
+						print "Setting: "+prop+" = "+str(hwmon[prop])
+
+				self.sensors[objpath]=True
+				self.hwmon_root[dpath].append(objpath)
+				gobject.timeout_add(hwmon['poll_interval'],self.poll,objpath,spath)
+	
+	def scanDirectory(self):
+	 	devices = os.listdir(HWMON_PATH)
+		found_hwmon = {}
+		for d in devices:
+			dpath = HWMON_PATH+'/'+d+'/'
+			found_hwmon[dpath] = True
+			if (self.hwmon_root.has_key(dpath) == False):
+				self.hwmon_root[dpath] = []
+			## the instance name is a soft link
+			instance_name = os.path.realpath(dpath+'device').split('/').pop()
+			if (System.HWMON_CONFIG.has_key(instance_name)):
+	 			for attribute in System.HWMON_CONFIG[instance_name].keys():
+					self.addObject(dpath,instance_name,attribute)
+			else:
+				print "WARNING: Unhandled hwmon: "+dpath
+	
+
+		for k in self.hwmon_root.keys():
+			if (found_hwmon.has_key(k) == False):
+				## need to remove all objects associated with this path
+				print "Removing: "+k
+				for objpath in self.hwmon_root[k]:
+					if (self.sensors.has_key(objpath) == True):
+						print "HWMON remove: "+objpath
+						self.sensors.pop(objpath,None)
+						obj = bus.get_object(SENSOR_BUS,SENSOR_PATH)
+						intf = dbus.Interface(obj,SENSOR_BUS)
+						intf.delete(objpath)
+
+				self.hwmon_root.pop(k,None)
+				
+		return True
+
+			
+if __name__ == '__main__':
+	
+	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+	bus = Openbmc.getDBus()
+	root_sensor = Hwmons(bus)
+	mainloop = gobject.MainLoop()
+
+	print "Starting HWMON sensors"
+	mainloop.run()
+
diff --git a/bin/inventory_items.py b/bin/inventory_items.py
index 865a717..6320f90 100755
--- a/bin/inventory_items.py
+++ b/bin/inventory_items.py
@@ -18,28 +18,15 @@
 
 
 INTF_NAME = 'org.openbmc.InventoryItem'
-DBUS_NAME = 'org.openbmc.managers.Inventory'
-ENUM_INTF = 'org.openbmc.Object.Enumerate'
-
+DBUS_NAME = 'org.openbmc.Inventory'
 FRUS = System.FRU_INSTANCES
 
-class Inventory(Openbmc.DbusProperties):
+class Inventory(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 	def __init__(self,bus,name):
+		Openbmc.DbusProperties.__init__(self)
+		Openbmc.DbusObjectManager.__init__(self)
 		dbus.service.Object.__init__(self,bus,name)
-		self.objects = [ ]
-		self.ObjectAdded(name,ENUM_INTF)		
-
-	def addItem(self,item):
-		self.objects.append(item)
-
-	@dbus.service.method(ENUM_INTF,
-		in_signature='', out_signature='a{sa{sv}}')
-	def enumerate(self):
-		tmp_obj = {}
-		for item in self.objects:
-			tmp_obj[str(item.name)]=item.GetAll(INTF_NAME)
-		return tmp_obj
-			
+		self.InterfacesAdded(name,self.properties)
 
 
 class InventoryItem(Openbmc.DbusProperties):
@@ -59,7 +46,6 @@
 			data['version'] = ''
 
 		self.SetMultiple(INTF_NAME,data)
-		self.ObjectAdded(name,INTF_NAME)		
 		
 		
 	@dbus.service.method(INTF_NAME,
@@ -98,10 +84,9 @@
     obj_parent = Inventory(bus, '/org/openbmc/inventory')
 
     for f in FRUS.keys():
-	print f
 	obj_path=f.replace("<inventory_root>",System.INVENTORY_ROOT)
     	obj = InventoryItem(bus,obj_path,FRUS[f])
-	obj_parent.addItem(obj)
+	obj_parent.add(obj_path,obj)
 
     	## TODO:  this is a hack to update bmc inventory item with version
     	## should be done by flash object
diff --git a/bin/obmcutil b/bin/obmcutil
index 0dd18df..e63fa27 100755
--- a/bin/obmcutil
+++ b/bin/obmcutil
@@ -89,8 +89,8 @@
 		'method' : 'getSystemState',
 	},
 	'bootprogress' : { 
-		'bus_name' : 'org.openbmc.sensor.Power8Virtual',
-		'object_name' : '/org/openbmc/sensor/virtual/BootProgress',
+		'bus_name' : 'org.openbmc.Sensors',
+		'object_name' : '/org/openbmc/sensors/host/BootProgress',
 		'interface_name' : 'org.openbmc.SensorValue'
 	},
 	'biosupdate' : {
@@ -116,13 +116,13 @@
 		'interface_name' : 'org.openbmc.Flash',
 	},
 	'getinventory' : {
-		'bus_name' : 'org.openbmc.managers.Inventory',
+		'bus_name' : 'org.openbmc.Inventory',
 		'object_name' : '/org/openbmc/inventory',
 		'interface_name' : 'org.openbmc.Object.Enumerate',
 		'method' : 'enumerate'
 	},
 	'getsensors' : {
-		'bus_name' : 'org.openbmc.managers.Sensors',
+		'bus_name' : 'org.openbmc.Sensors',
 		'object_name' : '/org/openbmc/sensors',
 		'interface_name' : 'org.openbmc.Object.Enumerate',
 		'method' : 'enumerate'
@@ -143,7 +143,7 @@
 bus = dbus.SystemBus()
 
 
-if (len(sys.argv) == 1 or sys.argv[1] == "-h"):
+if (len(sys.argv) == 1 or sys.argv[1] == "-h" or dbus_objects.has_key(sys.argv[1])==False):
 	print "Usage: obmcutil [command] [[method] [*args]]"
 	print "\tIf [method] is blank, then all properties are printed\n"
 	print "Available commands:"
diff --git a/bin/sensor_manager.py b/bin/sensor_manager.py
deleted file mode 100755
index f1af961..0000000
--- a/bin/sensor_manager.py
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/python -u
-
-import sys
-#from gi.repository import GObject
-import gobject
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-
-if (len(sys.argv) < 2):
-	print "Usage:  sensor_manager.py [system name]"
-	exit(1)
-System = __import__(sys.argv[1])
-import Openbmc
-
-DBUS_NAME = 'org.openbmc.managers.Sensors'
-OBJ_NAME = '/org/openbmc/sensors'
-ENUM_INTF = 'org.openbmc.Object.Enumerate'
-
-class SensorManager(Openbmc.DbusProperties):
-	def __init__(self,bus,name):
-		dbus.service.Object.__init__(self,bus,name)
-		bus.add_signal_receiver(self.SensorChangedHandler,
-					dbus_interface = 'org.openbmc.SensorValue', 
-					signal_name = 'Changed', path_keyword='path')
-		bus.add_signal_receiver(self.SensorErrorHandler,
-					dbus_interface = 'org.openbmc.SensorValue', 
-					signal_name = 'Error', path_keyword='path')
-		bus.add_signal_receiver(self.NormalThreshold,
-					dbus_interface = 'org.openbmc.SensorThreshold', 
-					signal_name = 'Normal', path_keyword='path')
-		bus.add_signal_receiver(self.WarningThreshold,
-					dbus_interface = 'org.openbmc.SensorThreshold', 
-					signal_name = 'Warning', path_keyword='path')
-		bus.add_signal_receiver(self.CriticalThreshold,
-					dbus_interface = 'org.openbmc.SensorThreshold', 
-					signal_name = 'Critical', path_keyword='path')
-
-		self.sensor_cache = {}
-		self.ObjectAdded(name,DBUS_NAME);
-		self.ObjectAdded(name,ENUM_INTF);
-
-	@dbus.service.method(ENUM_INTF,
-		in_signature='', out_signature='a{sa{sv}}')
-	def enumerate(self):
-		return self.sensor_cache;
-	
-	
-	@dbus.service.method(DBUS_NAME,
-		in_signature='s', out_signature='v')
-	def getSensor(self,path):
-		val = 0
-		if (self.sensor_cache.has_key(path) == True):
-			val = self.sensor_cache[path]['value']
-		else:
-			print "ERROR: Unknown sensor: "+path
-		return val
-	
-	## Signal handlers
-	def SensorErrorHandler(self,path = None):
-		self.initSensorEntry(path)
-		self.sensor_cache[path]['error'] = True
-
-	def SensorChangedHandler(self,value,units,path = None):
-		self.initSensorEntry(path)
-		self.sensor_cache[path]['value'] = value
-		self.sensor_cache[path]['units'] = units
-
-	@dbus.service.signal(DBUS_NAME)
-	def CriticalThreshold(self, path = None):
-		print "Critical: "+path
-		self.initSensorEntry(path)
-		self.sensor_cache[path]['threshold'] = "CRITICAL"
-
-	@dbus.service.signal(DBUS_NAME)
-	def WarningThreshold(self, path = None):
-		print "Warning:"+path
-		self.initSensorEntry(path)
-		self.sensor_cache[path]['threshold'] = "WARNING"
-
-	@dbus.service.signal(DBUS_NAME)
-	def NormalThreshold(self, path = None):
-		print "Normal: "+path
-		self.initSensorEntry(path)
-		self.sensor_cache[path]['threshold'] = "NORMAL"
-
-	def initSensorEntry(self,path):
-		if (self.sensor_cache.has_key(path) == False):
-			self.sensor_cache[path] = {}
-
-				
-if __name__ == '__main__':
-    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-    bus = Openbmc.getDBus()
-    name = dbus.service.BusName(DBUS_NAME,bus)
-    obj = SensorManager(bus,OBJ_NAME)
-    mainloop = gobject.MainLoop()
-
-    print "Running Sensor Manager"
-    mainloop.run()
-
diff --git a/bin/sensor_manager2.py b/bin/sensor_manager2.py
new file mode 100755
index 0000000..5e044f0
--- /dev/null
+++ b/bin/sensor_manager2.py
@@ -0,0 +1,69 @@
+#!/usr/bin/python -u
+
+import sys
+import os
+import gobject
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import Openbmc
+import Sensors
+
+DBUS_NAME = 'org.openbmc.Sensors'
+OBJ_PATH = '/org/openbmc/sensors'
+
+
+class SensorManager(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
+	def __init__(self,bus,name):
+		Openbmc.DbusProperties.__init__(self)
+		Openbmc.DbusObjectManager.__init__(self)
+		dbus.service.Object.__init__(self,bus,name)
+		self.InterfacesAdded(name,self.properties)
+
+	@dbus.service.method(DBUS_NAME,
+		in_signature='ss', out_signature='')
+	def register(self,object_name,obj_path):
+		if (self.objects.has_key(obj_path) == False):
+			print "Register: "+object_name+" : "+obj_path
+			sensor = eval('Sensors.'+object_name+'(bus,obj_path)')
+			self.add(obj_path,sensor)
+
+	@dbus.service.method(DBUS_NAME,
+		in_signature='s', out_signature='')
+	def delete(self,obj_path):
+		if (self.objects.has_key(obj_path) == True):
+			print "Delete: "+obj_path
+			self.remove(obj_path)
+	
+	def SensorChange(self,value,path=None):
+		if (self.objects.has_key(path)):
+			self.objects[path].setValue(value)
+		else:
+			print "ERROR: Sensor not found: "+path
+			
+if __name__ == '__main__':
+	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+	bus = Openbmc.getDBus()
+	name = dbus.service.BusName(DBUS_NAME,bus)
+	root_sensor = SensorManager(bus,OBJ_PATH)
+
+
+	## instantiate non-polling sensors
+	## these don't need to be in seperate process
+	## TODO: this should not be hardcoded
+
+	obj_path = OBJ_PATH+"/host/HostStatus"
+	root_sensor.add(obj_path,Sensors.HostStatusSensor(bus,obj_path))
+	obj_path = OBJ_PATH+"/host/BootProgress"
+	root_sensor.add(obj_path,Sensors.BootProgressSensor(bus,obj_path))
+	obj_path = OBJ_PATH+"/host/OccStatus"
+	root_sensor.add(obj_path,Sensors.OccStatusSensor(bus,obj_path))
+	obj_path = OBJ_PATH+"/host/BootCount"
+	root_sensor.add(obj_path,Sensors.BootCountSensor(bus,obj_path))
+	obj_path = OBJ_PATH+"/host/OperatingSystemStatus"
+	root_sensor.add(obj_path,Sensors.OperatingSystemStatusSensor(bus,obj_path))
+
+	mainloop = gobject.MainLoop()
+	print "Starting sensor manager"
+	mainloop.run()
+
diff --git a/bin/sensors_hwmon.py b/bin/sensors_hwmon.py
deleted file mode 100755
index 3574b60..0000000
--- a/bin/sensors_hwmon.py
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/python -u
-
-import sys
-import os
-import gobject
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-import Openbmc
-if (len(sys.argv) < 2):
-	print "Usage:  sensors_hwmon.py [system name]"
-	exit(1)
-
-System = __import__(sys.argv[1])
-
-DBUS_NAME = 'org.openbmc.sensors.hwmon'
-OBJ_PATH = '/org/openbmc/sensors'
-DIR_POLL_INTERVAL = 10000
-HWMON_PATH = '/sys/class/hwmon'
-
-class SensorValue(Openbmc.DbusProperties):
-	IFACE_NAME = 'org.openbmc.SensorValue'
-	def __init__(self,bus,name):
-		Openbmc.DbusProperties.__init__(self)
-		self.Set(SensorValue.IFACE_NAME,'units',"")
-		dbus.service.Object.__init__(self,bus,name)
-		
-	@dbus.service.method(IFACE_NAME,
-		in_signature='v', out_signature='')
-	def setValue(self,value):
-		changed = False
-		try:
-			old_value = self.Get(SensorValue.IFACE_NAME,'value')
-			if (value != old_value):
-				changed = True
-		except:
-			changed = True
-
-		if (changed == True):
-			self.Set(SensorValue.IFACE_NAME,'value',value)
-			self.Changed(self.getValue(),self.getUnits())
-
-
-
-	@dbus.service.method(IFACE_NAME,
-		in_signature='', out_signature='v')
-	def getValue(self):
-		return self.Get(SensorValue.IFACE_NAME,'value')
-
-	@dbus.service.method(IFACE_NAME,
-		in_signature='', out_signature='s')
-	def getUnits(self):
-		return self.Get(SensorValue.IFACE_NAME,'units')
-
-	@dbus.service.signal(IFACE_NAME,signature='vs')
-	def Changed(self,value,units):
-		pass
-
-def readAttribute(filename):
-	val = ""
-	with open(filename, 'r') as f:
-		for line in f:
-			val = line.rstrip('\n')
-	return val
-
-class HwmonSensor(SensorValue):
-	def __init__(self, bus ,name, attribute ,poll_interval ,units, scale):
-		SensorValue.__init__(self,bus,name)
-		self.attribute = attribute
-		self.scale = 1
-		if scale > 0:
-			self.scale = scale
-		
-		self.Set(SensorValue.IFACE_NAME,'units',units)
-		self.pollSensor()
-
-		if (poll_interval > 0):
-			gobject.timeout_add(poll_interval, self.pollSensor)  
-		else:
-			print "ERROR HWMON: poll_interval must be > 0"
-		self.ObjectAdded(name,SensorValue.IFACE_NAME)
-			
-
-	def pollSensor(self):
-		try:
-			with open(self.attribute, 'r') as f:
-				for line in f:
-					val = int(line.rstrip('\n'))/self.scale
-					SensorValue.setValue(self,val)
-		except:
-			print "Attribute no longer exists: "+self.attribute
-			return False
-
-		return True
-
-	@dbus.service.method(SensorValue.IFACE_NAME,
-		in_signature='v', out_signature='')
-	def setValue(self,value):
-		try:
-			with open(self.attribute, 'w') as f:
-				val = int(value*self.scale)
-				f.write(str(val)+'\n')
-				SensorValue.setValue(self,value)
-		except Exception as e:
-			print e
-			print "Unable to write: "+self.attribute
-		
-		SensorValue.setValue(self,value)
-
-
-
-	
-
-class Sensors(Openbmc.DbusProperties):
-	def __init__(self,bus,name):
-		dbus.service.Object.__init__(self,bus,name)
-		self.sensors = { }
-		self.hwmon_root = { }
-		bus.add_signal_receiver(self.OccActiveHandler, 
-					dbus_interface = "org.openbmc.SensorValue", signal_name = "Changed", 
-					path="/org/openbmc/sensor/virtual/OccStatus" )
-
-		gobject.timeout_add(DIR_POLL_INTERVAL, self.scanDirectory)   
-		self.ObjectAdded(name,DBUS_NAME)
-
-	def OccActiveHandler(self,value,units):
-		print  "OCC "+value
-		if (value == "Enabled"):
-			print "Installing OCC device"
-			os.system("echo occ-i2c 0x50 >  /sys/bus/i2c/devices/i2c-3/new_device")
-			os.system("echo occ-i2c 0x51 >  /sys/bus/i2c/devices/i2c-3/new_device")
-		if (value == "Disabled"):
-			print "Deleting OCC device"
-			os.system("echo 0x50 >  /sys/bus/i2c/devices/i2c-3/delete_device")
-			os.system("echo 0x51 >  /sys/bus/i2c/devices/i2c-3/delete_device")
-
-	def addObject(self,dpath,instance_name,attribute):
-		hwmon = System.HWMON_CONFIG[instance_name][attribute]
-		objsuf = hwmon['object_path']
-		if (objsuf.find('<label>') > -1):
-			label_file = attribute.replace('_input','_label')
-			label = readAttribute(dpath+label_file)
-			objsuf = objsuf.replace('<label>',label)
-
-		objpath = OBJ_PATH+'/'+objsuf
-		spath = dpath+attribute
-		if (self.sensors.has_key(objpath) == False):
-			if os.path.isfile(spath):
-				print "HWMON add: "+objpath+" : "+spath
-				self.sensors[objpath]= HwmonSensor(bus,objpath,spath,
-					hwmon['poll_interval'],hwmon['units'],hwmon['scale'])
-				self.hwmon_root[dpath].append(objpath)
-	
-
-	def scanDirectory(self):
-	 	devices = os.listdir(HWMON_PATH)
-		found_hwmon = {}
-		for d in devices:
-			dpath = HWMON_PATH+'/'+d+'/'
-			found_hwmon[dpath] = True
-			if (self.hwmon_root.has_key(dpath) == False):
-				self.hwmon_root[dpath] = []
-			## the instance name is a soft link
-			instance_name = os.path.realpath(dpath+'device').split('/').pop()
-			if (System.HWMON_CONFIG.has_key(instance_name)):
-	 			for attribute in System.HWMON_CONFIG[instance_name].keys():
-					self.addObject(dpath,instance_name,attribute)
-			else:
-				print "WARNING: Unhandled hwmon: "+dpath
-	
-
-		for k in self.hwmon_root.keys():
-			if (found_hwmon.has_key(k) == False):
-				## need to remove all objects associated with this path
-				print "Removing: "+k
-				for objpath in self.hwmon_root[k]:
-					if (self.sensors.has_key(objpath) == True):
-						print "HWMON remove: "+objpath
-						obj = self.sensors.pop(objpath,None)
-						obj.remove_from_connection()
-				self.hwmon_root.pop(k,None)
-				
-		return True
-
-			
-if __name__ == '__main__':
-	
-	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-	bus = Openbmc.getDBus()
-	name = dbus.service.BusName(DBUS_NAME,bus)
-	root_sensor = Sensors(bus,OBJ_PATH)
-	mainloop = gobject.MainLoop()
-
-	print "Starting HWMON sensors"
-	mainloop.run()
-
diff --git a/bin/sensors_virtual_p8.py b/bin/sensors_virtual_p8.py
deleted file mode 100755
index adda301..0000000
--- a/bin/sensors_virtual_p8.py
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/usr/bin/python -u
-
-import sys
-#from gi.repository import GObject
-import gobject
-import dbus
-import dbus.service
-import dbus.mainloop.glib
-import Openbmc
-
-DBUS_NAME = 'org.openbmc.sensor.Power8Virtual'
-OBJ_PATH = '/org/openbmc/sensor/virtual/'
-
-class SensorValue(Openbmc.DbusProperties):
-	IFACE_NAME = 'org.openbmc.SensorValue'
-	def __init__(self,bus,name):
-		Openbmc.DbusProperties.__init__(self)
-		self.Set(SensorValue.IFACE_NAME,'units',"")
-		dbus.service.Object.__init__(self,bus,name)
-		self.ObjectAdded(name,SensorValue.IFACE_NAME)
-		
-	@dbus.service.method(IFACE_NAME,
-		in_signature='v', out_signature='')
-	def setValue(self,value):
-		changed = False
-		try:
-			old_value = self.Get(SensorValue.IFACE_NAME,'value')
-			if (value != old_value):
-				changed = True
-		except:
-			changed = True
-
-		if (changed == True):
-			self.Set(SensorValue.IFACE_NAME,'value',value)
-			self.Changed(self.getValue(),self.getUnits())
-
-
-
-	@dbus.service.method(IFACE_NAME,
-		in_signature='', out_signature='v')
-	def getValue(self):
-		return self.Get(SensorValue.IFACE_NAME,'value')
-
-	@dbus.service.method(IFACE_NAME,
-		in_signature='', out_signature='s')
-	def getUnits(self):
-		return self.Get(SensorValue.IFACE_NAME,'units')
-
-	@dbus.service.signal(IFACE_NAME,signature='vs')
-	def Changed(self,value,units):
-		pass
-
-class VirtualSensor(SensorValue):
-	def __init__(self,bus,name):
-		SensorValue.__init__(self,bus,name)
-
-		
-CONTROL_IFACE = 'org.openbmc.Control'
-class HostStatusSensor(VirtualSensor):
-	def __init__(self,bus,name):
-		VirtualSensor.__init__(self,bus,name)
-
-	##override setValue method
-	@dbus.service.method(SensorValue.IFACE_NAME,
-		in_signature='v', out_signature='')
-	def setValue(self,value):
-		SensorValue.setValue(self,value)
-		if (value == "BLAH"):
-			self.GotoSystemState("OS_BOOTED")
-			
-	@dbus.service.signal(CONTROL_IFACE,signature='s')
-	def GotoSystemState(self,state):
-		pass
-		
-class BootProgressSensor(VirtualSensor):
-	def __init__(self,bus,name):
-		VirtualSensor.__init__(self,bus,name)
-		self.setValue("Off")
-		bus.add_signal_receiver(self.SystemStateHandler,signal_name = "GotoSystemState")
-
-	def SystemStateHandler(self,state):
-		if (state == "HOST_POWERED_OFF"):
-			self.setValue("Off")
-
-
-	##override setValue method
-	@dbus.service.method(SensorValue.IFACE_NAME,
-		in_signature='v', out_signature='')
-	def setValue(self,value):
-		SensorValue.setValue(self,value)
-		if (value == "FW Progress, Starting OS"):
-			self.GotoSystemState("HOST_BOOTED")
-			
-	@dbus.service.signal(CONTROL_IFACE,signature='s')
-	def GotoSystemState(self,state):
-		pass
-		
-class OccActiveSensor(VirtualSensor):
-	def __init__(self,bus,name):
-		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):
-		SensorValue.setValue(self,value)
-			
-	@dbus.service.signal(CONTROL_IFACE,signature='s')
-	def GotoSystemState(self,state):
-		pass
-		
-				
-if __name__ == '__main__':
-	
-	sensors = {
-		'OperatingSystemStatus' : None,
-		'BootCount' : None,
-	}
-	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-	bus = Openbmc.getDBus()
-	name = dbus.service.BusName(DBUS_NAME,bus)
-	for instance in sensors.keys():
-		sensors[instance]= VirtualSensor(bus,OBJ_PATH+instance)
-
-	sensors['HostStatus'] = HostStatusSensor(bus,OBJ_PATH+"HostStatus")
-	sensors['BootProgress'] = BootProgressSensor(bus,OBJ_PATH+"BootProgress")
-	sensors['OccStatus'] = OccActiveSensor(bus,OBJ_PATH+"OccStatus")
-	mainloop = gobject.MainLoop()
-   
-	## Initialize sensors 
- 	sensors['HostStatus'].setValue("OFF")
-	sensors['OperatingSystemStatus'].setValue("OFF")
-	sensors['BootCount'].setValue(0)
-
-	print "Starting virtual sensors"
-	mainloop.run()
-
diff --git a/bin/system_manager.py b/bin/system_manager.py
index e03cced..63e2319 100755
--- a/bin/system_manager.py
+++ b/bin/system_manager.py
@@ -27,9 +27,10 @@
 INTF_CONTROL = 'org.openbmc.Control'
 
 
-class SystemManager(Openbmc.DbusProperties):
+class SystemManager(Openbmc.DbusProperties,Openbmc.DbusObjectManager):
 	def __init__(self,bus,obj_name):
 		Openbmc.DbusProperties.__init__(self)
+		Openbmc.DbusObjectManager.__init__(self)
 		dbus.service.Object.__init__(self,bus,obj_name)
 
 		bus.add_signal_receiver(self.NewObjectHandler,
@@ -60,7 +61,7 @@
 			print "Creating cache directory: "+PropertyCacher.CACHE_PATH
    			os.makedirs(PropertyCacher.CACHE_PATH)
 
-		self.ObjectAdded(obj_name,DBUS_NAME)
+		self.InterfacesAdded(obj_name,self.properties)
 		print "SystemManager Init Done"
 
 
@@ -121,7 +122,7 @@
 			obj_path = System.ID_LOOKUP[category][key]
 			bus_name = self.bus_name_lookup[obj_path]
 			parts = obj_path.split('/')
-			if (parts[3] == 'sensor'):
+			if (parts[3] == 'sensors'):
 				intf_name = INTF_SENSOR
 		except Exception as e:
 			print "ERROR SystemManager: "+str(e)+" not found in lookup"