diff --git a/interfaces/sensor2.c b/interfaces/sensor2.c
new file mode 100644
index 0000000..5229695
--- /dev/null
+++ b/interfaces/sensor2.c
@@ -0,0 +1,6811 @@
+/*
+ * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
+ *
+ * The license of this code is the same as for the source it was derived from.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "interfaces/sensor2.h"
+
+#include <string.h>
+#ifdef G_OS_UNIX
+#  include <gio/gunixfdlist.h>
+#endif
+
+typedef struct
+{
+  GDBusArgInfo parent_struct;
+  gboolean use_gvariant;
+} _ExtendedGDBusArgInfo;
+
+typedef struct
+{
+  GDBusMethodInfo parent_struct;
+  const gchar *signal_name;
+  gboolean pass_fdlist;
+} _ExtendedGDBusMethodInfo;
+
+typedef struct
+{
+  GDBusSignalInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusSignalInfo;
+
+typedef struct
+{
+  GDBusPropertyInfo parent_struct;
+  const gchar *hyphen_name;
+  gboolean use_gvariant;
+} _ExtendedGDBusPropertyInfo;
+
+typedef struct
+{
+  GDBusInterfaceInfo parent_struct;
+  const gchar *hyphen_name;
+} _ExtendedGDBusInterfaceInfo;
+
+typedef struct
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  guint prop_id;
+  GValue orig_value; /* the value before the change */
+} ChangedProperty;
+
+static void
+_changed_property_free (ChangedProperty *data)
+{
+  g_value_unset (&data->orig_value);
+  g_free (data);
+}
+
+static gboolean
+_g_strv_equal0 (gchar **a, gchar **b)
+{
+  gboolean ret = FALSE;
+  guint n;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  if (g_strv_length (a) != g_strv_length (b))
+    goto out;
+  for (n = 0; a[n] != NULL; n++)
+    if (g_strcmp0 (a[n], b[n]) != 0)
+      goto out;
+  ret = TRUE;
+out:
+  return ret;
+}
+
+static gboolean
+_g_variant_equal0 (GVariant *a, GVariant *b)
+{
+  gboolean ret = FALSE;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  ret = g_variant_equal (a, b);
+out:
+  return ret;
+}
+
+G_GNUC_UNUSED static gboolean
+_g_value_equal (const GValue *a, const GValue *b)
+{
+  gboolean ret = FALSE;
+  g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
+  switch (G_VALUE_TYPE (a))
+    {
+      case G_TYPE_BOOLEAN:
+        ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
+        break;
+      case G_TYPE_UCHAR:
+        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
+        break;
+      case G_TYPE_INT:
+        ret = (g_value_get_int (a) == g_value_get_int (b));
+        break;
+      case G_TYPE_UINT:
+        ret = (g_value_get_uint (a) == g_value_get_uint (b));
+        break;
+      case G_TYPE_INT64:
+        ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
+        break;
+      case G_TYPE_UINT64:
+        ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
+        break;
+      case G_TYPE_DOUBLE:
+        {
+          /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
+          gdouble da = g_value_get_double (a);
+          gdouble db = g_value_get_double (b);
+          ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
+        }
+        break;
+      case G_TYPE_STRING:
+        ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
+        break;
+      case G_TYPE_VARIANT:
+        ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
+        break;
+      default:
+        if (G_VALUE_TYPE (a) == G_TYPE_STRV)
+          ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
+        else
+          g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
+        break;
+    }
+  return ret;
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.openbmc.SensorInteger
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:SensorInteger
+ * @title: SensorInteger
+ * @short_description: Generated C code for the org.openbmc.SensorInteger D-Bus interface
+ *
+ * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link> D-Bus interface in C.
+ */
+
+/* ---- Introspection data for org.openbmc.SensorInteger ---- */
+
+static const _ExtendedGDBusArgInfo _sensor_integer_method_info_get_value_OUT_ARG_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_method_info_get_value_OUT_ARG_pointers[] =
+{
+  &_sensor_integer_method_info_get_value_OUT_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_method_info_get_value =
+{
+  {
+    -1,
+    (gchar *) "getValue",
+    NULL,
+    (GDBusArgInfo **) &_sensor_integer_method_info_get_value_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-value",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_method_info_set_value_IN_ARG_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_method_info_set_value_IN_ARG_pointers[] =
+{
+  &_sensor_integer_method_info_set_value_IN_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_method_info_set_value =
+{
+  {
+    -1,
+    (gchar *) "setValue",
+    (GDBusArgInfo **) &_sensor_integer_method_info_set_value_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-value",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_method_info_get_units_OUT_ARG_units =
+{
+  {
+    -1,
+    (gchar *) "units",
+    (gchar *) "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_method_info_get_units_OUT_ARG_pointers[] =
+{
+  &_sensor_integer_method_info_get_units_OUT_ARG_units,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_method_info_get_units =
+{
+  {
+    -1,
+    (gchar *) "getUnits",
+    NULL,
+    (GDBusArgInfo **) &_sensor_integer_method_info_get_units_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-units",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_method_info_set_poll_interval_IN_ARG_poll_interval =
+{
+  {
+    -1,
+    (gchar *) "poll_interval",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_method_info_set_poll_interval_IN_ARG_pointers[] =
+{
+  &_sensor_integer_method_info_set_poll_interval_IN_ARG_poll_interval,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_method_info_set_poll_interval =
+{
+  {
+    -1,
+    (gchar *) "setPollInterval",
+    (GDBusArgInfo **) &_sensor_integer_method_info_set_poll_interval_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-poll-interval",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_method_info_set_config_data_IN_ARG_config =
+{
+  {
+    -1,
+    (gchar *) "config",
+    (gchar *) "as",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_method_info_set_config_data_IN_ARG_pointers[] =
+{
+  &_sensor_integer_method_info_set_config_data_IN_ARG_config,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_method_info_set_config_data =
+{
+  {
+    -1,
+    (gchar *) "setConfigData",
+    (GDBusArgInfo **) &_sensor_integer_method_info_set_config_data_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-config-data",
+  FALSE
+};
+
+static const _ExtendedGDBusMethodInfo * const _sensor_integer_method_info_pointers[] =
+{
+  &_sensor_integer_method_info_get_value,
+  &_sensor_integer_method_info_set_value,
+  &_sensor_integer_method_info_get_units,
+  &_sensor_integer_method_info_set_poll_interval,
+  &_sensor_integer_method_info_set_config_data,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_signal_info_changed_ARG_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_signal_info_changed_ARG_pointers[] =
+{
+  &_sensor_integer_signal_info_changed_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_integer_signal_info_changed =
+{
+  {
+    -1,
+    (gchar *) "Changed",
+    (GDBusArgInfo **) &_sensor_integer_signal_info_changed_ARG_pointers,
+    NULL
+  },
+  "changed"
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_signal_info_heartbeat_ARG_bus_name =
+{
+  {
+    -1,
+    (gchar *) "bus_name",
+    (gchar *) "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_signal_info_heartbeat_ARG_pointers[] =
+{
+  &_sensor_integer_signal_info_heartbeat_ARG_bus_name,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_integer_signal_info_heartbeat =
+{
+  {
+    -1,
+    (gchar *) "Heartbeat",
+    (GDBusArgInfo **) &_sensor_integer_signal_info_heartbeat_ARG_pointers,
+    NULL
+  },
+  "heartbeat"
+};
+
+static const _ExtendedGDBusSignalInfo * const _sensor_integer_signal_info_pointers[] =
+{
+  &_sensor_integer_signal_info_changed,
+  &_sensor_integer_signal_info_heartbeat,
+  NULL
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_property_info_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "value",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_property_info_units =
+{
+  {
+    -1,
+    (gchar *) "units",
+    (gchar *) "s",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "units",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_property_info_poll_interval =
+{
+  {
+    -1,
+    (gchar *) "poll_interval",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "poll-interval",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_property_info_config_data =
+{
+  {
+    -1,
+    (gchar *) "config_data",
+    (gchar *) "as",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "config-data",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_property_info_heatbeat =
+{
+  {
+    -1,
+    (gchar *) "heatbeat",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "heatbeat",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo * const _sensor_integer_property_info_pointers[] =
+{
+  &_sensor_integer_property_info_value,
+  &_sensor_integer_property_info_units,
+  &_sensor_integer_property_info_poll_interval,
+  &_sensor_integer_property_info_config_data,
+  &_sensor_integer_property_info_heatbeat,
+  NULL
+};
+
+static const _ExtendedGDBusInterfaceInfo _sensor_integer_interface_info =
+{
+  {
+    -1,
+    (gchar *) "org.openbmc.SensorInteger",
+    (GDBusMethodInfo **) &_sensor_integer_method_info_pointers,
+    (GDBusSignalInfo **) &_sensor_integer_signal_info_pointers,
+    (GDBusPropertyInfo **) &_sensor_integer_property_info_pointers,
+    NULL
+  },
+  "sensor-integer",
+};
+
+
+/**
+ * sensor_integer_interface_info:
+ *
+ * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link> D-Bus interface.
+ *
+ * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
+ */
+GDBusInterfaceInfo *
+sensor_integer_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_sensor_integer_interface_info.parent_struct;
+}
+
+/**
+ * sensor_integer_override_properties:
+ * @klass: The class structure for a #GObject<!-- -->-derived class.
+ * @property_id_begin: The property id to assign to the first overridden property.
+ *
+ * Overrides all #GObject properties in the #SensorInteger interface for a concrete class.
+ * The properties are overridden in the order they are defined.
+ *
+ * Returns: The last property id.
+ */
+guint
+sensor_integer_override_properties (GObjectClass *klass, guint property_id_begin)
+{
+  g_object_class_override_property (klass, property_id_begin++, "value");
+  g_object_class_override_property (klass, property_id_begin++, "units");
+  g_object_class_override_property (klass, property_id_begin++, "poll-interval");
+  g_object_class_override_property (klass, property_id_begin++, "config-data");
+  g_object_class_override_property (klass, property_id_begin++, "heatbeat");
+  return property_id_begin - 1;
+}
+
+
+
+/**
+ * SensorInteger:
+ *
+ * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link>.
+ */
+
+/**
+ * SensorIntegerIface:
+ * @parent_iface: The parent interface.
+ * @handle_get_units: Handler for the #SensorInteger::handle-get-units signal.
+ * @handle_get_value: Handler for the #SensorInteger::handle-get-value signal.
+ * @handle_set_config_data: Handler for the #SensorInteger::handle-set-config-data signal.
+ * @handle_set_poll_interval: Handler for the #SensorInteger::handle-set-poll-interval signal.
+ * @handle_set_value: Handler for the #SensorInteger::handle-set-value signal.
+ * @get_config_data: Getter for the #SensorInteger:config-data property.
+ * @get_heatbeat: Getter for the #SensorInteger:heatbeat property.
+ * @get_poll_interval: Getter for the #SensorInteger:poll-interval property.
+ * @get_units: Getter for the #SensorInteger:units property.
+ * @get_value: Getter for the #SensorInteger:value property.
+ * @changed: Handler for the #SensorInteger::changed signal.
+ * @heartbeat: Handler for the #SensorInteger::heartbeat signal.
+ *
+ * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link>.
+ */
+
+typedef SensorIntegerIface SensorIntegerInterface;
+G_DEFINE_INTERFACE (SensorInteger, sensor_integer, G_TYPE_OBJECT);
+
+static void
+sensor_integer_default_init (SensorIntegerIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  /**
+   * SensorInteger::handle-get-value:
+   * @object: A #SensorInteger.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorInteger.getValue">getValue()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_complete_get_value() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-get-value",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, handle_get_value),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /**
+   * SensorInteger::handle-set-value:
+   * @object: A #SensorInteger.
+   * @invocation: A #GDBusMethodInvocation.
+   * @arg_value: Argument passed by remote caller.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorInteger.setValue">setValue()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_complete_set_value() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-set-value",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, handle_set_value),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT);
+
+  /**
+   * SensorInteger::handle-get-units:
+   * @object: A #SensorInteger.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorInteger.getUnits">getUnits()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_complete_get_units() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-get-units",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, handle_get_units),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /**
+   * SensorInteger::handle-set-poll-interval:
+   * @object: A #SensorInteger.
+   * @invocation: A #GDBusMethodInvocation.
+   * @arg_poll_interval: Argument passed by remote caller.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorInteger.setPollInterval">setPollInterval()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_complete_set_poll_interval() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-set-poll-interval",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, handle_set_poll_interval),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT);
+
+  /**
+   * SensorInteger::handle-set-config-data:
+   * @object: A #SensorInteger.
+   * @invocation: A #GDBusMethodInvocation.
+   * @arg_config: Argument passed by remote caller.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorInteger.setConfigData">setConfigData()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_complete_set_config_data() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-set-config-data",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, handle_set_config_data),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    2,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRV);
+
+  /* GObject signals for received D-Bus signals: */
+  /**
+   * SensorInteger::changed:
+   * @object: A #SensorInteger.
+   * @arg_value: Argument.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorInteger.Changed">"Changed"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("changed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, changed),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_INT);
+
+  /**
+   * SensorInteger::heartbeat:
+   * @object: A #SensorInteger.
+   * @arg_bus_name: Argument.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorInteger.Heartbeat">"Heartbeat"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("heartbeat",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerIface, heartbeat),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_STRING);
+
+  /* GObject properties for D-Bus properties: */
+  /**
+   * SensorInteger:value:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorInteger.value">"value"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("value", "value", "value", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorInteger:units:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorInteger.units">"units"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_string ("units", "units", "units", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorInteger:poll-interval:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorInteger.poll_interval">"poll_interval"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("poll-interval", "poll_interval", "poll_interval", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorInteger:config-data:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorInteger.config_data">"config_data"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_boxed ("config-data", "config_data", "config_data", G_TYPE_STRV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorInteger:heatbeat:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorInteger.heatbeat">"heatbeat"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("heatbeat", "heatbeat", "heatbeat", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * sensor_integer_get_value: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorInteger.value">"value"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_get_value (SensorInteger *object)
+{
+  return SENSOR_INTEGER_GET_IFACE (object)->get_value (object);
+}
+
+/**
+ * sensor_integer_set_value: (skip)
+ * @object: A #SensorInteger.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorInteger.value">"value"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_set_value (SensorInteger *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "value", value, NULL);
+}
+
+/**
+ * sensor_integer_get_units: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorInteger.units">"units"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use sensor_integer_dup_units() if on another thread.</warning>
+ *
+ * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
+ */
+const gchar *
+sensor_integer_get_units (SensorInteger *object)
+{
+  return SENSOR_INTEGER_GET_IFACE (object)->get_units (object);
+}
+
+/**
+ * sensor_integer_dup_units: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorInteger.units">"units"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_free().
+ */
+gchar *
+sensor_integer_dup_units (SensorInteger *object)
+{
+  gchar *value;
+  g_object_get (G_OBJECT (object), "units", &value, NULL);
+  return value;
+}
+
+/**
+ * sensor_integer_set_units: (skip)
+ * @object: A #SensorInteger.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorInteger.units">"units"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_set_units (SensorInteger *object, const gchar *value)
+{
+  g_object_set (G_OBJECT (object), "units", value, NULL);
+}
+
+/**
+ * sensor_integer_get_poll_interval: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorInteger.poll_interval">"poll_interval"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_get_poll_interval (SensorInteger *object)
+{
+  return SENSOR_INTEGER_GET_IFACE (object)->get_poll_interval (object);
+}
+
+/**
+ * sensor_integer_set_poll_interval: (skip)
+ * @object: A #SensorInteger.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorInteger.poll_interval">"poll_interval"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_set_poll_interval (SensorInteger *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "poll-interval", value, NULL);
+}
+
+/**
+ * sensor_integer_get_config_data: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorInteger.config_data">"config_data"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use sensor_integer_dup_config_data() if on another thread.</warning>
+ *
+ * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
+ */
+const gchar *const *
+sensor_integer_get_config_data (SensorInteger *object)
+{
+  return SENSOR_INTEGER_GET_IFACE (object)->get_config_data (object);
+}
+
+/**
+ * sensor_integer_dup_config_data: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorInteger.config_data">"config_data"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_strfreev().
+ */
+gchar **
+sensor_integer_dup_config_data (SensorInteger *object)
+{
+  gchar **value;
+  g_object_get (G_OBJECT (object), "config-data", &value, NULL);
+  return value;
+}
+
+/**
+ * sensor_integer_set_config_data: (skip)
+ * @object: A #SensorInteger.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorInteger.config_data">"config_data"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_set_config_data (SensorInteger *object, const gchar *const *value)
+{
+  g_object_set (G_OBJECT (object), "config-data", value, NULL);
+}
+
+/**
+ * sensor_integer_get_heatbeat: (skip)
+ * @object: A #SensorInteger.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorInteger.heatbeat">"heatbeat"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_get_heatbeat (SensorInteger *object)
+{
+  return SENSOR_INTEGER_GET_IFACE (object)->get_heatbeat (object);
+}
+
+/**
+ * sensor_integer_set_heatbeat: (skip)
+ * @object: A #SensorInteger.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorInteger.heatbeat">"heatbeat"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_set_heatbeat (SensorInteger *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "heatbeat", value, NULL);
+}
+
+/**
+ * sensor_integer_emit_changed:
+ * @object: A #SensorInteger.
+ * @arg_value: Argument to pass with the signal.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorInteger.Changed">"Changed"</link> D-Bus signal.
+ */
+void
+sensor_integer_emit_changed (
+    SensorInteger *object,
+    gint arg_value)
+{
+  g_signal_emit_by_name (object, "changed", arg_value);
+}
+
+/**
+ * sensor_integer_emit_heartbeat:
+ * @object: A #SensorInteger.
+ * @arg_bus_name: Argument to pass with the signal.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorInteger.Heartbeat">"Heartbeat"</link> D-Bus signal.
+ */
+void
+sensor_integer_emit_heartbeat (
+    SensorInteger *object,
+    const gchar *arg_bus_name)
+{
+  g_signal_emit_by_name (object, "heartbeat", arg_bus_name);
+}
+
+/**
+ * sensor_integer_call_get_value:
+ * @proxy: A #SensorIntegerProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.getValue">getValue()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_call_get_value_finish() to get the result of the operation.
+ *
+ * See sensor_integer_call_get_value_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_call_get_value (
+    SensorInteger *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getValue",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_call_get_value_finish:
+ * @proxy: A #SensorIntegerProxy.
+ * @out_value: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_call_get_value().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_call_get_value().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_get_value_finish (
+    SensorInteger *proxy,
+    gint *out_value,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_value);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_get_value_sync:
+ * @proxy: A #SensorIntegerProxy.
+ * @out_value: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.getValue">getValue()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_call_get_value() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_get_value_sync (
+    SensorInteger *proxy,
+    gint *out_value,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getValue",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_value);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_set_value:
+ * @proxy: A #SensorIntegerProxy.
+ * @arg_value: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.setValue">setValue()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_call_set_value_finish() to get the result of the operation.
+ *
+ * See sensor_integer_call_set_value_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_call_set_value (
+    SensorInteger *proxy,
+    gint arg_value,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setValue",
+    g_variant_new ("(i)",
+                   arg_value),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_call_set_value_finish:
+ * @proxy: A #SensorIntegerProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_call_set_value().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_call_set_value().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_set_value_finish (
+    SensorInteger *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_set_value_sync:
+ * @proxy: A #SensorIntegerProxy.
+ * @arg_value: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.setValue">setValue()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_call_set_value() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_set_value_sync (
+    SensorInteger *proxy,
+    gint arg_value,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setValue",
+    g_variant_new ("(i)",
+                   arg_value),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_get_units:
+ * @proxy: A #SensorIntegerProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.getUnits">getUnits()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_call_get_units_finish() to get the result of the operation.
+ *
+ * See sensor_integer_call_get_units_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_call_get_units (
+    SensorInteger *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getUnits",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_call_get_units_finish:
+ * @proxy: A #SensorIntegerProxy.
+ * @out_units: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_call_get_units().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_call_get_units().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_get_units_finish (
+    SensorInteger *proxy,
+    gchar **out_units,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_units);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_get_units_sync:
+ * @proxy: A #SensorIntegerProxy.
+ * @out_units: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.getUnits">getUnits()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_call_get_units() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_get_units_sync (
+    SensorInteger *proxy,
+    gchar **out_units,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getUnits",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_units);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_set_poll_interval:
+ * @proxy: A #SensorIntegerProxy.
+ * @arg_poll_interval: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.setPollInterval">setPollInterval()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_call_set_poll_interval_finish() to get the result of the operation.
+ *
+ * See sensor_integer_call_set_poll_interval_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_call_set_poll_interval (
+    SensorInteger *proxy,
+    gint arg_poll_interval,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setPollInterval",
+    g_variant_new ("(i)",
+                   arg_poll_interval),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_call_set_poll_interval_finish:
+ * @proxy: A #SensorIntegerProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_call_set_poll_interval().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_call_set_poll_interval().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_set_poll_interval_finish (
+    SensorInteger *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_set_poll_interval_sync:
+ * @proxy: A #SensorIntegerProxy.
+ * @arg_poll_interval: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.setPollInterval">setPollInterval()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_call_set_poll_interval() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_set_poll_interval_sync (
+    SensorInteger *proxy,
+    gint arg_poll_interval,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setPollInterval",
+    g_variant_new ("(i)",
+                   arg_poll_interval),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_set_config_data:
+ * @proxy: A #SensorIntegerProxy.
+ * @arg_config: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.setConfigData">setConfigData()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_call_set_config_data_finish() to get the result of the operation.
+ *
+ * See sensor_integer_call_set_config_data_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_call_set_config_data (
+    SensorInteger *proxy,
+    const gchar *const *arg_config,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setConfigData",
+    g_variant_new ("(^as)",
+                   arg_config),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_call_set_config_data_finish:
+ * @proxy: A #SensorIntegerProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_call_set_config_data().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_call_set_config_data().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_set_config_data_finish (
+    SensorInteger *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_call_set_config_data_sync:
+ * @proxy: A #SensorIntegerProxy.
+ * @arg_config: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorInteger.setConfigData">setConfigData()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_call_set_config_data() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_call_set_config_data_sync (
+    SensorInteger *proxy,
+    const gchar *const *arg_config,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setConfigData",
+    g_variant_new ("(^as)",
+                   arg_config),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_complete_get_value:
+ * @object: A #SensorInteger.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @value: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorInteger.getValue">getValue()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_complete_get_value (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    gint value)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   value));
+}
+
+/**
+ * sensor_integer_complete_set_value:
+ * @object: A #SensorInteger.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorInteger.setValue">setValue()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_complete_set_value (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+/**
+ * sensor_integer_complete_get_units:
+ * @object: A #SensorInteger.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @units: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorInteger.getUnits">getUnits()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_complete_get_units (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *units)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   units));
+}
+
+/**
+ * sensor_integer_complete_set_poll_interval:
+ * @object: A #SensorInteger.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorInteger.setPollInterval">setPollInterval()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_complete_set_poll_interval (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+/**
+ * sensor_integer_complete_set_config_data:
+ * @object: A #SensorInteger.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorInteger.setConfigData">setConfigData()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_complete_set_config_data (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorIntegerProxy:
+ *
+ * The #SensorIntegerProxy structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorIntegerProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorIntegerProxy.
+ */
+
+struct _SensorIntegerProxyPrivate
+{
+  GData *qdata;
+};
+
+static void sensor_integer_proxy_iface_init (SensorIntegerIface *iface);
+
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerProxy, sensor_integer_proxy, G_TYPE_DBUS_PROXY,
+                         G_ADD_PRIVATE (SensorIntegerProxy)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER, sensor_integer_proxy_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerProxy, sensor_integer_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER, sensor_integer_proxy_iface_init));
+
+#endif
+static void
+sensor_integer_proxy_finalize (GObject *object)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (object);
+  g_datalist_clear (&proxy->priv->qdata);
+  G_OBJECT_CLASS (sensor_integer_proxy_parent_class)->finalize (object);
+}
+
+static void
+sensor_integer_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  info = _sensor_integer_property_info_pointers[prop_id - 1];
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
+  if (info->use_gvariant)
+    {
+      g_value_set_variant (value, variant);
+    }
+  else
+    {
+      if (variant != NULL)
+        g_dbus_gvariant_to_gvalue (variant, value);
+    }
+  if (variant != NULL)
+    g_variant_unref (variant);
+}
+
+static void
+sensor_integer_proxy_set_property_cb (GDBusProxy *proxy,
+  GAsyncResult *res,
+  gpointer      user_data)
+{
+  const _ExtendedGDBusPropertyInfo *info = user_data;
+  GError *error;
+  GVariant *_ret;
+  error = NULL;
+  _ret = g_dbus_proxy_call_finish (proxy, res, &error);
+  if (!_ret)
+    {
+      g_warning ("Error setting property '%s' on interface org.openbmc.SensorInteger: %s (%s, %d)",
+                 info->parent_struct.name, 
+                 error->message, g_quark_to_string (error->domain), error->code);
+      g_error_free (error);
+    }
+  else
+    {
+      g_variant_unref (_ret);
+    }
+}
+
+static void
+sensor_integer_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  info = _sensor_integer_property_info_pointers[prop_id - 1];
+  variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
+  g_dbus_proxy_call (G_DBUS_PROXY (object),
+    "org.freedesktop.DBus.Properties.Set",
+    g_variant_new ("(ssv)", "org.openbmc.SensorInteger", info->parent_struct.name, variant),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    NULL, (GAsyncReadyCallback) sensor_integer_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
+  g_variant_unref (variant);
+}
+
+static void
+sensor_integer_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name G_GNUC_UNUSED,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_integer_interface_info.parent_struct, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], TYPE_SENSOR_INTEGER);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_INTEGER);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+sensor_integer_proxy_g_properties_changed (GDBusProxy *_proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (_proxy);
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_interface_info.parent_struct, key);
+      g_datalist_remove_data (&proxy->priv->qdata, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_interface_info.parent_struct, invalidated_properties[n]);
+      g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static gint 
+sensor_integer_proxy_get_value (SensorInteger *object)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "value");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static const gchar *
+sensor_integer_proxy_get_units (SensorInteger *object)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (object);
+  GVariant *variant;
+  const gchar *value = NULL;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "units");
+  if (variant != NULL)
+    {
+      value = g_variant_get_string (variant, NULL);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_proxy_get_poll_interval (SensorInteger *object)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "poll_interval");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static const gchar *const *
+sensor_integer_proxy_get_config_data (SensorInteger *object)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (object);
+  GVariant *variant;
+  const gchar *const *value = NULL;
+  value = g_datalist_get_data (&proxy->priv->qdata, "config_data");
+  if (value != NULL)
+    return value;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "config_data");
+  if (variant != NULL)
+    {
+      value = g_variant_get_strv (variant, NULL);
+      g_datalist_set_data_full (&proxy->priv->qdata, "config_data", (gpointer) value, g_free);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_proxy_get_heatbeat (SensorInteger *object)
+{
+  SensorIntegerProxy *proxy = SENSOR_INTEGER_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "heatbeat");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static void
+sensor_integer_proxy_init (SensorIntegerProxy *proxy)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  proxy->priv = sensor_integer_proxy_get_instance_private (proxy);
+#else
+  proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_INTEGER_PROXY, SensorIntegerProxyPrivate);
+#endif
+
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_integer_interface_info ());
+}
+
+static void
+sensor_integer_proxy_class_init (SensorIntegerProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize     = sensor_integer_proxy_finalize;
+  gobject_class->get_property = sensor_integer_proxy_get_property;
+  gobject_class->set_property = sensor_integer_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = sensor_integer_proxy_g_signal;
+  proxy_class->g_properties_changed = sensor_integer_proxy_g_properties_changed;
+
+  sensor_integer_override_properties (gobject_class, 1);
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorIntegerProxyPrivate));
+#endif
+}
+
+static void
+sensor_integer_proxy_iface_init (SensorIntegerIface *iface)
+{
+  iface->get_value = sensor_integer_proxy_get_value;
+  iface->get_units = sensor_integer_proxy_get_units;
+  iface->get_poll_interval = sensor_integer_proxy_get_poll_interval;
+  iface->get_config_data = sensor_integer_proxy_get_config_data;
+  iface->get_heatbeat = sensor_integer_proxy_get_heatbeat;
+}
+
+/**
+ * sensor_integer_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link>. See g_dbus_proxy_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_proxy_new_finish() to get the result of the operation.
+ *
+ * See sensor_integer_proxy_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_integer_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_INTEGER_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorInteger", NULL);
+}
+
+/**
+ * sensor_integer_proxy_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_proxy_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_integer_proxy_new().
+ *
+ * Returns: (transfer full) (type SensorIntegerProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorInteger *
+sensor_integer_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_INTEGER (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_integer_proxy_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link>. See g_dbus_proxy_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_proxy_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorIntegerProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorInteger *
+sensor_integer_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_INTEGER_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorInteger", NULL);
+  if (ret != NULL)
+    return SENSOR_INTEGER (ret);
+  else
+    return NULL;
+}
+
+
+/**
+ * sensor_integer_proxy_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like sensor_integer_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_proxy_new_for_bus_finish() to get the result of the operation.
+ *
+ * See sensor_integer_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_integer_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_INTEGER_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorInteger", NULL);
+}
+
+/**
+ * sensor_integer_proxy_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_proxy_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_integer_proxy_new_for_bus().
+ *
+ * Returns: (transfer full) (type SensorIntegerProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorInteger *
+sensor_integer_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_INTEGER (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_integer_proxy_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like sensor_integer_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_proxy_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorIntegerProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorInteger *
+sensor_integer_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_INTEGER_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorInteger", NULL);
+  if (ret != NULL)
+    return SENSOR_INTEGER (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorIntegerSkeleton:
+ *
+ * The #SensorIntegerSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorIntegerSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorIntegerSkeleton.
+ */
+
+struct _SensorIntegerSkeletonPrivate
+{
+  GValue *properties;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GMainContext *context;
+  GMutex lock;
+};
+
+static void
+_sensor_integer_skeleton_handle_method_call (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint num_extra;
+  guint n;
+  guint signal_id;
+  GValue return_value = G_VALUE_INIT;
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  num_extra = info->pass_fdlist ? 3 : 2;  paramv = g_new0 (GValue, num_params + num_extra);
+  n = 0;
+  g_value_init (&paramv[n], TYPE_SENSOR_INTEGER);
+  g_value_set_object (&paramv[n++], skeleton);
+  g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[n++], invocation);
+  if (info->pass_fdlist)
+    {
+#ifdef G_OS_UNIX
+      g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
+      g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
+#else
+      g_assert_not_reached ();
+#endif
+    }
+  g_variant_iter_init (&iter, parameters);
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_INTEGER);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + num_extra; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_sensor_integer_skeleton_handle_get_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_sensor_integer_skeleton_handle_set_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _sensor_integer_skeleton_vtable =
+{
+  _sensor_integer_skeleton_handle_method_call,
+  _sensor_integer_skeleton_handle_get_property,
+  _sensor_integer_skeleton_handle_set_property,
+  {NULL}
+};
+
+static GDBusInterfaceInfo *
+sensor_integer_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return sensor_integer_interface_info ();
+}
+
+static GDBusInterfaceVTable *
+sensor_integer_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return (GDBusInterfaceVTable *) &_sensor_integer_skeleton_vtable;
+}
+
+static GVariant *
+sensor_integer_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (_skeleton);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_sensor_integer_interface_info.parent_struct.properties == NULL)
+    goto out;
+  for (n = 0; _sensor_integer_interface_info.parent_struct.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _sensor_integer_interface_info.parent_struct.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _sensor_integer_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorInteger", info->name, NULL, skeleton);
+          if (value != NULL)
+            {
+              g_variant_take_ref (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static gboolean _sensor_integer_emit_changed (gpointer user_data);
+
+static void
+sensor_integer_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (_skeleton);
+  gboolean emit_changed = FALSE;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    {
+      g_source_destroy (skeleton->priv->changed_properties_idle_source);
+      skeleton->priv->changed_properties_idle_source = NULL;
+      emit_changed = TRUE;
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+
+  if (emit_changed)
+    _sensor_integer_emit_changed (skeleton);
+}
+
+static void
+_sensor_integer_on_signal_changed (
+    SensorInteger *object,
+    gint arg_value)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("(i)",
+                   arg_value));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorInteger", "Changed",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void
+_sensor_integer_on_signal_heartbeat (
+    SensorInteger *object,
+    const gchar *arg_bus_name)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("(s)",
+                   arg_bus_name));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorInteger", "Heartbeat",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void sensor_integer_skeleton_iface_init (SensorIntegerIface *iface);
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerSkeleton, sensor_integer_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_ADD_PRIVATE (SensorIntegerSkeleton)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER, sensor_integer_skeleton_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerSkeleton, sensor_integer_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER, sensor_integer_skeleton_iface_init));
+
+#endif
+static void
+sensor_integer_skeleton_finalize (GObject *object)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  guint n;
+  for (n = 0; n < 5; n++)
+    g_value_unset (&skeleton->priv->properties[n]);
+  g_free (skeleton->priv->properties);
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (skeleton->priv->changed_properties_idle_source);
+  g_main_context_unref (skeleton->priv->context);
+  g_mutex_clear (&skeleton->priv->lock);
+  G_OBJECT_CLASS (sensor_integer_skeleton_parent_class)->finalize (object);
+}
+
+static void
+sensor_integer_skeleton_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static gboolean
+_sensor_integer_emit_changed (gpointer user_data)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (user_data);
+  GList *l;
+  GVariantBuilder builder;
+  GVariantBuilder invalidated_builder;
+  guint num_changes;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
+  for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
+    {
+      ChangedProperty *cp = l->data;
+      GVariant *variant;
+      const GValue *cur_value;
+
+      cur_value = &skeleton->priv->properties[cp->prop_id - 1];
+      if (!_g_value_equal (cur_value, &cp->orig_value))
+        {
+          variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
+          g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
+          g_variant_unref (variant);
+          num_changes++;
+        }
+    }
+  if (num_changes > 0)
+    {
+      GList *connections, *ll;
+      GVariant *signal_variant;
+      signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorInteger",
+                                           &builder, &invalidated_builder));
+      connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+      for (ll = connections; ll != NULL; ll = ll->next)
+        {
+          GDBusConnection *connection = ll->data;
+
+          g_dbus_connection_emit_signal (connection,
+                                         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
+                                         "org.freedesktop.DBus.Properties",
+                                         "PropertiesChanged",
+                                         signal_variant,
+                                         NULL);
+        }
+      g_variant_unref (signal_variant);
+      g_list_free_full (connections, g_object_unref);
+    }
+  else
+    {
+      g_variant_builder_clear (&builder);
+      g_variant_builder_clear (&invalidated_builder);
+    }
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  skeleton->priv->changed_properties = NULL;
+  skeleton->priv->changed_properties_idle_source = NULL;
+  g_mutex_unlock (&skeleton->priv->lock);
+  return FALSE;
+}
+
+static void
+_sensor_integer_schedule_emit_changed (SensorIntegerSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
+{
+  ChangedProperty *cp;
+  GList *l;
+  cp = NULL;
+  for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
+    {
+      ChangedProperty *i_cp = l->data;
+      if (i_cp->info == info)
+        {
+          cp = i_cp;
+          break;
+        }
+    }
+  if (cp == NULL)
+    {
+      cp = g_new0 (ChangedProperty, 1);
+      cp->prop_id = prop_id;
+      cp->info = info;
+      skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
+      g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
+      g_value_copy (orig_value, &cp->orig_value);
+    }
+}
+
+static void
+sensor_integer_skeleton_notify (GObject      *object,
+  GParamSpec *pspec G_GNUC_UNUSED)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties != NULL &&
+      skeleton->priv->changed_properties_idle_source == NULL)
+    {
+      skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
+      g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
+      g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_integer_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+      g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
+      g_source_unref (skeleton->priv->changed_properties_idle_source);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static void
+sensor_integer_skeleton_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_object_freeze_notify (object);
+  if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
+    {
+      if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
+        _sensor_integer_schedule_emit_changed (skeleton, _sensor_integer_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
+      g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
+      g_object_notify_by_pspec (object, pspec);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+  g_object_thaw_notify (object);
+}
+
+static void
+sensor_integer_skeleton_init (SensorIntegerSkeleton *skeleton)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  skeleton->priv = sensor_integer_skeleton_get_instance_private (skeleton);
+#else
+  skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_INTEGER_SKELETON, SensorIntegerSkeletonPrivate);
+#endif
+
+  g_mutex_init (&skeleton->priv->lock);
+  skeleton->priv->context = g_main_context_ref_thread_default ();
+  skeleton->priv->properties = g_new0 (GValue, 5);
+  g_value_init (&skeleton->priv->properties[0], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[1], G_TYPE_STRING);
+  g_value_init (&skeleton->priv->properties[2], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[3], G_TYPE_STRV);
+  g_value_init (&skeleton->priv->properties[4], G_TYPE_INT);
+}
+
+static gint 
+sensor_integer_skeleton_get_value (SensorInteger *object)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[0]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static const gchar *
+sensor_integer_skeleton_get_units (SensorInteger *object)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  const gchar *value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_string (&(skeleton->priv->properties[1]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_skeleton_get_poll_interval (SensorInteger *object)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[2]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static const gchar *const *
+sensor_integer_skeleton_get_config_data (SensorInteger *object)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  const gchar *const *value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_boxed (&(skeleton->priv->properties[3]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_skeleton_get_heatbeat (SensorInteger *object)
+{
+  SensorIntegerSkeleton *skeleton = SENSOR_INTEGER_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[4]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static void
+sensor_integer_skeleton_class_init (SensorIntegerSkeletonClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusInterfaceSkeletonClass *skeleton_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = sensor_integer_skeleton_finalize;
+  gobject_class->get_property = sensor_integer_skeleton_get_property;
+  gobject_class->set_property = sensor_integer_skeleton_set_property;
+  gobject_class->notify       = sensor_integer_skeleton_notify;
+
+
+  sensor_integer_override_properties (gobject_class, 1);
+
+  skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
+  skeleton_class->get_info = sensor_integer_skeleton_dbus_interface_get_info;
+  skeleton_class->get_properties = sensor_integer_skeleton_dbus_interface_get_properties;
+  skeleton_class->flush = sensor_integer_skeleton_dbus_interface_flush;
+  skeleton_class->get_vtable = sensor_integer_skeleton_dbus_interface_get_vtable;
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorIntegerSkeletonPrivate));
+#endif
+}
+
+static void
+sensor_integer_skeleton_iface_init (SensorIntegerIface *iface)
+{
+  iface->changed = _sensor_integer_on_signal_changed;
+  iface->heartbeat = _sensor_integer_on_signal_heartbeat;
+  iface->get_value = sensor_integer_skeleton_get_value;
+  iface->get_units = sensor_integer_skeleton_get_units;
+  iface->get_poll_interval = sensor_integer_skeleton_get_poll_interval;
+  iface->get_config_data = sensor_integer_skeleton_get_config_data;
+  iface->get_heatbeat = sensor_integer_skeleton_get_heatbeat;
+}
+
+/**
+ * sensor_integer_skeleton_new:
+ *
+ * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link>.
+ *
+ * Returns: (transfer full) (type SensorIntegerSkeleton): The skeleton object.
+ */
+SensorInteger *
+sensor_integer_skeleton_new (void)
+{
+  return SENSOR_INTEGER (g_object_new (TYPE_SENSOR_INTEGER_SKELETON, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.openbmc.SensorString
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:SensorString
+ * @title: SensorString
+ * @short_description: Generated C code for the org.openbmc.SensorString D-Bus interface
+ *
+ * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link> D-Bus interface in C.
+ */
+
+/* ---- Introspection data for org.openbmc.SensorString ---- */
+
+static const _ExtendedGDBusArgInfo _sensor_string_method_info_get_value_OUT_ARG_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_string_method_info_get_value_OUT_ARG_pointers[] =
+{
+  &_sensor_string_method_info_get_value_OUT_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_string_method_info_get_value =
+{
+  {
+    -1,
+    (gchar *) "getValue",
+    NULL,
+    (GDBusArgInfo **) &_sensor_string_method_info_get_value_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-value",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_string_method_info_get_units_OUT_ARG_units =
+{
+  {
+    -1,
+    (gchar *) "units",
+    (gchar *) "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_string_method_info_get_units_OUT_ARG_pointers[] =
+{
+  &_sensor_string_method_info_get_units_OUT_ARG_units,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_string_method_info_get_units =
+{
+  {
+    -1,
+    (gchar *) "getUnits",
+    NULL,
+    (GDBusArgInfo **) &_sensor_string_method_info_get_units_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-units",
+  FALSE
+};
+
+static const _ExtendedGDBusMethodInfo * const _sensor_string_method_info_pointers[] =
+{
+  &_sensor_string_method_info_get_value,
+  &_sensor_string_method_info_get_units,
+  NULL
+};
+
+static const _ExtendedGDBusArgInfo _sensor_string_signal_info_changed_ARG_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "s",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_string_signal_info_changed_ARG_pointers[] =
+{
+  &_sensor_string_signal_info_changed_ARG_value,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_string_signal_info_changed =
+{
+  {
+    -1,
+    (gchar *) "Changed",
+    (GDBusArgInfo **) &_sensor_string_signal_info_changed_ARG_pointers,
+    NULL
+  },
+  "changed"
+};
+
+static const _ExtendedGDBusSignalInfo * const _sensor_string_signal_info_pointers[] =
+{
+  &_sensor_string_signal_info_changed,
+  NULL
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_string_property_info_value =
+{
+  {
+    -1,
+    (gchar *) "value",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "value",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_string_property_info_units =
+{
+  {
+    -1,
+    (gchar *) "units",
+    (gchar *) "s",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "units",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo * const _sensor_string_property_info_pointers[] =
+{
+  &_sensor_string_property_info_value,
+  &_sensor_string_property_info_units,
+  NULL
+};
+
+static const _ExtendedGDBusInterfaceInfo _sensor_string_interface_info =
+{
+  {
+    -1,
+    (gchar *) "org.openbmc.SensorString",
+    (GDBusMethodInfo **) &_sensor_string_method_info_pointers,
+    (GDBusSignalInfo **) &_sensor_string_signal_info_pointers,
+    (GDBusPropertyInfo **) &_sensor_string_property_info_pointers,
+    NULL
+  },
+  "sensor-string",
+};
+
+
+/**
+ * sensor_string_interface_info:
+ *
+ * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link> D-Bus interface.
+ *
+ * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
+ */
+GDBusInterfaceInfo *
+sensor_string_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_sensor_string_interface_info.parent_struct;
+}
+
+/**
+ * sensor_string_override_properties:
+ * @klass: The class structure for a #GObject<!-- -->-derived class.
+ * @property_id_begin: The property id to assign to the first overridden property.
+ *
+ * Overrides all #GObject properties in the #SensorString interface for a concrete class.
+ * The properties are overridden in the order they are defined.
+ *
+ * Returns: The last property id.
+ */
+guint
+sensor_string_override_properties (GObjectClass *klass, guint property_id_begin)
+{
+  g_object_class_override_property (klass, property_id_begin++, "value");
+  g_object_class_override_property (klass, property_id_begin++, "units");
+  return property_id_begin - 1;
+}
+
+
+
+/**
+ * SensorString:
+ *
+ * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link>.
+ */
+
+/**
+ * SensorStringIface:
+ * @parent_iface: The parent interface.
+ * @handle_get_units: Handler for the #SensorString::handle-get-units signal.
+ * @handle_get_value: Handler for the #SensorString::handle-get-value signal.
+ * @get_units: Getter for the #SensorString:units property.
+ * @get_value: Getter for the #SensorString:value property.
+ * @changed: Handler for the #SensorString::changed signal.
+ *
+ * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link>.
+ */
+
+typedef SensorStringIface SensorStringInterface;
+G_DEFINE_INTERFACE (SensorString, sensor_string, G_TYPE_OBJECT);
+
+static void
+sensor_string_default_init (SensorStringIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  /**
+   * SensorString::handle-get-value:
+   * @object: A #SensorString.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorString.getValue">getValue()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_string_complete_get_value() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-get-value",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorStringIface, handle_get_value),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /**
+   * SensorString::handle-get-units:
+   * @object: A #SensorString.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorString.getUnits">getUnits()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_string_complete_get_units() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-get-units",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorStringIface, handle_get_units),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /* GObject signals for received D-Bus signals: */
+  /**
+   * SensorString::changed:
+   * @object: A #SensorString.
+   * @arg_value: Argument.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorString.Changed">"Changed"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("changed",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorStringIface, changed),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    1, G_TYPE_STRING);
+
+  /* GObject properties for D-Bus properties: */
+  /**
+   * SensorString:value:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorString.value">"value"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("value", "value", "value", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorString:units:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorString.units">"units"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_string ("units", "units", "units", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * sensor_string_get_value: (skip)
+ * @object: A #SensorString.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorString.value">"value"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_string_get_value (SensorString *object)
+{
+  return SENSOR_STRING_GET_IFACE (object)->get_value (object);
+}
+
+/**
+ * sensor_string_set_value: (skip)
+ * @object: A #SensorString.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorString.value">"value"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_string_set_value (SensorString *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "value", value, NULL);
+}
+
+/**
+ * sensor_string_get_units: (skip)
+ * @object: A #SensorString.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorString.units">"units"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * <warning>The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use sensor_string_dup_units() if on another thread.</warning>
+ *
+ * Returns: (transfer none): The property value or %NULL if the property is not set. Do not free the returned value, it belongs to @object.
+ */
+const gchar *
+sensor_string_get_units (SensorString *object)
+{
+  return SENSOR_STRING_GET_IFACE (object)->get_units (object);
+}
+
+/**
+ * sensor_string_dup_units: (skip)
+ * @object: A #SensorString.
+ *
+ * Gets a copy of the <link linkend="gdbus-property-org-openbmc-SensorString.units">"units"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: (transfer full): The property value or %NULL if the property is not set. The returned value should be freed with g_free().
+ */
+gchar *
+sensor_string_dup_units (SensorString *object)
+{
+  gchar *value;
+  g_object_get (G_OBJECT (object), "units", &value, NULL);
+  return value;
+}
+
+/**
+ * sensor_string_set_units: (skip)
+ * @object: A #SensorString.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorString.units">"units"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_string_set_units (SensorString *object, const gchar *value)
+{
+  g_object_set (G_OBJECT (object), "units", value, NULL);
+}
+
+/**
+ * sensor_string_emit_changed:
+ * @object: A #SensorString.
+ * @arg_value: Argument to pass with the signal.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorString.Changed">"Changed"</link> D-Bus signal.
+ */
+void
+sensor_string_emit_changed (
+    SensorString *object,
+    const gchar *arg_value)
+{
+  g_signal_emit_by_name (object, "changed", arg_value);
+}
+
+/**
+ * sensor_string_call_get_value:
+ * @proxy: A #SensorStringProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorString.getValue">getValue()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_string_call_get_value_finish() to get the result of the operation.
+ *
+ * See sensor_string_call_get_value_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_string_call_get_value (
+    SensorString *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getValue",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_string_call_get_value_finish:
+ * @proxy: A #SensorStringProxy.
+ * @out_value: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_string_call_get_value().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_string_call_get_value().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_string_call_get_value_finish (
+    SensorString *proxy,
+    gchar **out_value,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_value);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_string_call_get_value_sync:
+ * @proxy: A #SensorStringProxy.
+ * @out_value: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorString.getValue">getValue()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_string_call_get_value() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_string_call_get_value_sync (
+    SensorString *proxy,
+    gchar **out_value,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getValue",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_value);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_string_call_get_units:
+ * @proxy: A #SensorStringProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorString.getUnits">getUnits()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_string_call_get_units_finish() to get the result of the operation.
+ *
+ * See sensor_string_call_get_units_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_string_call_get_units (
+    SensorString *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getUnits",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_string_call_get_units_finish:
+ * @proxy: A #SensorStringProxy.
+ * @out_units: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_string_call_get_units().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_string_call_get_units().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_string_call_get_units_finish (
+    SensorString *proxy,
+    gchar **out_units,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_units);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_string_call_get_units_sync:
+ * @proxy: A #SensorStringProxy.
+ * @out_units: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorString.getUnits">getUnits()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_string_call_get_units() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_string_call_get_units_sync (
+    SensorString *proxy,
+    gchar **out_units,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getUnits",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(s)",
+                 out_units);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_string_complete_get_value:
+ * @object: A #SensorString.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @value: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorString.getValue">getValue()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_string_complete_get_value (
+    SensorString *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *value)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   value));
+}
+
+/**
+ * sensor_string_complete_get_units:
+ * @object: A #SensorString.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @units: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorString.getUnits">getUnits()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_string_complete_get_units (
+    SensorString *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *units)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(s)",
+                   units));
+}
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorStringProxy:
+ *
+ * The #SensorStringProxy structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorStringProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorStringProxy.
+ */
+
+struct _SensorStringProxyPrivate
+{
+  GData *qdata;
+};
+
+static void sensor_string_proxy_iface_init (SensorStringIface *iface);
+
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorStringProxy, sensor_string_proxy, G_TYPE_DBUS_PROXY,
+                         G_ADD_PRIVATE (SensorStringProxy)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_STRING, sensor_string_proxy_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorStringProxy, sensor_string_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_STRING, sensor_string_proxy_iface_init));
+
+#endif
+static void
+sensor_string_proxy_finalize (GObject *object)
+{
+  SensorStringProxy *proxy = SENSOR_STRING_PROXY (object);
+  g_datalist_clear (&proxy->priv->qdata);
+  G_OBJECT_CLASS (sensor_string_proxy_parent_class)->finalize (object);
+}
+
+static void
+sensor_string_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 2);
+  info = _sensor_string_property_info_pointers[prop_id - 1];
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
+  if (info->use_gvariant)
+    {
+      g_value_set_variant (value, variant);
+    }
+  else
+    {
+      if (variant != NULL)
+        g_dbus_gvariant_to_gvalue (variant, value);
+    }
+  if (variant != NULL)
+    g_variant_unref (variant);
+}
+
+static void
+sensor_string_proxy_set_property_cb (GDBusProxy *proxy,
+  GAsyncResult *res,
+  gpointer      user_data)
+{
+  const _ExtendedGDBusPropertyInfo *info = user_data;
+  GError *error;
+  GVariant *_ret;
+  error = NULL;
+  _ret = g_dbus_proxy_call_finish (proxy, res, &error);
+  if (!_ret)
+    {
+      g_warning ("Error setting property '%s' on interface org.openbmc.SensorString: %s (%s, %d)",
+                 info->parent_struct.name, 
+                 error->message, g_quark_to_string (error->domain), error->code);
+      g_error_free (error);
+    }
+  else
+    {
+      g_variant_unref (_ret);
+    }
+}
+
+static void
+sensor_string_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 2);
+  info = _sensor_string_property_info_pointers[prop_id - 1];
+  variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
+  g_dbus_proxy_call (G_DBUS_PROXY (object),
+    "org.freedesktop.DBus.Properties.Set",
+    g_variant_new ("(ssv)", "org.openbmc.SensorString", info->parent_struct.name, variant),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    NULL, (GAsyncReadyCallback) sensor_string_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
+  g_variant_unref (variant);
+}
+
+static void
+sensor_string_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name G_GNUC_UNUSED,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_string_interface_info.parent_struct, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], TYPE_SENSOR_STRING);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_STRING);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+sensor_string_proxy_g_properties_changed (GDBusProxy *_proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  SensorStringProxy *proxy = SENSOR_STRING_PROXY (_proxy);
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_string_interface_info.parent_struct, key);
+      g_datalist_remove_data (&proxy->priv->qdata, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_string_interface_info.parent_struct, invalidated_properties[n]);
+      g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static gint 
+sensor_string_proxy_get_value (SensorString *object)
+{
+  SensorStringProxy *proxy = SENSOR_STRING_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "value");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static const gchar *
+sensor_string_proxy_get_units (SensorString *object)
+{
+  SensorStringProxy *proxy = SENSOR_STRING_PROXY (object);
+  GVariant *variant;
+  const gchar *value = NULL;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "units");
+  if (variant != NULL)
+    {
+      value = g_variant_get_string (variant, NULL);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static void
+sensor_string_proxy_init (SensorStringProxy *proxy)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  proxy->priv = sensor_string_proxy_get_instance_private (proxy);
+#else
+  proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_STRING_PROXY, SensorStringProxyPrivate);
+#endif
+
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_string_interface_info ());
+}
+
+static void
+sensor_string_proxy_class_init (SensorStringProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize     = sensor_string_proxy_finalize;
+  gobject_class->get_property = sensor_string_proxy_get_property;
+  gobject_class->set_property = sensor_string_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = sensor_string_proxy_g_signal;
+  proxy_class->g_properties_changed = sensor_string_proxy_g_properties_changed;
+
+  sensor_string_override_properties (gobject_class, 1);
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorStringProxyPrivate));
+#endif
+}
+
+static void
+sensor_string_proxy_iface_init (SensorStringIface *iface)
+{
+  iface->get_value = sensor_string_proxy_get_value;
+  iface->get_units = sensor_string_proxy_get_units;
+}
+
+/**
+ * sensor_string_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link>. See g_dbus_proxy_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_string_proxy_new_finish() to get the result of the operation.
+ *
+ * See sensor_string_proxy_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_string_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_STRING_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorString", NULL);
+}
+
+/**
+ * sensor_string_proxy_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_string_proxy_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_string_proxy_new().
+ *
+ * Returns: (transfer full) (type SensorStringProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorString *
+sensor_string_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_STRING (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_string_proxy_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link>. See g_dbus_proxy_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_string_proxy_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorStringProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorString *
+sensor_string_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_STRING_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorString", NULL);
+  if (ret != NULL)
+    return SENSOR_STRING (ret);
+  else
+    return NULL;
+}
+
+
+/**
+ * sensor_string_proxy_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like sensor_string_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_string_proxy_new_for_bus_finish() to get the result of the operation.
+ *
+ * See sensor_string_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_string_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_STRING_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorString", NULL);
+}
+
+/**
+ * sensor_string_proxy_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_string_proxy_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_string_proxy_new_for_bus().
+ *
+ * Returns: (transfer full) (type SensorStringProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorString *
+sensor_string_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_STRING (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_string_proxy_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like sensor_string_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_string_proxy_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorStringProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorString *
+sensor_string_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_STRING_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorString", NULL);
+  if (ret != NULL)
+    return SENSOR_STRING (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorStringSkeleton:
+ *
+ * The #SensorStringSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorStringSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorStringSkeleton.
+ */
+
+struct _SensorStringSkeletonPrivate
+{
+  GValue *properties;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GMainContext *context;
+  GMutex lock;
+};
+
+static void
+_sensor_string_skeleton_handle_method_call (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint num_extra;
+  guint n;
+  guint signal_id;
+  GValue return_value = G_VALUE_INIT;
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  num_extra = info->pass_fdlist ? 3 : 2;  paramv = g_new0 (GValue, num_params + num_extra);
+  n = 0;
+  g_value_init (&paramv[n], TYPE_SENSOR_STRING);
+  g_value_set_object (&paramv[n++], skeleton);
+  g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[n++], invocation);
+  if (info->pass_fdlist)
+    {
+#ifdef G_OS_UNIX
+      g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
+      g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
+#else
+      g_assert_not_reached ();
+#endif
+    }
+  g_variant_iter_init (&iter, parameters);
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_STRING);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + num_extra; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_sensor_string_skeleton_handle_get_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_string_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_sensor_string_skeleton_handle_set_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_string_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _sensor_string_skeleton_vtable =
+{
+  _sensor_string_skeleton_handle_method_call,
+  _sensor_string_skeleton_handle_get_property,
+  _sensor_string_skeleton_handle_set_property,
+  {NULL}
+};
+
+static GDBusInterfaceInfo *
+sensor_string_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return sensor_string_interface_info ();
+}
+
+static GDBusInterfaceVTable *
+sensor_string_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return (GDBusInterfaceVTable *) &_sensor_string_skeleton_vtable;
+}
+
+static GVariant *
+sensor_string_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (_skeleton);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_sensor_string_interface_info.parent_struct.properties == NULL)
+    goto out;
+  for (n = 0; _sensor_string_interface_info.parent_struct.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _sensor_string_interface_info.parent_struct.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _sensor_string_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorString", info->name, NULL, skeleton);
+          if (value != NULL)
+            {
+              g_variant_take_ref (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static gboolean _sensor_string_emit_changed (gpointer user_data);
+
+static void
+sensor_string_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (_skeleton);
+  gboolean emit_changed = FALSE;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    {
+      g_source_destroy (skeleton->priv->changed_properties_idle_source);
+      skeleton->priv->changed_properties_idle_source = NULL;
+      emit_changed = TRUE;
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+
+  if (emit_changed)
+    _sensor_string_emit_changed (skeleton);
+}
+
+static void
+_sensor_string_on_signal_changed (
+    SensorString *object,
+    const gchar *arg_value)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("(s)",
+                   arg_value));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorString", "Changed",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void sensor_string_skeleton_iface_init (SensorStringIface *iface);
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorStringSkeleton, sensor_string_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_ADD_PRIVATE (SensorStringSkeleton)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_STRING, sensor_string_skeleton_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorStringSkeleton, sensor_string_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_STRING, sensor_string_skeleton_iface_init));
+
+#endif
+static void
+sensor_string_skeleton_finalize (GObject *object)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+  guint n;
+  for (n = 0; n < 2; n++)
+    g_value_unset (&skeleton->priv->properties[n]);
+  g_free (skeleton->priv->properties);
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (skeleton->priv->changed_properties_idle_source);
+  g_main_context_unref (skeleton->priv->context);
+  g_mutex_clear (&skeleton->priv->lock);
+  G_OBJECT_CLASS (sensor_string_skeleton_parent_class)->finalize (object);
+}
+
+static void
+sensor_string_skeleton_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 2);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static gboolean
+_sensor_string_emit_changed (gpointer user_data)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (user_data);
+  GList *l;
+  GVariantBuilder builder;
+  GVariantBuilder invalidated_builder;
+  guint num_changes;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
+  for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
+    {
+      ChangedProperty *cp = l->data;
+      GVariant *variant;
+      const GValue *cur_value;
+
+      cur_value = &skeleton->priv->properties[cp->prop_id - 1];
+      if (!_g_value_equal (cur_value, &cp->orig_value))
+        {
+          variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
+          g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
+          g_variant_unref (variant);
+          num_changes++;
+        }
+    }
+  if (num_changes > 0)
+    {
+      GList *connections, *ll;
+      GVariant *signal_variant;
+      signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorString",
+                                           &builder, &invalidated_builder));
+      connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+      for (ll = connections; ll != NULL; ll = ll->next)
+        {
+          GDBusConnection *connection = ll->data;
+
+          g_dbus_connection_emit_signal (connection,
+                                         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
+                                         "org.freedesktop.DBus.Properties",
+                                         "PropertiesChanged",
+                                         signal_variant,
+                                         NULL);
+        }
+      g_variant_unref (signal_variant);
+      g_list_free_full (connections, g_object_unref);
+    }
+  else
+    {
+      g_variant_builder_clear (&builder);
+      g_variant_builder_clear (&invalidated_builder);
+    }
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  skeleton->priv->changed_properties = NULL;
+  skeleton->priv->changed_properties_idle_source = NULL;
+  g_mutex_unlock (&skeleton->priv->lock);
+  return FALSE;
+}
+
+static void
+_sensor_string_schedule_emit_changed (SensorStringSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
+{
+  ChangedProperty *cp;
+  GList *l;
+  cp = NULL;
+  for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
+    {
+      ChangedProperty *i_cp = l->data;
+      if (i_cp->info == info)
+        {
+          cp = i_cp;
+          break;
+        }
+    }
+  if (cp == NULL)
+    {
+      cp = g_new0 (ChangedProperty, 1);
+      cp->prop_id = prop_id;
+      cp->info = info;
+      skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
+      g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
+      g_value_copy (orig_value, &cp->orig_value);
+    }
+}
+
+static void
+sensor_string_skeleton_notify (GObject      *object,
+  GParamSpec *pspec G_GNUC_UNUSED)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties != NULL &&
+      skeleton->priv->changed_properties_idle_source == NULL)
+    {
+      skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
+      g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
+      g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_string_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+      g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
+      g_source_unref (skeleton->priv->changed_properties_idle_source);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static void
+sensor_string_skeleton_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 2);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_object_freeze_notify (object);
+  if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
+    {
+      if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
+        _sensor_string_schedule_emit_changed (skeleton, _sensor_string_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
+      g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
+      g_object_notify_by_pspec (object, pspec);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+  g_object_thaw_notify (object);
+}
+
+static void
+sensor_string_skeleton_init (SensorStringSkeleton *skeleton)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  skeleton->priv = sensor_string_skeleton_get_instance_private (skeleton);
+#else
+  skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_STRING_SKELETON, SensorStringSkeletonPrivate);
+#endif
+
+  g_mutex_init (&skeleton->priv->lock);
+  skeleton->priv->context = g_main_context_ref_thread_default ();
+  skeleton->priv->properties = g_new0 (GValue, 2);
+  g_value_init (&skeleton->priv->properties[0], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[1], G_TYPE_STRING);
+}
+
+static gint 
+sensor_string_skeleton_get_value (SensorString *object)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[0]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static const gchar *
+sensor_string_skeleton_get_units (SensorString *object)
+{
+  SensorStringSkeleton *skeleton = SENSOR_STRING_SKELETON (object);
+  const gchar *value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_string (&(skeleton->priv->properties[1]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static void
+sensor_string_skeleton_class_init (SensorStringSkeletonClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusInterfaceSkeletonClass *skeleton_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = sensor_string_skeleton_finalize;
+  gobject_class->get_property = sensor_string_skeleton_get_property;
+  gobject_class->set_property = sensor_string_skeleton_set_property;
+  gobject_class->notify       = sensor_string_skeleton_notify;
+
+
+  sensor_string_override_properties (gobject_class, 1);
+
+  skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
+  skeleton_class->get_info = sensor_string_skeleton_dbus_interface_get_info;
+  skeleton_class->get_properties = sensor_string_skeleton_dbus_interface_get_properties;
+  skeleton_class->flush = sensor_string_skeleton_dbus_interface_flush;
+  skeleton_class->get_vtable = sensor_string_skeleton_dbus_interface_get_vtable;
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorStringSkeletonPrivate));
+#endif
+}
+
+static void
+sensor_string_skeleton_iface_init (SensorStringIface *iface)
+{
+  iface->changed = _sensor_string_on_signal_changed;
+  iface->get_value = sensor_string_skeleton_get_value;
+  iface->get_units = sensor_string_skeleton_get_units;
+}
+
+/**
+ * sensor_string_skeleton_new:
+ *
+ * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link>.
+ *
+ * Returns: (transfer full) (type SensorStringSkeleton): The skeleton object.
+ */
+SensorString *
+sensor_string_skeleton_new (void)
+{
+  return SENSOR_STRING (g_object_new (TYPE_SENSOR_STRING_SKELETON, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.openbmc.SensorIntegerThreshold
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:SensorIntegerThreshold
+ * @title: SensorIntegerThreshold
+ * @short_description: Generated C code for the org.openbmc.SensorIntegerThreshold D-Bus interface
+ *
+ * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> D-Bus interface in C.
+ */
+
+/* ---- Introspection data for org.openbmc.SensorIntegerThreshold ---- */
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_IN_ARG_lower_critical =
+{
+  {
+    -1,
+    (gchar *) "lower_critical",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_IN_ARG_lower_warning =
+{
+  {
+    -1,
+    (gchar *) "lower_warning",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_IN_ARG_upper_warning =
+{
+  {
+    -1,
+    (gchar *) "upper_warning",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_IN_ARG_upper_critical =
+{
+  {
+    -1,
+    (gchar *) "upper_critical",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_threshold_method_info_set_IN_ARG_pointers[] =
+{
+  &_sensor_integer_threshold_method_info_set_IN_ARG_lower_critical,
+  &_sensor_integer_threshold_method_info_set_IN_ARG_lower_warning,
+  &_sensor_integer_threshold_method_info_set_IN_ARG_upper_warning,
+  &_sensor_integer_threshold_method_info_set_IN_ARG_upper_critical,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_threshold_method_info_set =
+{
+  {
+    -1,
+    (gchar *) "set",
+    (GDBusArgInfo **) &_sensor_integer_threshold_method_info_set_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_get_state_OUT_ARG_state =
+{
+  {
+    -1,
+    (gchar *) "state",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_threshold_method_info_get_state_OUT_ARG_pointers[] =
+{
+  &_sensor_integer_threshold_method_info_get_state_OUT_ARG_state,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_threshold_method_info_get_state =
+{
+  {
+    -1,
+    (gchar *) "getState",
+    NULL,
+    (GDBusArgInfo **) &_sensor_integer_threshold_method_info_get_state_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-state",
+  FALSE
+};
+
+static const _ExtendedGDBusMethodInfo * const _sensor_integer_threshold_method_info_pointers[] =
+{
+  &_sensor_integer_threshold_method_info_set,
+  &_sensor_integer_threshold_method_info_get_state,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_integer_threshold_signal_info_warning =
+{
+  {
+    -1,
+    (gchar *) "Warning",
+    NULL,
+    NULL
+  },
+  "warning"
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_integer_threshold_signal_info_critical =
+{
+  {
+    -1,
+    (gchar *) "Critical",
+    NULL,
+    NULL
+  },
+  "critical"
+};
+
+static const _ExtendedGDBusSignalInfo * const _sensor_integer_threshold_signal_info_pointers[] =
+{
+  &_sensor_integer_threshold_signal_info_warning,
+  &_sensor_integer_threshold_signal_info_critical,
+  NULL
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_lower_critical =
+{
+  {
+    -1,
+    (gchar *) "lower_critical",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "lower-critical",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_lower_warning =
+{
+  {
+    -1,
+    (gchar *) "lower_warning",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "lower-warning",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_upper_warning =
+{
+  {
+    -1,
+    (gchar *) "upper_warning",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "upper-warning",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_upper_critical =
+{
+  {
+    -1,
+    (gchar *) "upper_critical",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "upper-critical",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_state =
+{
+  {
+    -1,
+    (gchar *) "state",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "state",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo * const _sensor_integer_threshold_property_info_pointers[] =
+{
+  &_sensor_integer_threshold_property_info_lower_critical,
+  &_sensor_integer_threshold_property_info_lower_warning,
+  &_sensor_integer_threshold_property_info_upper_warning,
+  &_sensor_integer_threshold_property_info_upper_critical,
+  &_sensor_integer_threshold_property_info_state,
+  NULL
+};
+
+static const _ExtendedGDBusInterfaceInfo _sensor_integer_threshold_interface_info =
+{
+  {
+    -1,
+    (gchar *) "org.openbmc.SensorIntegerThreshold",
+    (GDBusMethodInfo **) &_sensor_integer_threshold_method_info_pointers,
+    (GDBusSignalInfo **) &_sensor_integer_threshold_signal_info_pointers,
+    (GDBusPropertyInfo **) &_sensor_integer_threshold_property_info_pointers,
+    NULL
+  },
+  "sensor-integer-threshold",
+};
+
+
+/**
+ * sensor_integer_threshold_interface_info:
+ *
+ * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> D-Bus interface.
+ *
+ * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
+ */
+GDBusInterfaceInfo *
+sensor_integer_threshold_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct;
+}
+
+/**
+ * sensor_integer_threshold_override_properties:
+ * @klass: The class structure for a #GObject<!-- -->-derived class.
+ * @property_id_begin: The property id to assign to the first overridden property.
+ *
+ * Overrides all #GObject properties in the #SensorIntegerThreshold interface for a concrete class.
+ * The properties are overridden in the order they are defined.
+ *
+ * Returns: The last property id.
+ */
+guint
+sensor_integer_threshold_override_properties (GObjectClass *klass, guint property_id_begin)
+{
+  g_object_class_override_property (klass, property_id_begin++, "lower-critical");
+  g_object_class_override_property (klass, property_id_begin++, "lower-warning");
+  g_object_class_override_property (klass, property_id_begin++, "upper-warning");
+  g_object_class_override_property (klass, property_id_begin++, "upper-critical");
+  g_object_class_override_property (klass, property_id_begin++, "state");
+  return property_id_begin - 1;
+}
+
+
+
+/**
+ * SensorIntegerThreshold:
+ *
+ * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>.
+ */
+
+/**
+ * SensorIntegerThresholdIface:
+ * @parent_iface: The parent interface.
+ * @handle_get_state: Handler for the #SensorIntegerThreshold::handle-get-state signal.
+ * @handle_set: Handler for the #SensorIntegerThreshold::handle-set signal.
+ * @get_lower_critical: Getter for the #SensorIntegerThreshold:lower-critical property.
+ * @get_lower_warning: Getter for the #SensorIntegerThreshold:lower-warning property.
+ * @get_state: Getter for the #SensorIntegerThreshold:state property.
+ * @get_upper_critical: Getter for the #SensorIntegerThreshold:upper-critical property.
+ * @get_upper_warning: Getter for the #SensorIntegerThreshold:upper-warning property.
+ * @critical: Handler for the #SensorIntegerThreshold::critical signal.
+ * @warning: Handler for the #SensorIntegerThreshold::warning signal.
+ *
+ * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>.
+ */
+
+typedef SensorIntegerThresholdIface SensorIntegerThresholdInterface;
+G_DEFINE_INTERFACE (SensorIntegerThreshold, sensor_integer_threshold, G_TYPE_OBJECT);
+
+static void
+sensor_integer_threshold_default_init (SensorIntegerThresholdIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  /**
+   * SensorIntegerThreshold::handle-set:
+   * @object: A #SensorIntegerThreshold.
+   * @invocation: A #GDBusMethodInvocation.
+   * @arg_lower_critical: Argument passed by remote caller.
+   * @arg_lower_warning: Argument passed by remote caller.
+   * @arg_upper_warning: Argument passed by remote caller.
+   * @arg_upper_critical: Argument passed by remote caller.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.set">set()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_threshold_complete_set() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-set",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, handle_set),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    5,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
+
+  /**
+   * SensorIntegerThreshold::handle-get-state:
+   * @object: A #SensorIntegerThreshold.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getState">getState()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_threshold_complete_get_state() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-get-state",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, handle_get_state),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /* GObject signals for received D-Bus signals: */
+  /**
+   * SensorIntegerThreshold::warning:
+   * @object: A #SensorIntegerThreshold.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Warning">"Warning"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("warning",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, warning),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    0);
+
+  /**
+   * SensorIntegerThreshold::critical:
+   * @object: A #SensorIntegerThreshold.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Critical">"Critical"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("critical",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, critical),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    0);
+
+  /* GObject properties for D-Bus properties: */
+  /**
+   * SensorIntegerThreshold:lower-critical:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.lower_critical">"lower_critical"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("lower-critical", "lower_critical", "lower_critical", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:lower-warning:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.lower_warning">"lower_warning"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("lower-warning", "lower_warning", "lower_warning", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:upper-warning:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.upper_warning">"upper_warning"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("upper-warning", "upper_warning", "upper_warning", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:upper-critical:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.upper_critical">"upper_critical"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("upper-critical", "upper_critical", "upper_critical", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:state:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.state">"state"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("state", "state", "state", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * sensor_integer_threshold_get_lower_critical: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.lower_critical">"lower_critical"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_lower_critical (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_lower_critical (object);
+}
+
+/**
+ * sensor_integer_threshold_set_lower_critical: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.lower_critical">"lower_critical"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_lower_critical (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "lower-critical", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_lower_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.lower_warning">"lower_warning"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_lower_warning (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_lower_warning (object);
+}
+
+/**
+ * sensor_integer_threshold_set_lower_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.lower_warning">"lower_warning"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_lower_warning (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "lower-warning", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_upper_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.upper_warning">"upper_warning"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_upper_warning (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_upper_warning (object);
+}
+
+/**
+ * sensor_integer_threshold_set_upper_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.upper_warning">"upper_warning"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_upper_warning (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "upper-warning", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_upper_critical: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.upper_critical">"upper_critical"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_upper_critical (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_upper_critical (object);
+}
+
+/**
+ * sensor_integer_threshold_set_upper_critical: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.upper_critical">"upper_critical"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_upper_critical (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "upper-critical", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_state: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.state">"state"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_state (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_state (object);
+}
+
+/**
+ * sensor_integer_threshold_set_state: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.state">"state"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_state (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "state", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_emit_warning:
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Warning">"Warning"</link> D-Bus signal.
+ */
+void
+sensor_integer_threshold_emit_warning (
+    SensorIntegerThreshold *object)
+{
+  g_signal_emit_by_name (object, "warning");
+}
+
+/**
+ * sensor_integer_threshold_emit_critical:
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Critical">"Critical"</link> D-Bus signal.
+ */
+void
+sensor_integer_threshold_emit_critical (
+    SensorIntegerThreshold *object)
+{
+  g_signal_emit_by_name (object, "critical");
+}
+
+/**
+ * sensor_integer_threshold_call_set:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @arg_lower_critical: Argument to pass with the method invocation.
+ * @arg_lower_warning: Argument to pass with the method invocation.
+ * @arg_upper_warning: Argument to pass with the method invocation.
+ * @arg_upper_critical: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.set">set()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_call_set_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_call_set_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_threshold_call_set (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "set",
+    g_variant_new ("(iiii)",
+                   arg_lower_critical,
+                   arg_lower_warning,
+                   arg_upper_warning,
+                   arg_upper_critical),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_threshold_call_set_finish:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_call_set().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_threshold_call_set().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_set_finish (
+    SensorIntegerThreshold *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_call_set_sync:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @arg_lower_critical: Argument to pass with the method invocation.
+ * @arg_lower_warning: Argument to pass with the method invocation.
+ * @arg_upper_warning: Argument to pass with the method invocation.
+ * @arg_upper_critical: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.set">set()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_call_set() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_set_sync (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "set",
+    g_variant_new ("(iiii)",
+                   arg_lower_critical,
+                   arg_lower_warning,
+                   arg_upper_warning,
+                   arg_upper_critical),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_call_get_state:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getState">getState()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_call_get_state_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_call_get_state_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_threshold_call_get_state (
+    SensorIntegerThreshold *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getState",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_threshold_call_get_state_finish:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @out_state: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_call_get_state().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_threshold_call_get_state().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_get_state_finish (
+    SensorIntegerThreshold *proxy,
+    gint *out_state,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_state);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_call_get_state_sync:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @out_state: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getState">getState()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_call_get_state() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_get_state_sync (
+    SensorIntegerThreshold *proxy,
+    gint *out_state,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getState",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_state);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_complete_set:
+ * @object: A #SensorIntegerThreshold.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.set">set()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_threshold_complete_set (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+/**
+ * sensor_integer_threshold_complete_get_state:
+ * @object: A #SensorIntegerThreshold.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @state: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getState">getState()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_threshold_complete_get_state (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation,
+    gint state)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   state));
+}
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorIntegerThresholdProxy:
+ *
+ * The #SensorIntegerThresholdProxy structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorIntegerThresholdProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorIntegerThresholdProxy.
+ */
+
+struct _SensorIntegerThresholdProxyPrivate
+{
+  GData *qdata;
+};
+
+static void sensor_integer_threshold_proxy_iface_init (SensorIntegerThresholdIface *iface);
+
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdProxy, sensor_integer_threshold_proxy, G_TYPE_DBUS_PROXY,
+                         G_ADD_PRIVATE (SensorIntegerThresholdProxy)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_proxy_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdProxy, sensor_integer_threshold_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_proxy_iface_init));
+
+#endif
+static void
+sensor_integer_threshold_proxy_finalize (GObject *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  g_datalist_clear (&proxy->priv->qdata);
+  G_OBJECT_CLASS (sensor_integer_threshold_proxy_parent_class)->finalize (object);
+}
+
+static void
+sensor_integer_threshold_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  info = _sensor_integer_threshold_property_info_pointers[prop_id - 1];
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
+  if (info->use_gvariant)
+    {
+      g_value_set_variant (value, variant);
+    }
+  else
+    {
+      if (variant != NULL)
+        g_dbus_gvariant_to_gvalue (variant, value);
+    }
+  if (variant != NULL)
+    g_variant_unref (variant);
+}
+
+static void
+sensor_integer_threshold_proxy_set_property_cb (GDBusProxy *proxy,
+  GAsyncResult *res,
+  gpointer      user_data)
+{
+  const _ExtendedGDBusPropertyInfo *info = user_data;
+  GError *error;
+  GVariant *_ret;
+  error = NULL;
+  _ret = g_dbus_proxy_call_finish (proxy, res, &error);
+  if (!_ret)
+    {
+      g_warning ("Error setting property '%s' on interface org.openbmc.SensorIntegerThreshold: %s (%s, %d)",
+                 info->parent_struct.name, 
+                 error->message, g_quark_to_string (error->domain), error->code);
+      g_error_free (error);
+    }
+  else
+    {
+      g_variant_unref (_ret);
+    }
+}
+
+static void
+sensor_integer_threshold_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  info = _sensor_integer_threshold_property_info_pointers[prop_id - 1];
+  variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
+  g_dbus_proxy_call (G_DBUS_PROXY (object),
+    "org.freedesktop.DBus.Properties.Set",
+    g_variant_new ("(ssv)", "org.openbmc.SensorIntegerThreshold", info->parent_struct.name, variant),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    NULL, (GAsyncReadyCallback) sensor_integer_threshold_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
+  g_variant_unref (variant);
+}
+
+static void
+sensor_integer_threshold_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name G_GNUC_UNUSED,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+sensor_integer_threshold_proxy_g_properties_changed (GDBusProxy *_proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (_proxy);
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, key);
+      g_datalist_remove_data (&proxy->priv->qdata, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, invalidated_properties[n]);
+      g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_lower_critical (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "lower_critical");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_lower_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "lower_warning");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_upper_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "upper_warning");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_upper_critical (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "upper_critical");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_state (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "state");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static void
+sensor_integer_threshold_proxy_init (SensorIntegerThresholdProxy *proxy)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  proxy->priv = sensor_integer_threshold_proxy_get_instance_private (proxy);
+#else
+  proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyPrivate);
+#endif
+
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_integer_threshold_interface_info ());
+}
+
+static void
+sensor_integer_threshold_proxy_class_init (SensorIntegerThresholdProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize     = sensor_integer_threshold_proxy_finalize;
+  gobject_class->get_property = sensor_integer_threshold_proxy_get_property;
+  gobject_class->set_property = sensor_integer_threshold_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = sensor_integer_threshold_proxy_g_signal;
+  proxy_class->g_properties_changed = sensor_integer_threshold_proxy_g_properties_changed;
+
+  sensor_integer_threshold_override_properties (gobject_class, 1);
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorIntegerThresholdProxyPrivate));
+#endif
+}
+
+static void
+sensor_integer_threshold_proxy_iface_init (SensorIntegerThresholdIface *iface)
+{
+  iface->get_lower_critical = sensor_integer_threshold_proxy_get_lower_critical;
+  iface->get_lower_warning = sensor_integer_threshold_proxy_get_lower_warning;
+  iface->get_upper_warning = sensor_integer_threshold_proxy_get_upper_warning;
+  iface->get_upper_critical = sensor_integer_threshold_proxy_get_upper_critical;
+  iface->get_state = sensor_integer_threshold_proxy_get_state;
+}
+
+/**
+ * sensor_integer_threshold_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>. See g_dbus_proxy_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_proxy_new_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_proxy_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_integer_threshold_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_proxy_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_integer_threshold_proxy_new().
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>. See g_dbus_proxy_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_proxy_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+
+/**
+ * sensor_integer_threshold_proxy_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like sensor_integer_threshold_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_proxy_new_for_bus_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_integer_threshold_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_proxy_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_integer_threshold_proxy_new_for_bus().
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like sensor_integer_threshold_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_proxy_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorIntegerThresholdSkeleton:
+ *
+ * The #SensorIntegerThresholdSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorIntegerThresholdSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorIntegerThresholdSkeleton.
+ */
+
+struct _SensorIntegerThresholdSkeletonPrivate
+{
+  GValue *properties;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GMainContext *context;
+  GMutex lock;
+};
+
+static void
+_sensor_integer_threshold_skeleton_handle_method_call (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint num_extra;
+  guint n;
+  guint signal_id;
+  GValue return_value = G_VALUE_INIT;
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  num_extra = info->pass_fdlist ? 3 : 2;  paramv = g_new0 (GValue, num_params + num_extra);
+  n = 0;
+  g_value_init (&paramv[n], TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_value_set_object (&paramv[n++], skeleton);
+  g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[n++], invocation);
+  if (info->pass_fdlist)
+    {
+#ifdef G_OS_UNIX
+      g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
+      g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
+#else
+      g_assert_not_reached ();
+#endif
+    }
+  g_variant_iter_init (&iter, parameters);
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + num_extra; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_sensor_integer_threshold_skeleton_handle_get_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_sensor_integer_threshold_skeleton_handle_set_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _sensor_integer_threshold_skeleton_vtable =
+{
+  _sensor_integer_threshold_skeleton_handle_method_call,
+  _sensor_integer_threshold_skeleton_handle_get_property,
+  _sensor_integer_threshold_skeleton_handle_set_property,
+  {NULL}
+};
+
+static GDBusInterfaceInfo *
+sensor_integer_threshold_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return sensor_integer_threshold_interface_info ();
+}
+
+static GDBusInterfaceVTable *
+sensor_integer_threshold_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return (GDBusInterfaceVTable *) &_sensor_integer_threshold_skeleton_vtable;
+}
+
+static GVariant *
+sensor_integer_threshold_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (_skeleton);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_sensor_integer_threshold_interface_info.parent_struct.properties == NULL)
+    goto out;
+  for (n = 0; _sensor_integer_threshold_interface_info.parent_struct.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _sensor_integer_threshold_interface_info.parent_struct.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _sensor_integer_threshold_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorIntegerThreshold", info->name, NULL, skeleton);
+          if (value != NULL)
+            {
+              g_variant_take_ref (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static gboolean _sensor_integer_threshold_emit_changed (gpointer user_data);
+
+static void
+sensor_integer_threshold_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (_skeleton);
+  gboolean emit_changed = FALSE;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    {
+      g_source_destroy (skeleton->priv->changed_properties_idle_source);
+      skeleton->priv->changed_properties_idle_source = NULL;
+      emit_changed = TRUE;
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+
+  if (emit_changed)
+    _sensor_integer_threshold_emit_changed (skeleton);
+}
+
+static void
+_sensor_integer_threshold_on_signal_warning (
+    SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("()"));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorIntegerThreshold", "Warning",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void
+_sensor_integer_threshold_on_signal_critical (
+    SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("()"));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorIntegerThreshold", "Critical",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void sensor_integer_threshold_skeleton_iface_init (SensorIntegerThresholdIface *iface);
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdSkeleton, sensor_integer_threshold_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_ADD_PRIVATE (SensorIntegerThresholdSkeleton)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_skeleton_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdSkeleton, sensor_integer_threshold_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_skeleton_iface_init));
+
+#endif
+static void
+sensor_integer_threshold_skeleton_finalize (GObject *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  guint n;
+  for (n = 0; n < 5; n++)
+    g_value_unset (&skeleton->priv->properties[n]);
+  g_free (skeleton->priv->properties);
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (skeleton->priv->changed_properties_idle_source);
+  g_main_context_unref (skeleton->priv->context);
+  g_mutex_clear (&skeleton->priv->lock);
+  G_OBJECT_CLASS (sensor_integer_threshold_skeleton_parent_class)->finalize (object);
+}
+
+static void
+sensor_integer_threshold_skeleton_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static gboolean
+_sensor_integer_threshold_emit_changed (gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  GList *l;
+  GVariantBuilder builder;
+  GVariantBuilder invalidated_builder;
+  guint num_changes;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
+  for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
+    {
+      ChangedProperty *cp = l->data;
+      GVariant *variant;
+      const GValue *cur_value;
+
+      cur_value = &skeleton->priv->properties[cp->prop_id - 1];
+      if (!_g_value_equal (cur_value, &cp->orig_value))
+        {
+          variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
+          g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
+          g_variant_unref (variant);
+          num_changes++;
+        }
+    }
+  if (num_changes > 0)
+    {
+      GList *connections, *ll;
+      GVariant *signal_variant;
+      signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorIntegerThreshold",
+                                           &builder, &invalidated_builder));
+      connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+      for (ll = connections; ll != NULL; ll = ll->next)
+        {
+          GDBusConnection *connection = ll->data;
+
+          g_dbus_connection_emit_signal (connection,
+                                         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
+                                         "org.freedesktop.DBus.Properties",
+                                         "PropertiesChanged",
+                                         signal_variant,
+                                         NULL);
+        }
+      g_variant_unref (signal_variant);
+      g_list_free_full (connections, g_object_unref);
+    }
+  else
+    {
+      g_variant_builder_clear (&builder);
+      g_variant_builder_clear (&invalidated_builder);
+    }
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  skeleton->priv->changed_properties = NULL;
+  skeleton->priv->changed_properties_idle_source = NULL;
+  g_mutex_unlock (&skeleton->priv->lock);
+  return FALSE;
+}
+
+static void
+_sensor_integer_threshold_schedule_emit_changed (SensorIntegerThresholdSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
+{
+  ChangedProperty *cp;
+  GList *l;
+  cp = NULL;
+  for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
+    {
+      ChangedProperty *i_cp = l->data;
+      if (i_cp->info == info)
+        {
+          cp = i_cp;
+          break;
+        }
+    }
+  if (cp == NULL)
+    {
+      cp = g_new0 (ChangedProperty, 1);
+      cp->prop_id = prop_id;
+      cp->info = info;
+      skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
+      g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
+      g_value_copy (orig_value, &cp->orig_value);
+    }
+}
+
+static void
+sensor_integer_threshold_skeleton_notify (GObject      *object,
+  GParamSpec *pspec G_GNUC_UNUSED)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties != NULL &&
+      skeleton->priv->changed_properties_idle_source == NULL)
+    {
+      skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
+      g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
+      g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_integer_threshold_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+      g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
+      g_source_unref (skeleton->priv->changed_properties_idle_source);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static void
+sensor_integer_threshold_skeleton_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 5);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_object_freeze_notify (object);
+  if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
+    {
+      if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
+        _sensor_integer_threshold_schedule_emit_changed (skeleton, _sensor_integer_threshold_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
+      g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
+      g_object_notify_by_pspec (object, pspec);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+  g_object_thaw_notify (object);
+}
+
+static void
+sensor_integer_threshold_skeleton_init (SensorIntegerThresholdSkeleton *skeleton)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  skeleton->priv = sensor_integer_threshold_skeleton_get_instance_private (skeleton);
+#else
+  skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonPrivate);
+#endif
+
+  g_mutex_init (&skeleton->priv->lock);
+  skeleton->priv->context = g_main_context_ref_thread_default ();
+  skeleton->priv->properties = g_new0 (GValue, 5);
+  g_value_init (&skeleton->priv->properties[0], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[1], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[2], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[3], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[4], G_TYPE_INT);
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_lower_critical (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[0]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_lower_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[1]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_upper_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[2]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_upper_critical (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[3]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_state (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[4]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static void
+sensor_integer_threshold_skeleton_class_init (SensorIntegerThresholdSkeletonClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusInterfaceSkeletonClass *skeleton_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = sensor_integer_threshold_skeleton_finalize;
+  gobject_class->get_property = sensor_integer_threshold_skeleton_get_property;
+  gobject_class->set_property = sensor_integer_threshold_skeleton_set_property;
+  gobject_class->notify       = sensor_integer_threshold_skeleton_notify;
+
+
+  sensor_integer_threshold_override_properties (gobject_class, 1);
+
+  skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
+  skeleton_class->get_info = sensor_integer_threshold_skeleton_dbus_interface_get_info;
+  skeleton_class->get_properties = sensor_integer_threshold_skeleton_dbus_interface_get_properties;
+  skeleton_class->flush = sensor_integer_threshold_skeleton_dbus_interface_flush;
+  skeleton_class->get_vtable = sensor_integer_threshold_skeleton_dbus_interface_get_vtable;
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorIntegerThresholdSkeletonPrivate));
+#endif
+}
+
+static void
+sensor_integer_threshold_skeleton_iface_init (SensorIntegerThresholdIface *iface)
+{
+  iface->warning = _sensor_integer_threshold_on_signal_warning;
+  iface->critical = _sensor_integer_threshold_on_signal_critical;
+  iface->get_lower_critical = sensor_integer_threshold_skeleton_get_lower_critical;
+  iface->get_lower_warning = sensor_integer_threshold_skeleton_get_lower_warning;
+  iface->get_upper_warning = sensor_integer_threshold_skeleton_get_upper_warning;
+  iface->get_upper_critical = sensor_integer_threshold_skeleton_get_upper_critical;
+  iface->get_state = sensor_integer_threshold_skeleton_get_state;
+}
+
+/**
+ * sensor_integer_threshold_skeleton_new:
+ *
+ * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>.
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdSkeleton): The skeleton object.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_skeleton_new (void)
+{
+  return SENSOR_INTEGER_THRESHOLD (g_object_new (TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for Object, ObjectProxy and ObjectSkeleton
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:Object
+ * @title: Object
+ * @short_description: Specialized GDBusObject types
+ *
+ * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.
+ */
+
+/**
+ * Object:
+ *
+ * The #Object type is a specialized container of interfaces.
+ */
+
+/**
+ * ObjectIface:
+ * @parent_iface: The parent interface.
+ *
+ * Virtual table for the #Object interface.
+ */
+
+typedef ObjectIface ObjectInterface;
+G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT));
+
+static void
+object_default_init (ObjectIface *iface)
+{
+  /**
+   * Object:sensor-integer:
+   *
+   * The #SensorInteger instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link>, if any.
+   *
+   * Connect to the #GObject::notify signal to get informed of property changes.
+   */
+  g_object_interface_install_property (iface, g_param_spec_object ("sensor-integer", "sensor-integer", "sensor-integer", TYPE_SENSOR_INTEGER, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
+
+  /**
+   * Object:sensor-string:
+   *
+   * The #SensorString instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link>, if any.
+   *
+   * Connect to the #GObject::notify signal to get informed of property changes.
+   */
+  g_object_interface_install_property (iface, g_param_spec_object ("sensor-string", "sensor-string", "sensor-string", TYPE_SENSOR_STRING, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
+
+  /**
+   * Object:sensor-integer-threshold:
+   *
+   * The #SensorIntegerThreshold instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>, if any.
+   *
+   * Connect to the #GObject::notify signal to get informed of property changes.
+   */
+  g_object_interface_install_property (iface, g_param_spec_object ("sensor-integer-threshold", "sensor-integer-threshold", "sensor-integer-threshold", TYPE_SENSOR_INTEGER_THRESHOLD, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
+
+}
+
+/**
+ * object_get_sensor_integer:
+ * @object: A #Object.
+ *
+ * Gets the #SensorInteger instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link> on @object, if any.
+ *
+ * Returns: (transfer full): A #SensorInteger that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
+ */
+SensorInteger *object_get_sensor_integer (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorInteger");
+  if (ret == NULL)
+    return NULL;
+  return SENSOR_INTEGER (ret);
+}
+
+/**
+ * object_get_sensor_string:
+ * @object: A #Object.
+ *
+ * Gets the #SensorString instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link> on @object, if any.
+ *
+ * Returns: (transfer full): A #SensorString that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
+ */
+SensorString *object_get_sensor_string (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorString");
+  if (ret == NULL)
+    return NULL;
+  return SENSOR_STRING (ret);
+}
+
+/**
+ * object_get_sensor_integer_threshold:
+ * @object: A #Object.
+ *
+ * Gets the #SensorIntegerThreshold instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> on @object, if any.
+ *
+ * Returns: (transfer full): A #SensorIntegerThreshold that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
+ */
+SensorIntegerThreshold *object_get_sensor_integer_threshold (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+  if (ret == NULL)
+    return NULL;
+  return SENSOR_INTEGER_THRESHOLD (ret);
+}
+
+
+/**
+ * object_peek_sensor_integer: (skip)
+ * @object: A #Object.
+ *
+ * Like object_get_sensor_integer() but doesn't increase the reference count on the returned object.
+ *
+ * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>
+ *
+ * Returns: (transfer none): A #SensorInteger or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
+ */
+SensorInteger *object_peek_sensor_integer (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorInteger");
+  if (ret == NULL)
+    return NULL;
+  g_object_unref (ret);
+  return SENSOR_INTEGER (ret);
+}
+
+/**
+ * object_peek_sensor_string: (skip)
+ * @object: A #Object.
+ *
+ * Like object_get_sensor_string() but doesn't increase the reference count on the returned object.
+ *
+ * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>
+ *
+ * Returns: (transfer none): A #SensorString or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
+ */
+SensorString *object_peek_sensor_string (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorString");
+  if (ret == NULL)
+    return NULL;
+  g_object_unref (ret);
+  return SENSOR_STRING (ret);
+}
+
+/**
+ * object_peek_sensor_integer_threshold: (skip)
+ * @object: A #Object.
+ *
+ * Like object_get_sensor_integer_threshold() but doesn't increase the reference count on the returned object.
+ *
+ * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>
+ *
+ * Returns: (transfer none): A #SensorIntegerThreshold or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
+ */
+SensorIntegerThreshold *object_peek_sensor_integer_threshold (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+  if (ret == NULL)
+    return NULL;
+  g_object_unref (ret);
+  return SENSOR_INTEGER_THRESHOLD (ret);
+}
+
+
+static void
+object_notify (GDBusObject *object, GDBusInterface *interface)
+{
+  _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);
+  /* info can be NULL if the other end is using a D-Bus interface we don't know
+   * anything about, for example old generated code in this process talking to
+   * newer generated code in the other process. */
+  if (info != NULL)
+    g_object_notify (G_OBJECT (object), info->hyphen_name);
+}
+
+/**
+ * ObjectProxy:
+ *
+ * The #ObjectProxy structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * ObjectProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #ObjectProxy.
+ */
+
+static void
+object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
+{
+}
+
+static void
+object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface)
+{
+  iface->interface_added = object_notify;
+  iface->interface_removed = object_notify;
+}
+
+
+G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY,
+                         G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init));
+
+static void
+object_proxy_init (ObjectProxy *object G_GNUC_UNUSED)
+{
+}
+
+static void
+object_proxy_set_property (GObject      *gobject,
+  guint         prop_id,
+  const GValue *value G_GNUC_UNUSED,
+  GParamSpec   *pspec)
+{
+  G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+}
+
+static void
+object_proxy_get_property (GObject      *gobject,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  ObjectProxy *object = OBJECT_PROXY (gobject);
+  GDBusInterface *interface;
+
+  switch (prop_id)
+    {
+    case 1:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorInteger");
+      g_value_take_object (value, interface);
+      break;
+
+    case 2:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorString");
+      g_value_take_object (value, interface);
+      break;
+
+    case 3:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+      g_value_take_object (value, interface);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+object_proxy_class_init (ObjectProxyClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = object_proxy_set_property;
+  gobject_class->get_property = object_proxy_get_property;
+
+  g_object_class_override_property (gobject_class, 1, "sensor-integer");
+  g_object_class_override_property (gobject_class, 2, "sensor-string");
+  g_object_class_override_property (gobject_class, 3, "sensor-integer-threshold");
+}
+
+/**
+ * object_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @object_path: An object path.
+ *
+ * Creates a new proxy object.
+ *
+ * Returns: (transfer full): The proxy object.
+ */
+ObjectProxy *
+object_proxy_new (GDBusConnection *connection,
+  const gchar *object_path)
+{
+  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
+  g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
+  return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL));
+}
+
+/**
+ * ObjectSkeleton:
+ *
+ * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * ObjectSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #ObjectSkeleton.
+ */
+
+static void
+object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
+{
+}
+
+
+static void
+object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface)
+{
+  iface->interface_added = object_notify;
+  iface->interface_removed = object_notify;
+}
+
+G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON,
+                         G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init));
+
+static void
+object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED)
+{
+}
+
+static void
+object_skeleton_set_property (GObject      *gobject,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+  ObjectSkeleton *object = OBJECT_SKELETON (gobject);
+  GDBusInterfaceSkeleton *interface;
+
+  switch (prop_id)
+    {
+    case 1:
+      interface = g_value_get_object (value);
+      if (interface != NULL)
+        {
+          g_warn_if_fail (IS_SENSOR_INTEGER (interface));
+          g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
+        }
+      else
+        {
+          g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorInteger");
+        }
+      break;
+
+    case 2:
+      interface = g_value_get_object (value);
+      if (interface != NULL)
+        {
+          g_warn_if_fail (IS_SENSOR_STRING (interface));
+          g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
+        }
+      else
+        {
+          g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorString");
+        }
+      break;
+
+    case 3:
+      interface = g_value_get_object (value);
+      if (interface != NULL)
+        {
+          g_warn_if_fail (IS_SENSOR_INTEGER_THRESHOLD (interface));
+          g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
+        }
+      else
+        {
+          g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorIntegerThreshold");
+        }
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+object_skeleton_get_property (GObject      *gobject,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  ObjectSkeleton *object = OBJECT_SKELETON (gobject);
+  GDBusInterface *interface;
+
+  switch (prop_id)
+    {
+    case 1:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorInteger");
+      g_value_take_object (value, interface);
+      break;
+
+    case 2:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorString");
+      g_value_take_object (value, interface);
+      break;
+
+    case 3:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+      g_value_take_object (value, interface);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+object_skeleton_class_init (ObjectSkeletonClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = object_skeleton_set_property;
+  gobject_class->get_property = object_skeleton_get_property;
+
+  g_object_class_override_property (gobject_class, 1, "sensor-integer");
+  g_object_class_override_property (gobject_class, 2, "sensor-string");
+  g_object_class_override_property (gobject_class, 3, "sensor-integer-threshold");
+}
+
+/**
+ * object_skeleton_new:
+ * @object_path: An object path.
+ *
+ * Creates a new skeleton object.
+ *
+ * Returns: (transfer full): The skeleton object.
+ */
+ObjectSkeleton *
+object_skeleton_new (const gchar *object_path)
+{
+  g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
+  return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL));
+}
+
+/**
+ * object_skeleton_set_sensor_integer:
+ * @object: A #ObjectSkeleton.
+ * @interface_: (allow-none): A #SensorInteger or %NULL to clear the interface.
+ *
+ * Sets the #SensorInteger instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorInteger.top_of_page">org.openbmc.SensorInteger</link> on @object.
+ */
+void object_skeleton_set_sensor_integer (ObjectSkeleton *object, SensorInteger *interface_)
+{
+  g_object_set (G_OBJECT (object), "sensor-integer", interface_, NULL);
+}
+
+/**
+ * object_skeleton_set_sensor_string:
+ * @object: A #ObjectSkeleton.
+ * @interface_: (allow-none): A #SensorString or %NULL to clear the interface.
+ *
+ * Sets the #SensorString instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorString.top_of_page">org.openbmc.SensorString</link> on @object.
+ */
+void object_skeleton_set_sensor_string (ObjectSkeleton *object, SensorString *interface_)
+{
+  g_object_set (G_OBJECT (object), "sensor-string", interface_, NULL);
+}
+
+/**
+ * object_skeleton_set_sensor_integer_threshold:
+ * @object: A #ObjectSkeleton.
+ * @interface_: (allow-none): A #SensorIntegerThreshold or %NULL to clear the interface.
+ *
+ * Sets the #SensorIntegerThreshold instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> on @object.
+ */
+void object_skeleton_set_sensor_integer_threshold (ObjectSkeleton *object, SensorIntegerThreshold *interface_)
+{
+  g_object_set (G_OBJECT (object), "sensor-integer-threshold", interface_, NULL);
+}
+
+
+/* ------------------------------------------------------------------------
+ * Code for ObjectManager client
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:ObjectManagerClient
+ * @title: ObjectManagerClient
+ * @short_description: Generated GDBusObjectManagerClient type
+ *
+ * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc.
+ */
+
+/**
+ * ObjectManagerClient:
+ *
+ * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * ObjectManagerClientClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #ObjectManagerClient.
+ */
+
+G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT);
+
+static void
+object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED)
+{
+}
+
+static void
+object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED)
+{
+}
+
+/**
+ * object_manager_client_get_proxy_type:
+ * @manager: A #GDBusObjectManagerClient.
+ * @object_path: The object path of the remote object (unused).
+ * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType.
+ * @user_data: User data (unused).
+ *
+ * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types.
+ *
+ * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy.
+ */
+GType
+object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, gpointer user_data G_GNUC_UNUSED)
+{
+  static gsize once_init_value = 0;
+  static GHashTable *lookup_hash;
+  GType ret;
+
+  if (interface_name == NULL)
+    return TYPE_OBJECT_PROXY;
+  if (g_once_init_enter (&once_init_value))
+    {
+      lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
+      g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorInteger", GSIZE_TO_POINTER (TYPE_SENSOR_INTEGER_PROXY));
+      g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorString", GSIZE_TO_POINTER (TYPE_SENSOR_STRING_PROXY));
+      g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorIntegerThreshold", GSIZE_TO_POINTER (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY));
+      g_once_init_leave (&once_init_value, 1);
+    }
+  ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));
+  if (ret == (GType) 0)
+    ret = G_TYPE_DBUS_PROXY;
+  return ret;
+}
+
+/**
+ * object_manager_client_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call object_manager_client_new_finish() to get the result of the operation.
+ *
+ * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+object_manager_client_new (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data)
+{
+  g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+}
+
+/**
+ * object_manager_client_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with object_manager_client_new().
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+/**
+ * object_manager_client_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See object_manager_client_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_sync (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
+/**
+ * object_manager_client_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation.
+ *
+ * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+object_manager_client_new_for_bus (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data)
+{
+  g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+}
+
+/**
+ * object_manager_client_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with object_manager_client_new_for_bus().
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+/**
+ * object_manager_client_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See object_manager_client_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_for_bus_sync (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
diff --git a/interfaces/sensor2.h b/interfaces/sensor2.h
new file mode 100644
index 0000000..851a2be
--- /dev/null
+++ b/interfaces/sensor2.h
@@ -0,0 +1,915 @@
+/*
+ * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
+ *
+ * The license of this code is the same as for the source it was derived from.
+ */
+
+#ifndef __INTERFACES_SENSOR2_H__
+#define __INTERFACES_SENSOR2_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.openbmc.SensorInteger */
+
+#define TYPE_SENSOR_INTEGER (sensor_integer_get_type ())
+#define SENSOR_INTEGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER, SensorInteger))
+#define IS_SENSOR_INTEGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER))
+#define SENSOR_INTEGER_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_SENSOR_INTEGER, SensorIntegerIface))
+
+struct _SensorInteger;
+typedef struct _SensorInteger SensorInteger;
+typedef struct _SensorIntegerIface SensorIntegerIface;
+
+struct _SensorIntegerIface
+{
+  GTypeInterface parent_iface;
+
+
+
+  gboolean (*handle_get_units) (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_value) (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_set_config_data) (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *const *arg_config);
+
+  gboolean (*handle_set_poll_interval) (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    gint arg_poll_interval);
+
+  gboolean (*handle_set_value) (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    gint arg_value);
+
+  const gchar *const * (*get_config_data) (SensorInteger *object);
+
+  gint  (*get_heatbeat) (SensorInteger *object);
+
+  gint  (*get_poll_interval) (SensorInteger *object);
+
+  const gchar * (*get_units) (SensorInteger *object);
+
+  gint  (*get_value) (SensorInteger *object);
+
+  void (*changed) (
+    SensorInteger *object,
+    gint arg_value);
+
+  void (*heartbeat) (
+    SensorInteger *object,
+    const gchar *arg_bus_name);
+
+};
+
+GType sensor_integer_get_type (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *sensor_integer_interface_info (void);
+guint sensor_integer_override_properties (GObjectClass *klass, guint property_id_begin);
+
+
+/* D-Bus method call completion functions: */
+void sensor_integer_complete_get_value (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    gint value);
+
+void sensor_integer_complete_set_value (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation);
+
+void sensor_integer_complete_get_units (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *units);
+
+void sensor_integer_complete_set_poll_interval (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation);
+
+void sensor_integer_complete_set_config_data (
+    SensorInteger *object,
+    GDBusMethodInvocation *invocation);
+
+
+
+/* D-Bus signal emissions functions: */
+void sensor_integer_emit_changed (
+    SensorInteger *object,
+    gint arg_value);
+
+void sensor_integer_emit_heartbeat (
+    SensorInteger *object,
+    const gchar *arg_bus_name);
+
+
+
+/* D-Bus method calls: */
+void sensor_integer_call_get_value (
+    SensorInteger *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_call_get_value_finish (
+    SensorInteger *proxy,
+    gint *out_value,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_call_get_value_sync (
+    SensorInteger *proxy,
+    gint *out_value,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_integer_call_set_value (
+    SensorInteger *proxy,
+    gint arg_value,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_call_set_value_finish (
+    SensorInteger *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_call_set_value_sync (
+    SensorInteger *proxy,
+    gint arg_value,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_integer_call_get_units (
+    SensorInteger *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_call_get_units_finish (
+    SensorInteger *proxy,
+    gchar **out_units,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_call_get_units_sync (
+    SensorInteger *proxy,
+    gchar **out_units,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_integer_call_set_poll_interval (
+    SensorInteger *proxy,
+    gint arg_poll_interval,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_call_set_poll_interval_finish (
+    SensorInteger *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_call_set_poll_interval_sync (
+    SensorInteger *proxy,
+    gint arg_poll_interval,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_integer_call_set_config_data (
+    SensorInteger *proxy,
+    const gchar *const *arg_config,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_call_set_config_data_finish (
+    SensorInteger *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_call_set_config_data_sync (
+    SensorInteger *proxy,
+    const gchar *const *arg_config,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* D-Bus property accessors: */
+gint sensor_integer_get_value (SensorInteger *object);
+void sensor_integer_set_value (SensorInteger *object, gint value);
+
+const gchar *sensor_integer_get_units (SensorInteger *object);
+gchar *sensor_integer_dup_units (SensorInteger *object);
+void sensor_integer_set_units (SensorInteger *object, const gchar *value);
+
+gint sensor_integer_get_poll_interval (SensorInteger *object);
+void sensor_integer_set_poll_interval (SensorInteger *object, gint value);
+
+const gchar *const *sensor_integer_get_config_data (SensorInteger *object);
+gchar **sensor_integer_dup_config_data (SensorInteger *object);
+void sensor_integer_set_config_data (SensorInteger *object, const gchar *const *value);
+
+gint sensor_integer_get_heatbeat (SensorInteger *object);
+void sensor_integer_set_heatbeat (SensorInteger *object, gint value);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_INTEGER_PROXY (sensor_integer_proxy_get_type ())
+#define SENSOR_INTEGER_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_PROXY, SensorIntegerProxy))
+#define SENSOR_INTEGER_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_PROXY, SensorIntegerProxyClass))
+#define SENSOR_INTEGER_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_PROXY, SensorIntegerProxyClass))
+#define IS_SENSOR_INTEGER_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_PROXY))
+#define IS_SENSOR_INTEGER_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_PROXY))
+
+typedef struct _SensorIntegerProxy SensorIntegerProxy;
+typedef struct _SensorIntegerProxyClass SensorIntegerProxyClass;
+typedef struct _SensorIntegerProxyPrivate SensorIntegerProxyPrivate;
+
+struct _SensorIntegerProxy
+{
+  /*< private >*/
+  GDBusProxy parent_instance;
+  SensorIntegerProxyPrivate *priv;
+};
+
+struct _SensorIntegerProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType sensor_integer_proxy_get_type (void) G_GNUC_CONST;
+
+void sensor_integer_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorInteger *sensor_integer_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorInteger *sensor_integer_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void sensor_integer_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorInteger *sensor_integer_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorInteger *sensor_integer_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_INTEGER_SKELETON (sensor_integer_skeleton_get_type ())
+#define SENSOR_INTEGER_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_SKELETON, SensorIntegerSkeleton))
+#define SENSOR_INTEGER_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_SKELETON, SensorIntegerSkeletonClass))
+#define SENSOR_INTEGER_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_SKELETON, SensorIntegerSkeletonClass))
+#define IS_SENSOR_INTEGER_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_SKELETON))
+#define IS_SENSOR_INTEGER_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_SKELETON))
+
+typedef struct _SensorIntegerSkeleton SensorIntegerSkeleton;
+typedef struct _SensorIntegerSkeletonClass SensorIntegerSkeletonClass;
+typedef struct _SensorIntegerSkeletonPrivate SensorIntegerSkeletonPrivate;
+
+struct _SensorIntegerSkeleton
+{
+  /*< private >*/
+  GDBusInterfaceSkeleton parent_instance;
+  SensorIntegerSkeletonPrivate *priv;
+};
+
+struct _SensorIntegerSkeletonClass
+{
+  GDBusInterfaceSkeletonClass parent_class;
+};
+
+GType sensor_integer_skeleton_get_type (void) G_GNUC_CONST;
+
+SensorInteger *sensor_integer_skeleton_new (void);
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.openbmc.SensorString */
+
+#define TYPE_SENSOR_STRING (sensor_string_get_type ())
+#define SENSOR_STRING(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_STRING, SensorString))
+#define IS_SENSOR_STRING(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_STRING))
+#define SENSOR_STRING_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_SENSOR_STRING, SensorStringIface))
+
+struct _SensorString;
+typedef struct _SensorString SensorString;
+typedef struct _SensorStringIface SensorStringIface;
+
+struct _SensorStringIface
+{
+  GTypeInterface parent_iface;
+
+
+
+  gboolean (*handle_get_units) (
+    SensorString *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_get_value) (
+    SensorString *object,
+    GDBusMethodInvocation *invocation);
+
+  const gchar * (*get_units) (SensorString *object);
+
+  gint  (*get_value) (SensorString *object);
+
+  void (*changed) (
+    SensorString *object,
+    const gchar *arg_value);
+
+};
+
+GType sensor_string_get_type (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *sensor_string_interface_info (void);
+guint sensor_string_override_properties (GObjectClass *klass, guint property_id_begin);
+
+
+/* D-Bus method call completion functions: */
+void sensor_string_complete_get_value (
+    SensorString *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *value);
+
+void sensor_string_complete_get_units (
+    SensorString *object,
+    GDBusMethodInvocation *invocation,
+    const gchar *units);
+
+
+
+/* D-Bus signal emissions functions: */
+void sensor_string_emit_changed (
+    SensorString *object,
+    const gchar *arg_value);
+
+
+
+/* D-Bus method calls: */
+void sensor_string_call_get_value (
+    SensorString *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_string_call_get_value_finish (
+    SensorString *proxy,
+    gchar **out_value,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_string_call_get_value_sync (
+    SensorString *proxy,
+    gchar **out_value,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_string_call_get_units (
+    SensorString *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_string_call_get_units_finish (
+    SensorString *proxy,
+    gchar **out_units,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_string_call_get_units_sync (
+    SensorString *proxy,
+    gchar **out_units,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* D-Bus property accessors: */
+gint sensor_string_get_value (SensorString *object);
+void sensor_string_set_value (SensorString *object, gint value);
+
+const gchar *sensor_string_get_units (SensorString *object);
+gchar *sensor_string_dup_units (SensorString *object);
+void sensor_string_set_units (SensorString *object, const gchar *value);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_STRING_PROXY (sensor_string_proxy_get_type ())
+#define SENSOR_STRING_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_STRING_PROXY, SensorStringProxy))
+#define SENSOR_STRING_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_STRING_PROXY, SensorStringProxyClass))
+#define SENSOR_STRING_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_STRING_PROXY, SensorStringProxyClass))
+#define IS_SENSOR_STRING_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_STRING_PROXY))
+#define IS_SENSOR_STRING_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_STRING_PROXY))
+
+typedef struct _SensorStringProxy SensorStringProxy;
+typedef struct _SensorStringProxyClass SensorStringProxyClass;
+typedef struct _SensorStringProxyPrivate SensorStringProxyPrivate;
+
+struct _SensorStringProxy
+{
+  /*< private >*/
+  GDBusProxy parent_instance;
+  SensorStringProxyPrivate *priv;
+};
+
+struct _SensorStringProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType sensor_string_proxy_get_type (void) G_GNUC_CONST;
+
+void sensor_string_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorString *sensor_string_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorString *sensor_string_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void sensor_string_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorString *sensor_string_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorString *sensor_string_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_STRING_SKELETON (sensor_string_skeleton_get_type ())
+#define SENSOR_STRING_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_STRING_SKELETON, SensorStringSkeleton))
+#define SENSOR_STRING_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_STRING_SKELETON, SensorStringSkeletonClass))
+#define SENSOR_STRING_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_STRING_SKELETON, SensorStringSkeletonClass))
+#define IS_SENSOR_STRING_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_STRING_SKELETON))
+#define IS_SENSOR_STRING_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_STRING_SKELETON))
+
+typedef struct _SensorStringSkeleton SensorStringSkeleton;
+typedef struct _SensorStringSkeletonClass SensorStringSkeletonClass;
+typedef struct _SensorStringSkeletonPrivate SensorStringSkeletonPrivate;
+
+struct _SensorStringSkeleton
+{
+  /*< private >*/
+  GDBusInterfaceSkeleton parent_instance;
+  SensorStringSkeletonPrivate *priv;
+};
+
+struct _SensorStringSkeletonClass
+{
+  GDBusInterfaceSkeletonClass parent_class;
+};
+
+GType sensor_string_skeleton_get_type (void) G_GNUC_CONST;
+
+SensorString *sensor_string_skeleton_new (void);
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.openbmc.SensorIntegerThreshold */
+
+#define TYPE_SENSOR_INTEGER_THRESHOLD (sensor_integer_threshold_get_type ())
+#define SENSOR_INTEGER_THRESHOLD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD, SensorIntegerThreshold))
+#define IS_SENSOR_INTEGER_THRESHOLD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD))
+#define SENSOR_INTEGER_THRESHOLD_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_SENSOR_INTEGER_THRESHOLD, SensorIntegerThresholdIface))
+
+struct _SensorIntegerThreshold;
+typedef struct _SensorIntegerThreshold SensorIntegerThreshold;
+typedef struct _SensorIntegerThresholdIface SensorIntegerThresholdIface;
+
+struct _SensorIntegerThresholdIface
+{
+  GTypeInterface parent_iface;
+
+
+
+  gboolean (*handle_get_state) (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_set) (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical);
+
+  gint  (*get_lower_critical) (SensorIntegerThreshold *object);
+
+  gint  (*get_lower_warning) (SensorIntegerThreshold *object);
+
+  gint  (*get_state) (SensorIntegerThreshold *object);
+
+  gint  (*get_upper_critical) (SensorIntegerThreshold *object);
+
+  gint  (*get_upper_warning) (SensorIntegerThreshold *object);
+
+  void (*critical) (
+    SensorIntegerThreshold *object);
+
+  void (*warning) (
+    SensorIntegerThreshold *object);
+
+};
+
+GType sensor_integer_threshold_get_type (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *sensor_integer_threshold_interface_info (void);
+guint sensor_integer_threshold_override_properties (GObjectClass *klass, guint property_id_begin);
+
+
+/* D-Bus method call completion functions: */
+void sensor_integer_threshold_complete_set (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation);
+
+void sensor_integer_threshold_complete_get_state (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation,
+    gint state);
+
+
+
+/* D-Bus signal emissions functions: */
+void sensor_integer_threshold_emit_warning (
+    SensorIntegerThreshold *object);
+
+void sensor_integer_threshold_emit_critical (
+    SensorIntegerThreshold *object);
+
+
+
+/* D-Bus method calls: */
+void sensor_integer_threshold_call_set (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_threshold_call_set_finish (
+    SensorIntegerThreshold *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_threshold_call_set_sync (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_integer_threshold_call_get_state (
+    SensorIntegerThreshold *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_threshold_call_get_state_finish (
+    SensorIntegerThreshold *proxy,
+    gint *out_state,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_threshold_call_get_state_sync (
+    SensorIntegerThreshold *proxy,
+    gint *out_state,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* D-Bus property accessors: */
+gint sensor_integer_threshold_get_lower_critical (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_lower_critical (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_lower_warning (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_lower_warning (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_upper_warning (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_upper_warning (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_upper_critical (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_upper_critical (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_state (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_state (SensorIntegerThreshold *object, gint value);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_INTEGER_THRESHOLD_PROXY (sensor_integer_threshold_proxy_get_type ())
+#define SENSOR_INTEGER_THRESHOLD_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxy))
+#define SENSOR_INTEGER_THRESHOLD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyClass))
+#define SENSOR_INTEGER_THRESHOLD_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyClass))
+#define IS_SENSOR_INTEGER_THRESHOLD_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY))
+#define IS_SENSOR_INTEGER_THRESHOLD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY))
+
+typedef struct _SensorIntegerThresholdProxy SensorIntegerThresholdProxy;
+typedef struct _SensorIntegerThresholdProxyClass SensorIntegerThresholdProxyClass;
+typedef struct _SensorIntegerThresholdProxyPrivate SensorIntegerThresholdProxyPrivate;
+
+struct _SensorIntegerThresholdProxy
+{
+  /*< private >*/
+  GDBusProxy parent_instance;
+  SensorIntegerThresholdProxyPrivate *priv;
+};
+
+struct _SensorIntegerThresholdProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType sensor_integer_threshold_proxy_get_type (void) G_GNUC_CONST;
+
+void sensor_integer_threshold_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void sensor_integer_threshold_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON (sensor_integer_threshold_skeleton_get_type ())
+#define SENSOR_INTEGER_THRESHOLD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeleton))
+#define SENSOR_INTEGER_THRESHOLD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonClass))
+#define SENSOR_INTEGER_THRESHOLD_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonClass))
+#define IS_SENSOR_INTEGER_THRESHOLD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON))
+#define IS_SENSOR_INTEGER_THRESHOLD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON))
+
+typedef struct _SensorIntegerThresholdSkeleton SensorIntegerThresholdSkeleton;
+typedef struct _SensorIntegerThresholdSkeletonClass SensorIntegerThresholdSkeletonClass;
+typedef struct _SensorIntegerThresholdSkeletonPrivate SensorIntegerThresholdSkeletonPrivate;
+
+struct _SensorIntegerThresholdSkeleton
+{
+  /*< private >*/
+  GDBusInterfaceSkeleton parent_instance;
+  SensorIntegerThresholdSkeletonPrivate *priv;
+};
+
+struct _SensorIntegerThresholdSkeletonClass
+{
+  GDBusInterfaceSkeletonClass parent_class;
+};
+
+GType sensor_integer_threshold_skeleton_get_type (void) G_GNUC_CONST;
+
+SensorIntegerThreshold *sensor_integer_threshold_skeleton_new (void);
+
+
+/* ---- */
+
+#define TYPE_OBJECT (object_get_type ())
+#define OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT, Object))
+#define IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT))
+#define OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_OBJECT, Object))
+
+struct _Object;
+typedef struct _Object Object;
+typedef struct _ObjectIface ObjectIface;
+
+struct _ObjectIface
+{
+  GTypeInterface parent_iface;
+};
+
+GType object_get_type (void) G_GNUC_CONST;
+
+SensorInteger *object_get_sensor_integer (Object *object);
+SensorString *object_get_sensor_string (Object *object);
+SensorIntegerThreshold *object_get_sensor_integer_threshold (Object *object);
+SensorInteger *object_peek_sensor_integer (Object *object);
+SensorString *object_peek_sensor_string (Object *object);
+SensorIntegerThreshold *object_peek_sensor_integer_threshold (Object *object);
+
+#define TYPE_OBJECT_PROXY (object_proxy_get_type ())
+#define OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_PROXY, ObjectProxy))
+#define OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_PROXY, ObjectProxyClass))
+#define OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_PROXY, ObjectProxyClass))
+#define IS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_PROXY))
+#define IS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_PROXY))
+
+typedef struct _ObjectProxy ObjectProxy;
+typedef struct _ObjectProxyClass ObjectProxyClass;
+typedef struct _ObjectProxyPrivate ObjectProxyPrivate;
+
+struct _ObjectProxy
+{
+  /*< private >*/
+  GDBusObjectProxy parent_instance;
+  ObjectProxyPrivate *priv;
+};
+
+struct _ObjectProxyClass
+{
+  GDBusObjectProxyClass parent_class;
+};
+
+GType object_proxy_get_type (void) G_GNUC_CONST;
+ObjectProxy *object_proxy_new (GDBusConnection *connection, const gchar *object_path);
+
+#define TYPE_OBJECT_SKELETON (object_skeleton_get_type ())
+#define OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_SKELETON, ObjectSkeleton))
+#define OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
+#define OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
+#define IS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_SKELETON))
+#define IS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_SKELETON))
+
+typedef struct _ObjectSkeleton ObjectSkeleton;
+typedef struct _ObjectSkeletonClass ObjectSkeletonClass;
+typedef struct _ObjectSkeletonPrivate ObjectSkeletonPrivate;
+
+struct _ObjectSkeleton
+{
+  /*< private >*/
+  GDBusObjectSkeleton parent_instance;
+  ObjectSkeletonPrivate *priv;
+};
+
+struct _ObjectSkeletonClass
+{
+  GDBusObjectSkeletonClass parent_class;
+};
+
+GType object_skeleton_get_type (void) G_GNUC_CONST;
+ObjectSkeleton *object_skeleton_new (const gchar *object_path);
+void object_skeleton_set_sensor_integer (ObjectSkeleton *object, SensorInteger *interface_);
+void object_skeleton_set_sensor_string (ObjectSkeleton *object, SensorString *interface_);
+void object_skeleton_set_sensor_integer_threshold (ObjectSkeleton *object, SensorIntegerThreshold *interface_);
+
+/* ---- */
+
+#define TYPE_OBJECT_MANAGER_CLIENT (object_manager_client_get_type ())
+#define OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClient))
+#define OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
+#define OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
+#define IS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_MANAGER_CLIENT))
+#define IS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_MANAGER_CLIENT))
+
+typedef struct _ObjectManagerClient ObjectManagerClient;
+typedef struct _ObjectManagerClientClass ObjectManagerClientClass;
+typedef struct _ObjectManagerClientPrivate ObjectManagerClientPrivate;
+
+struct _ObjectManagerClient
+{
+  /*< private >*/
+  GDBusObjectManagerClient parent_instance;
+  ObjectManagerClientPrivate *priv;
+};
+
+struct _ObjectManagerClientClass
+{
+  GDBusObjectManagerClientClass parent_class;
+};
+
+GType object_manager_client_get_type (void) G_GNUC_CONST;
+
+GType object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data);
+
+void object_manager_client_new (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data);
+GDBusObjectManager *object_manager_client_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusObjectManager *object_manager_client_new_sync (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error);
+
+void object_manager_client_new_for_bus (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data);
+GDBusObjectManager *object_manager_client_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusObjectManager *object_manager_client_new_for_bus_sync (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error);
+
+
+G_END_DECLS
+
+#endif /* __INTERFACES_SENSOR2_H__ */
diff --git a/interfaces/sensor_threshold.c b/interfaces/sensor_threshold.c
new file mode 100644
index 0000000..6804e32
--- /dev/null
+++ b/interfaces/sensor_threshold.c
@@ -0,0 +1,2535 @@
+/*
+ * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
+ *
+ * The license of this code is the same as for the source it was derived from.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "interfaces/sensor_threshold.h"
+
+#include <string.h>
+#ifdef G_OS_UNIX
+#  include <gio/gunixfdlist.h>
+#endif
+
+typedef struct
+{
+  GDBusArgInfo parent_struct;
+  gboolean use_gvariant;
+} _ExtendedGDBusArgInfo;
+
+typedef struct
+{
+  GDBusMethodInfo parent_struct;
+  const gchar *signal_name;
+  gboolean pass_fdlist;
+} _ExtendedGDBusMethodInfo;
+
+typedef struct
+{
+  GDBusSignalInfo parent_struct;
+  const gchar *signal_name;
+} _ExtendedGDBusSignalInfo;
+
+typedef struct
+{
+  GDBusPropertyInfo parent_struct;
+  const gchar *hyphen_name;
+  gboolean use_gvariant;
+} _ExtendedGDBusPropertyInfo;
+
+typedef struct
+{
+  GDBusInterfaceInfo parent_struct;
+  const gchar *hyphen_name;
+} _ExtendedGDBusInterfaceInfo;
+
+typedef struct
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  guint prop_id;
+  GValue orig_value; /* the value before the change */
+} ChangedProperty;
+
+static void
+_changed_property_free (ChangedProperty *data)
+{
+  g_value_unset (&data->orig_value);
+  g_free (data);
+}
+
+static gboolean
+_g_strv_equal0 (gchar **a, gchar **b)
+{
+  gboolean ret = FALSE;
+  guint n;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  if (g_strv_length (a) != g_strv_length (b))
+    goto out;
+  for (n = 0; a[n] != NULL; n++)
+    if (g_strcmp0 (a[n], b[n]) != 0)
+      goto out;
+  ret = TRUE;
+out:
+  return ret;
+}
+
+static gboolean
+_g_variant_equal0 (GVariant *a, GVariant *b)
+{
+  gboolean ret = FALSE;
+  if (a == NULL && b == NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+  if (a == NULL || b == NULL)
+    goto out;
+  ret = g_variant_equal (a, b);
+out:
+  return ret;
+}
+
+G_GNUC_UNUSED static gboolean
+_g_value_equal (const GValue *a, const GValue *b)
+{
+  gboolean ret = FALSE;
+  g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
+  switch (G_VALUE_TYPE (a))
+    {
+      case G_TYPE_BOOLEAN:
+        ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
+        break;
+      case G_TYPE_UCHAR:
+        ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
+        break;
+      case G_TYPE_INT:
+        ret = (g_value_get_int (a) == g_value_get_int (b));
+        break;
+      case G_TYPE_UINT:
+        ret = (g_value_get_uint (a) == g_value_get_uint (b));
+        break;
+      case G_TYPE_INT64:
+        ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
+        break;
+      case G_TYPE_UINT64:
+        ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
+        break;
+      case G_TYPE_DOUBLE:
+        {
+          /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
+          gdouble da = g_value_get_double (a);
+          gdouble db = g_value_get_double (b);
+          ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
+        }
+        break;
+      case G_TYPE_STRING:
+        ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
+        break;
+      case G_TYPE_VARIANT:
+        ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
+        break;
+      default:
+        if (G_VALUE_TYPE (a) == G_TYPE_STRV)
+          ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
+        else
+          g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
+        break;
+    }
+  return ret;
+}
+
+/* ------------------------------------------------------------------------
+ * Code for interface org.openbmc.SensorIntegerThreshold
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:SensorIntegerThreshold
+ * @title: SensorIntegerThreshold
+ * @short_description: Generated C code for the org.openbmc.SensorIntegerThreshold D-Bus interface
+ *
+ * This section contains code for working with the <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> D-Bus interface in C.
+ */
+
+/* ---- Introspection data for org.openbmc.SensorIntegerThreshold ---- */
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_thresholds_IN_ARG_lower_critical =
+{
+  {
+    -1,
+    (gchar *) "lower_critical",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_thresholds_IN_ARG_lower_warning =
+{
+  {
+    -1,
+    (gchar *) "lower_warning",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_thresholds_IN_ARG_upper_warning =
+{
+  {
+    -1,
+    (gchar *) "upper_warning",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_set_thresholds_IN_ARG_upper_critical =
+{
+  {
+    -1,
+    (gchar *) "upper_critical",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_threshold_method_info_set_thresholds_IN_ARG_pointers[] =
+{
+  &_sensor_integer_threshold_method_info_set_thresholds_IN_ARG_lower_critical,
+  &_sensor_integer_threshold_method_info_set_thresholds_IN_ARG_lower_warning,
+  &_sensor_integer_threshold_method_info_set_thresholds_IN_ARG_upper_warning,
+  &_sensor_integer_threshold_method_info_set_thresholds_IN_ARG_upper_critical,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_threshold_method_info_set_thresholds =
+{
+  {
+    -1,
+    (gchar *) "setThresholds",
+    (GDBusArgInfo **) &_sensor_integer_threshold_method_info_set_thresholds_IN_ARG_pointers,
+    NULL,
+    NULL
+  },
+  "handle-set-thresholds",
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo _sensor_integer_threshold_method_info_get_threshold_state_OUT_ARG_threshold_state =
+{
+  {
+    -1,
+    (gchar *) "threshold_state",
+    (gchar *) "i",
+    NULL
+  },
+  FALSE
+};
+
+static const _ExtendedGDBusArgInfo * const _sensor_integer_threshold_method_info_get_threshold_state_OUT_ARG_pointers[] =
+{
+  &_sensor_integer_threshold_method_info_get_threshold_state_OUT_ARG_threshold_state,
+  NULL
+};
+
+static const _ExtendedGDBusMethodInfo _sensor_integer_threshold_method_info_get_threshold_state =
+{
+  {
+    -1,
+    (gchar *) "getThresholdState",
+    NULL,
+    (GDBusArgInfo **) &_sensor_integer_threshold_method_info_get_threshold_state_OUT_ARG_pointers,
+    NULL
+  },
+  "handle-get-threshold-state",
+  FALSE
+};
+
+static const _ExtendedGDBusMethodInfo * const _sensor_integer_threshold_method_info_pointers[] =
+{
+  &_sensor_integer_threshold_method_info_set_thresholds,
+  &_sensor_integer_threshold_method_info_get_threshold_state,
+  NULL
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_integer_threshold_signal_info_warning =
+{
+  {
+    -1,
+    (gchar *) "Warning",
+    NULL,
+    NULL
+  },
+  "warning"
+};
+
+static const _ExtendedGDBusSignalInfo _sensor_integer_threshold_signal_info_critical =
+{
+  {
+    -1,
+    (gchar *) "Critical",
+    NULL,
+    NULL
+  },
+  "critical"
+};
+
+static const _ExtendedGDBusSignalInfo * const _sensor_integer_threshold_signal_info_pointers[] =
+{
+  &_sensor_integer_threshold_signal_info_warning,
+  &_sensor_integer_threshold_signal_info_critical,
+  NULL
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_threshold_lower_warning =
+{
+  {
+    -1,
+    (gchar *) "threshold_lower_warning",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "threshold-lower-warning",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_threshold_upper_warning =
+{
+  {
+    -1,
+    (gchar *) "threshold_upper_warning",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "threshold-upper-warning",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_threshold_upper_critical =
+{
+  {
+    -1,
+    (gchar *) "threshold_upper_critical",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "threshold-upper-critical",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo _sensor_integer_threshold_property_info_threshold_state =
+{
+  {
+    -1,
+    (gchar *) "threshold_state",
+    (gchar *) "i",
+    G_DBUS_PROPERTY_INFO_FLAGS_READABLE,
+    NULL
+  },
+  "threshold-state",
+  FALSE
+};
+
+static const _ExtendedGDBusPropertyInfo * const _sensor_integer_threshold_property_info_pointers[] =
+{
+  &_sensor_integer_threshold_property_info_threshold_lower_warning,
+  &_sensor_integer_threshold_property_info_threshold_upper_warning,
+  &_sensor_integer_threshold_property_info_threshold_upper_critical,
+  &_sensor_integer_threshold_property_info_threshold_state,
+  NULL
+};
+
+static const _ExtendedGDBusInterfaceInfo _sensor_integer_threshold_interface_info =
+{
+  {
+    -1,
+    (gchar *) "org.openbmc.SensorIntegerThreshold",
+    (GDBusMethodInfo **) &_sensor_integer_threshold_method_info_pointers,
+    (GDBusSignalInfo **) &_sensor_integer_threshold_signal_info_pointers,
+    (GDBusPropertyInfo **) &_sensor_integer_threshold_property_info_pointers,
+    NULL
+  },
+  "sensor-integer-threshold",
+};
+
+
+/**
+ * sensor_integer_threshold_interface_info:
+ *
+ * Gets a machine-readable description of the <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> D-Bus interface.
+ *
+ * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
+ */
+GDBusInterfaceInfo *
+sensor_integer_threshold_interface_info (void)
+{
+  return (GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct;
+}
+
+/**
+ * sensor_integer_threshold_override_properties:
+ * @klass: The class structure for a #GObject<!-- -->-derived class.
+ * @property_id_begin: The property id to assign to the first overridden property.
+ *
+ * Overrides all #GObject properties in the #SensorIntegerThreshold interface for a concrete class.
+ * The properties are overridden in the order they are defined.
+ *
+ * Returns: The last property id.
+ */
+guint
+sensor_integer_threshold_override_properties (GObjectClass *klass, guint property_id_begin)
+{
+  g_object_class_override_property (klass, property_id_begin++, "threshold-lower-warning");
+  g_object_class_override_property (klass, property_id_begin++, "threshold-upper-warning");
+  g_object_class_override_property (klass, property_id_begin++, "threshold-upper-critical");
+  g_object_class_override_property (klass, property_id_begin++, "threshold-state");
+  return property_id_begin - 1;
+}
+
+
+
+/**
+ * SensorIntegerThreshold:
+ *
+ * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>.
+ */
+
+/**
+ * SensorIntegerThresholdIface:
+ * @parent_iface: The parent interface.
+ * @handle_get_threshold_state: Handler for the #SensorIntegerThreshold::handle-get-threshold-state signal.
+ * @handle_set_thresholds: Handler for the #SensorIntegerThreshold::handle-set-thresholds signal.
+ * @get_threshold_lower_warning: Getter for the #SensorIntegerThreshold:threshold-lower-warning property.
+ * @get_threshold_state: Getter for the #SensorIntegerThreshold:threshold-state property.
+ * @get_threshold_upper_critical: Getter for the #SensorIntegerThreshold:threshold-upper-critical property.
+ * @get_threshold_upper_warning: Getter for the #SensorIntegerThreshold:threshold-upper-warning property.
+ * @critical: Handler for the #SensorIntegerThreshold::critical signal.
+ * @warning: Handler for the #SensorIntegerThreshold::warning signal.
+ *
+ * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>.
+ */
+
+typedef SensorIntegerThresholdIface SensorIntegerThresholdInterface;
+G_DEFINE_INTERFACE (SensorIntegerThreshold, sensor_integer_threshold, G_TYPE_OBJECT);
+
+static void
+sensor_integer_threshold_default_init (SensorIntegerThresholdIface *iface)
+{
+  /* GObject signals for incoming D-Bus method calls: */
+  /**
+   * SensorIntegerThreshold::handle-set-thresholds:
+   * @object: A #SensorIntegerThreshold.
+   * @invocation: A #GDBusMethodInvocation.
+   * @arg_lower_critical: Argument passed by remote caller.
+   * @arg_lower_warning: Argument passed by remote caller.
+   * @arg_upper_warning: Argument passed by remote caller.
+   * @arg_upper_critical: Argument passed by remote caller.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.setThresholds">setThresholds()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_threshold_complete_set_thresholds() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-set-thresholds",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, handle_set_thresholds),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    5,
+    G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
+
+  /**
+   * SensorIntegerThreshold::handle-get-threshold-state:
+   * @object: A #SensorIntegerThreshold.
+   * @invocation: A #GDBusMethodInvocation.
+   *
+   * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getThresholdState">getThresholdState()</link> D-Bus method.
+   *
+   * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call sensor_integer_threshold_complete_get_threshold_state() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
+   *
+   * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
+   */
+  g_signal_new ("handle-get-threshold-state",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, handle_get_threshold_state),
+    g_signal_accumulator_true_handled,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_BOOLEAN,
+    1,
+    G_TYPE_DBUS_METHOD_INVOCATION);
+
+  /* GObject signals for received D-Bus signals: */
+  /**
+   * SensorIntegerThreshold::warning:
+   * @object: A #SensorIntegerThreshold.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Warning">"Warning"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("warning",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, warning),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    0);
+
+  /**
+   * SensorIntegerThreshold::critical:
+   * @object: A #SensorIntegerThreshold.
+   *
+   * On the client-side, this signal is emitted whenever the D-Bus signal <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Critical">"Critical"</link> is received.
+   *
+   * On the service-side, this signal can be used with e.g. g_signal_emit_by_name() to make the object emit the D-Bus signal.
+   */
+  g_signal_new ("critical",
+    G_TYPE_FROM_INTERFACE (iface),
+    G_SIGNAL_RUN_LAST,
+    G_STRUCT_OFFSET (SensorIntegerThresholdIface, critical),
+    NULL,
+    NULL,
+    g_cclosure_marshal_generic,
+    G_TYPE_NONE,
+    0);
+
+  /* GObject properties for D-Bus properties: */
+  /**
+   * SensorIntegerThreshold:threshold-lower-warning:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_lower_warning">"threshold_lower_warning"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("threshold-lower-warning", "threshold_lower_warning", "threshold_lower_warning", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:threshold-upper-warning:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_upper_warning">"threshold_upper_warning"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("threshold-upper-warning", "threshold_upper_warning", "threshold_upper_warning", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:threshold-upper-critical:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_upper_critical">"threshold_upper_critical"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("threshold-upper-critical", "threshold_upper_critical", "threshold_upper_critical", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+  /**
+   * SensorIntegerThreshold:threshold-state:
+   *
+   * Represents the D-Bus property <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_state">"threshold_state"</link>.
+   *
+   * Since the D-Bus property for this #GObject property is readable but not writable, it is meaningful to read from it on both the client- and service-side. It is only meaningful, however, to write to it on the service-side.
+   */
+  g_object_interface_install_property (iface,
+    g_param_spec_int ("threshold-state", "threshold_state", "threshold_state", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+/**
+ * sensor_integer_threshold_get_threshold_lower_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_lower_warning">"threshold_lower_warning"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_threshold_lower_warning (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_threshold_lower_warning (object);
+}
+
+/**
+ * sensor_integer_threshold_set_threshold_lower_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_lower_warning">"threshold_lower_warning"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_threshold_lower_warning (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "threshold-lower-warning", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_threshold_upper_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_upper_warning">"threshold_upper_warning"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_threshold_upper_warning (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_threshold_upper_warning (object);
+}
+
+/**
+ * sensor_integer_threshold_set_threshold_upper_warning: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_upper_warning">"threshold_upper_warning"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_threshold_upper_warning (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "threshold-upper-warning", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_threshold_upper_critical: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_upper_critical">"threshold_upper_critical"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_threshold_upper_critical (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_threshold_upper_critical (object);
+}
+
+/**
+ * sensor_integer_threshold_set_threshold_upper_critical: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_upper_critical">"threshold_upper_critical"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_threshold_upper_critical (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "threshold-upper-critical", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_get_threshold_state: (skip)
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Gets the value of the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_state">"threshold_state"</link> D-Bus property.
+ *
+ * Since this D-Bus property is readable, it is meaningful to use this function on both the client- and service-side.
+ *
+ * Returns: The property value.
+ */
+gint 
+sensor_integer_threshold_get_threshold_state (SensorIntegerThreshold *object)
+{
+  return SENSOR_INTEGER_THRESHOLD_GET_IFACE (object)->get_threshold_state (object);
+}
+
+/**
+ * sensor_integer_threshold_set_threshold_state: (skip)
+ * @object: A #SensorIntegerThreshold.
+ * @value: The value to set.
+ *
+ * Sets the <link linkend="gdbus-property-org-openbmc-SensorIntegerThreshold.threshold_state">"threshold_state"</link> D-Bus property to @value.
+ *
+ * Since this D-Bus property is not writable, it is only meaningful to use this function on the service-side.
+ */
+void
+sensor_integer_threshold_set_threshold_state (SensorIntegerThreshold *object, gint value)
+{
+  g_object_set (G_OBJECT (object), "threshold-state", value, NULL);
+}
+
+/**
+ * sensor_integer_threshold_emit_warning:
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Warning">"Warning"</link> D-Bus signal.
+ */
+void
+sensor_integer_threshold_emit_warning (
+    SensorIntegerThreshold *object)
+{
+  g_signal_emit_by_name (object, "warning");
+}
+
+/**
+ * sensor_integer_threshold_emit_critical:
+ * @object: A #SensorIntegerThreshold.
+ *
+ * Emits the <link linkend="gdbus-signal-org-openbmc-SensorIntegerThreshold.Critical">"Critical"</link> D-Bus signal.
+ */
+void
+sensor_integer_threshold_emit_critical (
+    SensorIntegerThreshold *object)
+{
+  g_signal_emit_by_name (object, "critical");
+}
+
+/**
+ * sensor_integer_threshold_call_set_thresholds:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @arg_lower_critical: Argument to pass with the method invocation.
+ * @arg_lower_warning: Argument to pass with the method invocation.
+ * @arg_upper_warning: Argument to pass with the method invocation.
+ * @arg_upper_critical: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.setThresholds">setThresholds()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_call_set_thresholds_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_call_set_thresholds_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_threshold_call_set_thresholds (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "setThresholds",
+    g_variant_new ("(iiii)",
+                   arg_lower_critical,
+                   arg_lower_warning,
+                   arg_upper_warning,
+                   arg_upper_critical),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_threshold_call_set_thresholds_finish:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_call_set_thresholds().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_threshold_call_set_thresholds().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_set_thresholds_finish (
+    SensorIntegerThreshold *proxy,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_call_set_thresholds_sync:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @arg_lower_critical: Argument to pass with the method invocation.
+ * @arg_lower_warning: Argument to pass with the method invocation.
+ * @arg_upper_warning: Argument to pass with the method invocation.
+ * @arg_upper_critical: Argument to pass with the method invocation.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.setThresholds">setThresholds()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_call_set_thresholds() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_set_thresholds_sync (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "setThresholds",
+    g_variant_new ("(iiii)",
+                   arg_lower_critical,
+                   arg_lower_warning,
+                   arg_upper_warning,
+                   arg_upper_critical),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "()");
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_call_get_threshold_state:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getThresholdState">getThresholdState()</link> D-Bus method on @proxy.
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_call_get_threshold_state_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_call_get_threshold_state_sync() for the synchronous, blocking version of this method.
+ */
+void
+sensor_integer_threshold_call_get_threshold_state (
+    SensorIntegerThreshold *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  g_dbus_proxy_call (G_DBUS_PROXY (proxy),
+    "getThresholdState",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    callback,
+    user_data);
+}
+
+/**
+ * sensor_integer_threshold_call_get_threshold_state_finish:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @out_threshold_state: (out): Return location for return parameter or %NULL to ignore.
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_call_get_threshold_state().
+ * @error: Return location for error or %NULL.
+ *
+ * Finishes an operation started with sensor_integer_threshold_call_get_threshold_state().
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_get_threshold_state_finish (
+    SensorIntegerThreshold *proxy,
+    gint *out_threshold_state,
+    GAsyncResult *res,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_threshold_state);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_call_get_threshold_state_sync:
+ * @proxy: A #SensorIntegerThresholdProxy.
+ * @out_threshold_state: (out): Return location for return parameter or %NULL to ignore.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
+ *
+ * Synchronously invokes the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getThresholdState">getThresholdState()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_call_get_threshold_state() for the asynchronous version of this method.
+ *
+ * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
+ */
+gboolean
+sensor_integer_threshold_call_get_threshold_state_sync (
+    SensorIntegerThreshold *proxy,
+    gint *out_threshold_state,
+    GCancellable *cancellable,
+    GError **error)
+{
+  GVariant *_ret;
+  _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
+    "getThresholdState",
+    g_variant_new ("()"),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    cancellable,
+    error);
+  if (_ret == NULL)
+    goto _out;
+  g_variant_get (_ret,
+                 "(i)",
+                 out_threshold_state);
+  g_variant_unref (_ret);
+_out:
+  return _ret != NULL;
+}
+
+/**
+ * sensor_integer_threshold_complete_set_thresholds:
+ * @object: A #SensorIntegerThreshold.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.setThresholds">setThresholds()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_threshold_complete_set_thresholds (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("()"));
+}
+
+/**
+ * sensor_integer_threshold_complete_get_threshold_state:
+ * @object: A #SensorIntegerThreshold.
+ * @invocation: (transfer full): A #GDBusMethodInvocation.
+ * @threshold_state: Parameter to return.
+ *
+ * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-openbmc-SensorIntegerThreshold.getThresholdState">getThresholdState()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
+ *
+ * This method will free @invocation, you cannot use it afterwards.
+ */
+void
+sensor_integer_threshold_complete_get_threshold_state (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation,
+    gint threshold_state)
+{
+  g_dbus_method_invocation_return_value (invocation,
+    g_variant_new ("(i)",
+                   threshold_state));
+}
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorIntegerThresholdProxy:
+ *
+ * The #SensorIntegerThresholdProxy structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorIntegerThresholdProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorIntegerThresholdProxy.
+ */
+
+struct _SensorIntegerThresholdProxyPrivate
+{
+  GData *qdata;
+};
+
+static void sensor_integer_threshold_proxy_iface_init (SensorIntegerThresholdIface *iface);
+
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdProxy, sensor_integer_threshold_proxy, G_TYPE_DBUS_PROXY,
+                         G_ADD_PRIVATE (SensorIntegerThresholdProxy)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_proxy_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdProxy, sensor_integer_threshold_proxy, G_TYPE_DBUS_PROXY,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_proxy_iface_init));
+
+#endif
+static void
+sensor_integer_threshold_proxy_finalize (GObject *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  g_datalist_clear (&proxy->priv->qdata);
+  G_OBJECT_CLASS (sensor_integer_threshold_proxy_parent_class)->finalize (object);
+}
+
+static void
+sensor_integer_threshold_proxy_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 4);
+  info = _sensor_integer_threshold_property_info_pointers[prop_id - 1];
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);
+  if (info->use_gvariant)
+    {
+      g_value_set_variant (value, variant);
+    }
+  else
+    {
+      if (variant != NULL)
+        g_dbus_gvariant_to_gvalue (variant, value);
+    }
+  if (variant != NULL)
+    g_variant_unref (variant);
+}
+
+static void
+sensor_integer_threshold_proxy_set_property_cb (GDBusProxy *proxy,
+  GAsyncResult *res,
+  gpointer      user_data)
+{
+  const _ExtendedGDBusPropertyInfo *info = user_data;
+  GError *error;
+  GVariant *_ret;
+  error = NULL;
+  _ret = g_dbus_proxy_call_finish (proxy, res, &error);
+  if (!_ret)
+    {
+      g_warning ("Error setting property '%s' on interface org.openbmc.SensorIntegerThreshold: %s (%s, %d)",
+                 info->parent_struct.name, 
+                 error->message, g_quark_to_string (error->domain), error->code);
+      g_error_free (error);
+    }
+  else
+    {
+      g_variant_unref (_ret);
+    }
+}
+
+static void
+sensor_integer_threshold_proxy_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  const _ExtendedGDBusPropertyInfo *info;
+  GVariant *variant;
+  g_assert (prop_id != 0 && prop_id - 1 < 4);
+  info = _sensor_integer_threshold_property_info_pointers[prop_id - 1];
+  variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));
+  g_dbus_proxy_call (G_DBUS_PROXY (object),
+    "org.freedesktop.DBus.Properties.Set",
+    g_variant_new ("(ssv)", "org.openbmc.SensorIntegerThreshold", info->parent_struct.name, variant),
+    G_DBUS_CALL_FLAGS_NONE,
+    -1,
+    NULL, (GAsyncReadyCallback) sensor_integer_threshold_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);
+  g_variant_unref (variant);
+}
+
+static void
+sensor_integer_threshold_proxy_g_signal (GDBusProxy *proxy,
+  const gchar *sender_name G_GNUC_UNUSED,
+  const gchar *signal_name,
+  GVariant *parameters)
+{
+  _ExtendedGDBusSignalInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint n;
+  guint signal_id;
+  info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, signal_name);
+  if (info == NULL)
+    return;
+  num_params = g_variant_n_children (parameters);
+  paramv = g_new0 (GValue, num_params + 1);
+  g_value_init (&paramv[0], TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_value_set_object (&paramv[0], proxy);
+  g_variant_iter_init (&iter, parameters);
+  n = 1;
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_signal_emitv (paramv, signal_id, 0, NULL);
+  for (n = 0; n < num_params + 1; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static void
+sensor_integer_threshold_proxy_g_properties_changed (GDBusProxy *_proxy,
+  GVariant *changed_properties,
+  const gchar *const *invalidated_properties)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (_proxy);
+  guint n;
+  const gchar *key;
+  GVariantIter *iter;
+  _ExtendedGDBusPropertyInfo *info;
+  g_variant_get (changed_properties, "a{sv}", &iter);
+  while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, key);
+      g_datalist_remove_data (&proxy->priv->qdata, key);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+  g_variant_iter_free (iter);
+  for (n = 0; invalidated_properties[n] != NULL; n++)
+    {
+      info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, invalidated_properties[n]);
+      g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
+      if (info != NULL)
+        g_object_notify (G_OBJECT (proxy), info->hyphen_name);
+    }
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_threshold_lower_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "threshold_lower_warning");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_threshold_upper_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "threshold_upper_warning");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_threshold_upper_critical (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "threshold_upper_critical");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_proxy_get_threshold_state (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdProxy *proxy = SENSOR_INTEGER_THRESHOLD_PROXY (object);
+  GVariant *variant;
+  gint value = 0;
+  variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "threshold_state");
+  if (variant != NULL)
+    {
+      value = g_variant_get_int32 (variant);
+      g_variant_unref (variant);
+    }
+  return value;
+}
+
+static void
+sensor_integer_threshold_proxy_init (SensorIntegerThresholdProxy *proxy)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  proxy->priv = sensor_integer_threshold_proxy_get_instance_private (proxy);
+#else
+  proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyPrivate);
+#endif
+
+  g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), sensor_integer_threshold_interface_info ());
+}
+
+static void
+sensor_integer_threshold_proxy_class_init (SensorIntegerThresholdProxyClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusProxyClass *proxy_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize     = sensor_integer_threshold_proxy_finalize;
+  gobject_class->get_property = sensor_integer_threshold_proxy_get_property;
+  gobject_class->set_property = sensor_integer_threshold_proxy_set_property;
+
+  proxy_class = G_DBUS_PROXY_CLASS (klass);
+  proxy_class->g_signal = sensor_integer_threshold_proxy_g_signal;
+  proxy_class->g_properties_changed = sensor_integer_threshold_proxy_g_properties_changed;
+
+  sensor_integer_threshold_override_properties (gobject_class, 1);
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorIntegerThresholdProxyPrivate));
+#endif
+}
+
+static void
+sensor_integer_threshold_proxy_iface_init (SensorIntegerThresholdIface *iface)
+{
+  iface->get_threshold_lower_warning = sensor_integer_threshold_proxy_get_threshold_lower_warning;
+  iface->get_threshold_upper_warning = sensor_integer_threshold_proxy_get_threshold_upper_warning;
+  iface->get_threshold_upper_critical = sensor_integer_threshold_proxy_get_threshold_upper_critical;
+  iface->get_threshold_state = sensor_integer_threshold_proxy_get_threshold_state;
+}
+
+/**
+ * sensor_integer_threshold_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>. See g_dbus_proxy_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_proxy_new_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_proxy_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_integer_threshold_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_proxy_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_integer_threshold_proxy_new().
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>. See g_dbus_proxy_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_proxy_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+
+/**
+ * sensor_integer_threshold_proxy_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like sensor_integer_threshold_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call sensor_integer_threshold_proxy_new_for_bus_finish() to get the result of the operation.
+ *
+ * See sensor_integer_threshold_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+sensor_integer_threshold_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data)
+{
+  g_async_initable_new_async (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to sensor_integer_threshold_proxy_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with sensor_integer_threshold_proxy_new_for_bus().
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+/**
+ * sensor_integer_threshold_proxy_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusProxyFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like sensor_integer_threshold_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See sensor_integer_threshold_proxy_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdProxy): The constructed proxy object or %NULL if @error is set.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.openbmc.SensorIntegerThreshold", NULL);
+  if (ret != NULL)
+    return SENSOR_INTEGER_THRESHOLD (ret);
+  else
+    return NULL;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+/**
+ * SensorIntegerThresholdSkeleton:
+ *
+ * The #SensorIntegerThresholdSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * SensorIntegerThresholdSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #SensorIntegerThresholdSkeleton.
+ */
+
+struct _SensorIntegerThresholdSkeletonPrivate
+{
+  GValue *properties;
+  GList *changed_properties;
+  GSource *changed_properties_idle_source;
+  GMainContext *context;
+  GMutex lock;
+};
+
+static void
+_sensor_integer_threshold_skeleton_handle_method_call (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name,
+  const gchar *method_name,
+  GVariant *parameters,
+  GDBusMethodInvocation *invocation,
+  gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  _ExtendedGDBusMethodInfo *info;
+  GVariantIter iter;
+  GVariant *child;
+  GValue *paramv;
+  guint num_params;
+  guint num_extra;
+  guint n;
+  guint signal_id;
+  GValue return_value = G_VALUE_INIT;
+  info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
+  g_assert (info != NULL);
+  num_params = g_variant_n_children (parameters);
+  num_extra = info->pass_fdlist ? 3 : 2;  paramv = g_new0 (GValue, num_params + num_extra);
+  n = 0;
+  g_value_init (&paramv[n], TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_value_set_object (&paramv[n++], skeleton);
+  g_value_init (&paramv[n], G_TYPE_DBUS_METHOD_INVOCATION);
+  g_value_set_object (&paramv[n++], invocation);
+  if (info->pass_fdlist)
+    {
+#ifdef G_OS_UNIX
+      g_value_init (&paramv[n], G_TYPE_UNIX_FD_LIST);
+      g_value_set_object (&paramv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
+#else
+      g_assert_not_reached ();
+#endif
+    }
+  g_variant_iter_init (&iter, parameters);
+  while ((child = g_variant_iter_next_value (&iter)) != NULL)
+    {
+      _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
+      if (arg_info->use_gvariant)
+        {
+          g_value_init (&paramv[n], G_TYPE_VARIANT);
+          g_value_set_variant (&paramv[n], child);
+          n++;
+        }
+      else
+        g_dbus_gvariant_to_gvalue (child, &paramv[n++]);
+      g_variant_unref (child);
+    }
+  signal_id = g_signal_lookup (info->signal_name, TYPE_SENSOR_INTEGER_THRESHOLD);
+  g_value_init (&return_value, G_TYPE_BOOLEAN);
+  g_signal_emitv (paramv, signal_id, 0, &return_value);
+  if (!g_value_get_boolean (&return_value))
+    g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
+  g_value_unset (&return_value);
+  for (n = 0; n < num_params + num_extra; n++)
+    g_value_unset (&paramv[n]);
+  g_free (paramv);
+}
+
+static GVariant *
+_sensor_integer_threshold_skeleton_handle_get_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GError **error,
+  gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  GVariant *ret;
+  ret = NULL;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      g_value_init (&value, pspec->value_type);
+      g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
+      g_value_unset (&value);
+    }
+  return ret;
+}
+
+static gboolean
+_sensor_integer_threshold_skeleton_handle_set_property (
+  GDBusConnection *connection G_GNUC_UNUSED,
+  const gchar *sender G_GNUC_UNUSED,
+  const gchar *object_path G_GNUC_UNUSED,
+  const gchar *interface_name G_GNUC_UNUSED,
+  const gchar *property_name,
+  GVariant *variant,
+  GError **error,
+  gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  GValue value = G_VALUE_INIT;
+  GParamSpec *pspec;
+  _ExtendedGDBusPropertyInfo *info;
+  gboolean ret;
+  ret = FALSE;
+  info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_sensor_integer_threshold_interface_info.parent_struct, property_name);
+  g_assert (info != NULL);
+  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
+  if (pspec == NULL)
+    {
+      g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
+    }
+  else
+    {
+      if (info->use_gvariant)
+        g_value_set_variant (&value, variant);
+      else
+        g_dbus_gvariant_to_gvalue (variant, &value);
+      g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
+      g_value_unset (&value);
+      ret = TRUE;
+    }
+  return ret;
+}
+
+static const GDBusInterfaceVTable _sensor_integer_threshold_skeleton_vtable =
+{
+  _sensor_integer_threshold_skeleton_handle_method_call,
+  _sensor_integer_threshold_skeleton_handle_get_property,
+  _sensor_integer_threshold_skeleton_handle_set_property,
+  {NULL}
+};
+
+static GDBusInterfaceInfo *
+sensor_integer_threshold_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return sensor_integer_threshold_interface_info ();
+}
+
+static GDBusInterfaceVTable *
+sensor_integer_threshold_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
+{
+  return (GDBusInterfaceVTable *) &_sensor_integer_threshold_skeleton_vtable;
+}
+
+static GVariant *
+sensor_integer_threshold_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (_skeleton);
+
+  GVariantBuilder builder;
+  guint n;
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  if (_sensor_integer_threshold_interface_info.parent_struct.properties == NULL)
+    goto out;
+  for (n = 0; _sensor_integer_threshold_interface_info.parent_struct.properties[n] != NULL; n++)
+    {
+      GDBusPropertyInfo *info = _sensor_integer_threshold_interface_info.parent_struct.properties[n];
+      if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
+        {
+          GVariant *value;
+          value = _sensor_integer_threshold_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorIntegerThreshold", info->name, NULL, skeleton);
+          if (value != NULL)
+            {
+              g_variant_take_ref (value);
+              g_variant_builder_add (&builder, "{sv}", info->name, value);
+              g_variant_unref (value);
+            }
+        }
+    }
+out:
+  return g_variant_builder_end (&builder);
+}
+
+static gboolean _sensor_integer_threshold_emit_changed (gpointer user_data);
+
+static void
+sensor_integer_threshold_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (_skeleton);
+  gboolean emit_changed = FALSE;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    {
+      g_source_destroy (skeleton->priv->changed_properties_idle_source);
+      skeleton->priv->changed_properties_idle_source = NULL;
+      emit_changed = TRUE;
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+
+  if (emit_changed)
+    _sensor_integer_threshold_emit_changed (skeleton);
+}
+
+static void
+_sensor_integer_threshold_on_signal_warning (
+    SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("()"));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorIntegerThreshold", "Warning",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void
+_sensor_integer_threshold_on_signal_critical (
+    SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+
+  GList      *connections, *l;
+  GVariant   *signal_variant;
+  connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+
+  signal_variant = g_variant_ref_sink (g_variant_new ("()"));
+  for (l = connections; l != NULL; l = l->next)
+    {
+      GDBusConnection *connection = l->data;
+      g_dbus_connection_emit_signal (connection,
+        NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.openbmc.SensorIntegerThreshold", "Critical",
+        signal_variant, NULL);
+    }
+  g_variant_unref (signal_variant);
+  g_list_free_full (connections, g_object_unref);
+}
+
+static void sensor_integer_threshold_skeleton_iface_init (SensorIntegerThresholdIface *iface);
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdSkeleton, sensor_integer_threshold_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_ADD_PRIVATE (SensorIntegerThresholdSkeleton)
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_skeleton_iface_init));
+
+#else
+G_DEFINE_TYPE_WITH_CODE (SensorIntegerThresholdSkeleton, sensor_integer_threshold_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
+                         G_IMPLEMENT_INTERFACE (TYPE_SENSOR_INTEGER_THRESHOLD, sensor_integer_threshold_skeleton_iface_init));
+
+#endif
+static void
+sensor_integer_threshold_skeleton_finalize (GObject *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  guint n;
+  for (n = 0; n < 4; n++)
+    g_value_unset (&skeleton->priv->properties[n]);
+  g_free (skeleton->priv->properties);
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  if (skeleton->priv->changed_properties_idle_source != NULL)
+    g_source_destroy (skeleton->priv->changed_properties_idle_source);
+  g_main_context_unref (skeleton->priv->context);
+  g_mutex_clear (&skeleton->priv->lock);
+  G_OBJECT_CLASS (sensor_integer_threshold_skeleton_parent_class)->finalize (object);
+}
+
+static void
+sensor_integer_threshold_skeleton_get_property (GObject      *object,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec G_GNUC_UNUSED)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 4);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_value_copy (&skeleton->priv->properties[prop_id - 1], value);
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static gboolean
+_sensor_integer_threshold_emit_changed (gpointer user_data)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (user_data);
+  GList *l;
+  GVariantBuilder builder;
+  GVariantBuilder invalidated_builder;
+  guint num_changes;
+
+  g_mutex_lock (&skeleton->priv->lock);
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
+  g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));
+  for (l = skeleton->priv->changed_properties, num_changes = 0; l != NULL; l = l->next)
+    {
+      ChangedProperty *cp = l->data;
+      GVariant *variant;
+      const GValue *cur_value;
+
+      cur_value = &skeleton->priv->properties[cp->prop_id - 1];
+      if (!_g_value_equal (cur_value, &cp->orig_value))
+        {
+          variant = g_dbus_gvalue_to_gvariant (cur_value, G_VARIANT_TYPE (cp->info->parent_struct.signature));
+          g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);
+          g_variant_unref (variant);
+          num_changes++;
+        }
+    }
+  if (num_changes > 0)
+    {
+      GList *connections, *ll;
+      GVariant *signal_variant;
+      signal_variant = g_variant_ref_sink (g_variant_new ("(sa{sv}as)", "org.openbmc.SensorIntegerThreshold",
+                                           &builder, &invalidated_builder));
+      connections = g_dbus_interface_skeleton_get_connections (G_DBUS_INTERFACE_SKELETON (skeleton));
+      for (ll = connections; ll != NULL; ll = ll->next)
+        {
+          GDBusConnection *connection = ll->data;
+
+          g_dbus_connection_emit_signal (connection,
+                                         NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),
+                                         "org.freedesktop.DBus.Properties",
+                                         "PropertiesChanged",
+                                         signal_variant,
+                                         NULL);
+        }
+      g_variant_unref (signal_variant);
+      g_list_free_full (connections, g_object_unref);
+    }
+  else
+    {
+      g_variant_builder_clear (&builder);
+      g_variant_builder_clear (&invalidated_builder);
+    }
+  g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
+  skeleton->priv->changed_properties = NULL;
+  skeleton->priv->changed_properties_idle_source = NULL;
+  g_mutex_unlock (&skeleton->priv->lock);
+  return FALSE;
+}
+
+static void
+_sensor_integer_threshold_schedule_emit_changed (SensorIntegerThresholdSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, guint prop_id, const GValue *orig_value)
+{
+  ChangedProperty *cp;
+  GList *l;
+  cp = NULL;
+  for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)
+    {
+      ChangedProperty *i_cp = l->data;
+      if (i_cp->info == info)
+        {
+          cp = i_cp;
+          break;
+        }
+    }
+  if (cp == NULL)
+    {
+      cp = g_new0 (ChangedProperty, 1);
+      cp->prop_id = prop_id;
+      cp->info = info;
+      skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);
+      g_value_init (&cp->orig_value, G_VALUE_TYPE (orig_value));
+      g_value_copy (orig_value, &cp->orig_value);
+    }
+}
+
+static void
+sensor_integer_threshold_skeleton_notify (GObject      *object,
+  GParamSpec *pspec G_GNUC_UNUSED)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  g_mutex_lock (&skeleton->priv->lock);
+  if (skeleton->priv->changed_properties != NULL &&
+      skeleton->priv->changed_properties_idle_source == NULL)
+    {
+      skeleton->priv->changed_properties_idle_source = g_idle_source_new ();
+      g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);
+      g_source_set_callback (skeleton->priv->changed_properties_idle_source, _sensor_integer_threshold_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);
+      g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);
+      g_source_unref (skeleton->priv->changed_properties_idle_source);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+}
+
+static void
+sensor_integer_threshold_skeleton_set_property (GObject      *object,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  g_assert (prop_id != 0 && prop_id - 1 < 4);
+  g_mutex_lock (&skeleton->priv->lock);
+  g_object_freeze_notify (object);
+  if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))
+    {
+      if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)
+        _sensor_integer_threshold_schedule_emit_changed (skeleton, _sensor_integer_threshold_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);
+      g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);
+      g_object_notify_by_pspec (object, pspec);
+    }
+  g_mutex_unlock (&skeleton->priv->lock);
+  g_object_thaw_notify (object);
+}
+
+static void
+sensor_integer_threshold_skeleton_init (SensorIntegerThresholdSkeleton *skeleton)
+{
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
+  skeleton->priv = sensor_integer_threshold_skeleton_get_instance_private (skeleton);
+#else
+  skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonPrivate);
+#endif
+
+  g_mutex_init (&skeleton->priv->lock);
+  skeleton->priv->context = g_main_context_ref_thread_default ();
+  skeleton->priv->properties = g_new0 (GValue, 4);
+  g_value_init (&skeleton->priv->properties[0], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[1], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[2], G_TYPE_INT);
+  g_value_init (&skeleton->priv->properties[3], G_TYPE_INT);
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_threshold_lower_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[0]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_threshold_upper_warning (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[1]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_threshold_upper_critical (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[2]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static gint 
+sensor_integer_threshold_skeleton_get_threshold_state (SensorIntegerThreshold *object)
+{
+  SensorIntegerThresholdSkeleton *skeleton = SENSOR_INTEGER_THRESHOLD_SKELETON (object);
+  gint value;
+  g_mutex_lock (&skeleton->priv->lock);
+  value = g_value_get_int (&(skeleton->priv->properties[3]));
+  g_mutex_unlock (&skeleton->priv->lock);
+  return value;
+}
+
+static void
+sensor_integer_threshold_skeleton_class_init (SensorIntegerThresholdSkeletonClass *klass)
+{
+  GObjectClass *gobject_class;
+  GDBusInterfaceSkeletonClass *skeleton_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = sensor_integer_threshold_skeleton_finalize;
+  gobject_class->get_property = sensor_integer_threshold_skeleton_get_property;
+  gobject_class->set_property = sensor_integer_threshold_skeleton_set_property;
+  gobject_class->notify       = sensor_integer_threshold_skeleton_notify;
+
+
+  sensor_integer_threshold_override_properties (gobject_class, 1);
+
+  skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
+  skeleton_class->get_info = sensor_integer_threshold_skeleton_dbus_interface_get_info;
+  skeleton_class->get_properties = sensor_integer_threshold_skeleton_dbus_interface_get_properties;
+  skeleton_class->flush = sensor_integer_threshold_skeleton_dbus_interface_flush;
+  skeleton_class->get_vtable = sensor_integer_threshold_skeleton_dbus_interface_get_vtable;
+
+#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
+  g_type_class_add_private (klass, sizeof (SensorIntegerThresholdSkeletonPrivate));
+#endif
+}
+
+static void
+sensor_integer_threshold_skeleton_iface_init (SensorIntegerThresholdIface *iface)
+{
+  iface->warning = _sensor_integer_threshold_on_signal_warning;
+  iface->critical = _sensor_integer_threshold_on_signal_critical;
+  iface->get_threshold_lower_warning = sensor_integer_threshold_skeleton_get_threshold_lower_warning;
+  iface->get_threshold_upper_warning = sensor_integer_threshold_skeleton_get_threshold_upper_warning;
+  iface->get_threshold_upper_critical = sensor_integer_threshold_skeleton_get_threshold_upper_critical;
+  iface->get_threshold_state = sensor_integer_threshold_skeleton_get_threshold_state;
+}
+
+/**
+ * sensor_integer_threshold_skeleton_new:
+ *
+ * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>.
+ *
+ * Returns: (transfer full) (type SensorIntegerThresholdSkeleton): The skeleton object.
+ */
+SensorIntegerThreshold *
+sensor_integer_threshold_skeleton_new (void)
+{
+  return SENSOR_INTEGER_THRESHOLD (g_object_new (TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, NULL));
+}
+
+/* ------------------------------------------------------------------------
+ * Code for Object, ObjectProxy and ObjectSkeleton
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:Object
+ * @title: Object
+ * @short_description: Specialized GDBusObject types
+ *
+ * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.
+ */
+
+/**
+ * Object:
+ *
+ * The #Object type is a specialized container of interfaces.
+ */
+
+/**
+ * ObjectIface:
+ * @parent_iface: The parent interface.
+ *
+ * Virtual table for the #Object interface.
+ */
+
+typedef ObjectIface ObjectInterface;
+G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT));
+
+static void
+object_default_init (ObjectIface *iface)
+{
+  /**
+   * Object:sensor-integer-threshold:
+   *
+   * The #SensorIntegerThreshold instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link>, if any.
+   *
+   * Connect to the #GObject::notify signal to get informed of property changes.
+   */
+  g_object_interface_install_property (iface, g_param_spec_object ("sensor-integer-threshold", "sensor-integer-threshold", "sensor-integer-threshold", TYPE_SENSOR_INTEGER_THRESHOLD, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
+
+}
+
+/**
+ * object_get_sensor_integer_threshold:
+ * @object: A #Object.
+ *
+ * Gets the #SensorIntegerThreshold instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> on @object, if any.
+ *
+ * Returns: (transfer full): A #SensorIntegerThreshold that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
+ */
+SensorIntegerThreshold *object_get_sensor_integer_threshold (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+  if (ret == NULL)
+    return NULL;
+  return SENSOR_INTEGER_THRESHOLD (ret);
+}
+
+
+/**
+ * object_peek_sensor_integer_threshold: (skip)
+ * @object: A #Object.
+ *
+ * Like object_get_sensor_integer_threshold() but doesn't increase the reference count on the returned object.
+ *
+ * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>
+ *
+ * Returns: (transfer none): A #SensorIntegerThreshold or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
+ */
+SensorIntegerThreshold *object_peek_sensor_integer_threshold (Object *object)
+{
+  GDBusInterface *ret;
+  ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+  if (ret == NULL)
+    return NULL;
+  g_object_unref (ret);
+  return SENSOR_INTEGER_THRESHOLD (ret);
+}
+
+
+static void
+object_notify (GDBusObject *object, GDBusInterface *interface)
+{
+  _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);
+  /* info can be NULL if the other end is using a D-Bus interface we don't know
+   * anything about, for example old generated code in this process talking to
+   * newer generated code in the other process. */
+  if (info != NULL)
+    g_object_notify (G_OBJECT (object), info->hyphen_name);
+}
+
+/**
+ * ObjectProxy:
+ *
+ * The #ObjectProxy structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * ObjectProxyClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #ObjectProxy.
+ */
+
+static void
+object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
+{
+}
+
+static void
+object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface)
+{
+  iface->interface_added = object_notify;
+  iface->interface_removed = object_notify;
+}
+
+
+G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY,
+                         G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init));
+
+static void
+object_proxy_init (ObjectProxy *object G_GNUC_UNUSED)
+{
+}
+
+static void
+object_proxy_set_property (GObject      *gobject,
+  guint         prop_id,
+  const GValue *value G_GNUC_UNUSED,
+  GParamSpec   *pspec)
+{
+  G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+}
+
+static void
+object_proxy_get_property (GObject      *gobject,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  ObjectProxy *object = OBJECT_PROXY (gobject);
+  GDBusInterface *interface;
+
+  switch (prop_id)
+    {
+    case 1:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+      g_value_take_object (value, interface);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+object_proxy_class_init (ObjectProxyClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = object_proxy_set_property;
+  gobject_class->get_property = object_proxy_get_property;
+
+  g_object_class_override_property (gobject_class, 1, "sensor-integer-threshold");
+}
+
+/**
+ * object_proxy_new:
+ * @connection: A #GDBusConnection.
+ * @object_path: An object path.
+ *
+ * Creates a new proxy object.
+ *
+ * Returns: (transfer full): The proxy object.
+ */
+ObjectProxy *
+object_proxy_new (GDBusConnection *connection,
+  const gchar *object_path)
+{
+  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
+  g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
+  return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL));
+}
+
+/**
+ * ObjectSkeleton:
+ *
+ * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * ObjectSkeletonClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #ObjectSkeleton.
+ */
+
+static void
+object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
+{
+}
+
+
+static void
+object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface)
+{
+  iface->interface_added = object_notify;
+  iface->interface_removed = object_notify;
+}
+
+G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON,
+                         G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init)
+                         G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init));
+
+static void
+object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED)
+{
+}
+
+static void
+object_skeleton_set_property (GObject      *gobject,
+  guint         prop_id,
+  const GValue *value,
+  GParamSpec   *pspec)
+{
+  ObjectSkeleton *object = OBJECT_SKELETON (gobject);
+  GDBusInterfaceSkeleton *interface;
+
+  switch (prop_id)
+    {
+    case 1:
+      interface = g_value_get_object (value);
+      if (interface != NULL)
+        {
+          g_warn_if_fail (IS_SENSOR_INTEGER_THRESHOLD (interface));
+          g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
+        }
+      else
+        {
+          g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.openbmc.SensorIntegerThreshold");
+        }
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+object_skeleton_get_property (GObject      *gobject,
+  guint         prop_id,
+  GValue       *value,
+  GParamSpec   *pspec)
+{
+  ObjectSkeleton *object = OBJECT_SKELETON (gobject);
+  GDBusInterface *interface;
+
+  switch (prop_id)
+    {
+    case 1:
+      interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.openbmc.SensorIntegerThreshold");
+      g_value_take_object (value, interface);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+  }
+}
+
+static void
+object_skeleton_class_init (ObjectSkeletonClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = object_skeleton_set_property;
+  gobject_class->get_property = object_skeleton_get_property;
+
+  g_object_class_override_property (gobject_class, 1, "sensor-integer-threshold");
+}
+
+/**
+ * object_skeleton_new:
+ * @object_path: An object path.
+ *
+ * Creates a new skeleton object.
+ *
+ * Returns: (transfer full): The skeleton object.
+ */
+ObjectSkeleton *
+object_skeleton_new (const gchar *object_path)
+{
+  g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
+  return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL));
+}
+
+/**
+ * object_skeleton_set_sensor_integer_threshold:
+ * @object: A #ObjectSkeleton.
+ * @interface_: (allow-none): A #SensorIntegerThreshold or %NULL to clear the interface.
+ *
+ * Sets the #SensorIntegerThreshold instance for the D-Bus interface <link linkend="gdbus-interface-org-openbmc-SensorIntegerThreshold.top_of_page">org.openbmc.SensorIntegerThreshold</link> on @object.
+ */
+void object_skeleton_set_sensor_integer_threshold (ObjectSkeleton *object, SensorIntegerThreshold *interface_)
+{
+  g_object_set (G_OBJECT (object), "sensor-integer-threshold", interface_, NULL);
+}
+
+
+/* ------------------------------------------------------------------------
+ * Code for ObjectManager client
+ * ------------------------------------------------------------------------
+ */
+
+/**
+ * SECTION:ObjectManagerClient
+ * @title: ObjectManagerClient
+ * @short_description: Generated GDBusObjectManagerClient type
+ *
+ * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc.
+ */
+
+/**
+ * ObjectManagerClient:
+ *
+ * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API.
+ */
+
+/**
+ * ObjectManagerClientClass:
+ * @parent_class: The parent class.
+ *
+ * Class structure for #ObjectManagerClient.
+ */
+
+G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT);
+
+static void
+object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED)
+{
+}
+
+static void
+object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED)
+{
+}
+
+/**
+ * object_manager_client_get_proxy_type:
+ * @manager: A #GDBusObjectManagerClient.
+ * @object_path: The object path of the remote object (unused).
+ * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType.
+ * @user_data: User data (unused).
+ *
+ * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types.
+ *
+ * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy.
+ */
+GType
+object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, gpointer user_data G_GNUC_UNUSED)
+{
+  static gsize once_init_value = 0;
+  static GHashTable *lookup_hash;
+  GType ret;
+
+  if (interface_name == NULL)
+    return TYPE_OBJECT_PROXY;
+  if (g_once_init_enter (&once_init_value))
+    {
+      lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
+      g_hash_table_insert (lookup_hash, (gpointer) "org.openbmc.SensorIntegerThreshold", GSIZE_TO_POINTER (TYPE_SENSOR_INTEGER_THRESHOLD_PROXY));
+      g_once_init_leave (&once_init_value, 1);
+    }
+  ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));
+  if (ret == (GType) 0)
+    ret = G_TYPE_DBUS_PROXY;
+  return ret;
+}
+
+/**
+ * object_manager_client_new:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call object_manager_client_new_finish() to get the result of the operation.
+ *
+ * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+object_manager_client_new (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data)
+{
+  g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+}
+
+/**
+ * object_manager_client_new_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with object_manager_client_new().
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+/**
+ * object_manager_client_new_sync:
+ * @connection: A #GDBusConnection.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See object_manager_client_new() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_sync (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
+/**
+ * object_manager_client_new_for_bus:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
+ * @user_data: User data to pass to @callback.
+ *
+ * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
+ * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation.
+ *
+ * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.
+ */
+void
+object_manager_client_new_for_bus (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data)
+{
+  g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+}
+
+/**
+ * object_manager_client_new_for_bus_finish:
+ * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus().
+ * @error: Return location for error or %NULL
+ *
+ * Finishes an operation started with object_manager_client_new_for_bus().
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error)
+{
+  GObject *ret;
+  GObject *source_object;
+  source_object = g_async_result_get_source_object (res);
+  ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
+  g_object_unref (source_object);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+/**
+ * object_manager_client_new_for_bus_sync:
+ * @bus_type: A #GBusType.
+ * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
+ * @name: A bus name (well-known or unique).
+ * @object_path: An object path.
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL
+ *
+ * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.
+ *
+ * The calling thread is blocked until a reply is received.
+ *
+ * See object_manager_client_new_for_bus() for the asynchronous version of this constructor.
+ *
+ * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
+ */
+GDBusObjectManager *
+object_manager_client_new_for_bus_sync (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error)
+{
+  GInitable *ret;
+  ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
+  if (ret != NULL)
+    return G_DBUS_OBJECT_MANAGER (ret);
+  else
+    return NULL;
+}
+
+
diff --git a/interfaces/sensor_threshold.h b/interfaces/sensor_threshold.h
new file mode 100644
index 0000000..e3e5435
--- /dev/null
+++ b/interfaces/sensor_threshold.h
@@ -0,0 +1,387 @@
+/*
+ * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
+ *
+ * The license of this code is the same as for the source it was derived from.
+ */
+
+#ifndef __INTERFACES_SENSOR_THRESHOLD_H__
+#define __INTERFACES_SENSOR_THRESHOLD_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+
+/* ------------------------------------------------------------------------ */
+/* Declarations for org.openbmc.SensorIntegerThreshold */
+
+#define TYPE_SENSOR_INTEGER_THRESHOLD (sensor_integer_threshold_get_type ())
+#define SENSOR_INTEGER_THRESHOLD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD, SensorIntegerThreshold))
+#define IS_SENSOR_INTEGER_THRESHOLD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD))
+#define SENSOR_INTEGER_THRESHOLD_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_SENSOR_INTEGER_THRESHOLD, SensorIntegerThresholdIface))
+
+struct _SensorIntegerThreshold;
+typedef struct _SensorIntegerThreshold SensorIntegerThreshold;
+typedef struct _SensorIntegerThresholdIface SensorIntegerThresholdIface;
+
+struct _SensorIntegerThresholdIface
+{
+  GTypeInterface parent_iface;
+
+
+
+  gboolean (*handle_get_threshold_state) (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation);
+
+  gboolean (*handle_set_thresholds) (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical);
+
+  gint  (*get_threshold_lower_warning) (SensorIntegerThreshold *object);
+
+  gint  (*get_threshold_state) (SensorIntegerThreshold *object);
+
+  gint  (*get_threshold_upper_critical) (SensorIntegerThreshold *object);
+
+  gint  (*get_threshold_upper_warning) (SensorIntegerThreshold *object);
+
+  void (*critical) (
+    SensorIntegerThreshold *object);
+
+  void (*warning) (
+    SensorIntegerThreshold *object);
+
+};
+
+GType sensor_integer_threshold_get_type (void) G_GNUC_CONST;
+
+GDBusInterfaceInfo *sensor_integer_threshold_interface_info (void);
+guint sensor_integer_threshold_override_properties (GObjectClass *klass, guint property_id_begin);
+
+
+/* D-Bus method call completion functions: */
+void sensor_integer_threshold_complete_set_thresholds (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation);
+
+void sensor_integer_threshold_complete_get_threshold_state (
+    SensorIntegerThreshold *object,
+    GDBusMethodInvocation *invocation,
+    gint threshold_state);
+
+
+
+/* D-Bus signal emissions functions: */
+void sensor_integer_threshold_emit_warning (
+    SensorIntegerThreshold *object);
+
+void sensor_integer_threshold_emit_critical (
+    SensorIntegerThreshold *object);
+
+
+
+/* D-Bus method calls: */
+void sensor_integer_threshold_call_set_thresholds (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_threshold_call_set_thresholds_finish (
+    SensorIntegerThreshold *proxy,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_threshold_call_set_thresholds_sync (
+    SensorIntegerThreshold *proxy,
+    gint arg_lower_critical,
+    gint arg_lower_warning,
+    gint arg_upper_warning,
+    gint arg_upper_critical,
+    GCancellable *cancellable,
+    GError **error);
+
+void sensor_integer_threshold_call_get_threshold_state (
+    SensorIntegerThreshold *proxy,
+    GCancellable *cancellable,
+    GAsyncReadyCallback callback,
+    gpointer user_data);
+
+gboolean sensor_integer_threshold_call_get_threshold_state_finish (
+    SensorIntegerThreshold *proxy,
+    gint *out_threshold_state,
+    GAsyncResult *res,
+    GError **error);
+
+gboolean sensor_integer_threshold_call_get_threshold_state_sync (
+    SensorIntegerThreshold *proxy,
+    gint *out_threshold_state,
+    GCancellable *cancellable,
+    GError **error);
+
+
+
+/* D-Bus property accessors: */
+gint sensor_integer_threshold_get_threshold_lower_warning (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_threshold_lower_warning (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_threshold_upper_warning (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_threshold_upper_warning (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_threshold_upper_critical (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_threshold_upper_critical (SensorIntegerThreshold *object, gint value);
+
+gint sensor_integer_threshold_get_threshold_state (SensorIntegerThreshold *object);
+void sensor_integer_threshold_set_threshold_state (SensorIntegerThreshold *object, gint value);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_INTEGER_THRESHOLD_PROXY (sensor_integer_threshold_proxy_get_type ())
+#define SENSOR_INTEGER_THRESHOLD_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxy))
+#define SENSOR_INTEGER_THRESHOLD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyClass))
+#define SENSOR_INTEGER_THRESHOLD_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY, SensorIntegerThresholdProxyClass))
+#define IS_SENSOR_INTEGER_THRESHOLD_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY))
+#define IS_SENSOR_INTEGER_THRESHOLD_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_THRESHOLD_PROXY))
+
+typedef struct _SensorIntegerThresholdProxy SensorIntegerThresholdProxy;
+typedef struct _SensorIntegerThresholdProxyClass SensorIntegerThresholdProxyClass;
+typedef struct _SensorIntegerThresholdProxyPrivate SensorIntegerThresholdProxyPrivate;
+
+struct _SensorIntegerThresholdProxy
+{
+  /*< private >*/
+  GDBusProxy parent_instance;
+  SensorIntegerThresholdProxyPrivate *priv;
+};
+
+struct _SensorIntegerThresholdProxyClass
+{
+  GDBusProxyClass parent_class;
+};
+
+GType sensor_integer_threshold_proxy_get_type (void) G_GNUC_CONST;
+
+void sensor_integer_threshold_proxy_new (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_sync (
+    GDBusConnection     *connection,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+void sensor_integer_threshold_proxy_new_for_bus (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GAsyncReadyCallback  callback,
+    gpointer             user_data);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+SensorIntegerThreshold *sensor_integer_threshold_proxy_new_for_bus_sync (
+    GBusType             bus_type,
+    GDBusProxyFlags      flags,
+    const gchar         *name,
+    const gchar         *object_path,
+    GCancellable        *cancellable,
+    GError             **error);
+
+
+/* ---- */
+
+#define TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON (sensor_integer_threshold_skeleton_get_type ())
+#define SENSOR_INTEGER_THRESHOLD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeleton))
+#define SENSOR_INTEGER_THRESHOLD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonClass))
+#define SENSOR_INTEGER_THRESHOLD_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON, SensorIntegerThresholdSkeletonClass))
+#define IS_SENSOR_INTEGER_THRESHOLD_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON))
+#define IS_SENSOR_INTEGER_THRESHOLD_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_SENSOR_INTEGER_THRESHOLD_SKELETON))
+
+typedef struct _SensorIntegerThresholdSkeleton SensorIntegerThresholdSkeleton;
+typedef struct _SensorIntegerThresholdSkeletonClass SensorIntegerThresholdSkeletonClass;
+typedef struct _SensorIntegerThresholdSkeletonPrivate SensorIntegerThresholdSkeletonPrivate;
+
+struct _SensorIntegerThresholdSkeleton
+{
+  /*< private >*/
+  GDBusInterfaceSkeleton parent_instance;
+  SensorIntegerThresholdSkeletonPrivate *priv;
+};
+
+struct _SensorIntegerThresholdSkeletonClass
+{
+  GDBusInterfaceSkeletonClass parent_class;
+};
+
+GType sensor_integer_threshold_skeleton_get_type (void) G_GNUC_CONST;
+
+SensorIntegerThreshold *sensor_integer_threshold_skeleton_new (void);
+
+
+/* ---- */
+
+#define TYPE_OBJECT (object_get_type ())
+#define OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT, Object))
+#define IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT))
+#define OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_OBJECT, Object))
+
+struct _Object;
+typedef struct _Object Object;
+typedef struct _ObjectIface ObjectIface;
+
+struct _ObjectIface
+{
+  GTypeInterface parent_iface;
+};
+
+GType object_get_type (void) G_GNUC_CONST;
+
+SensorIntegerThreshold *object_get_sensor_integer_threshold (Object *object);
+SensorIntegerThreshold *object_peek_sensor_integer_threshold (Object *object);
+
+#define TYPE_OBJECT_PROXY (object_proxy_get_type ())
+#define OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_PROXY, ObjectProxy))
+#define OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_PROXY, ObjectProxyClass))
+#define OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_PROXY, ObjectProxyClass))
+#define IS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_PROXY))
+#define IS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_PROXY))
+
+typedef struct _ObjectProxy ObjectProxy;
+typedef struct _ObjectProxyClass ObjectProxyClass;
+typedef struct _ObjectProxyPrivate ObjectProxyPrivate;
+
+struct _ObjectProxy
+{
+  /*< private >*/
+  GDBusObjectProxy parent_instance;
+  ObjectProxyPrivate *priv;
+};
+
+struct _ObjectProxyClass
+{
+  GDBusObjectProxyClass parent_class;
+};
+
+GType object_proxy_get_type (void) G_GNUC_CONST;
+ObjectProxy *object_proxy_new (GDBusConnection *connection, const gchar *object_path);
+
+#define TYPE_OBJECT_SKELETON (object_skeleton_get_type ())
+#define OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_SKELETON, ObjectSkeleton))
+#define OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
+#define OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
+#define IS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_SKELETON))
+#define IS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_SKELETON))
+
+typedef struct _ObjectSkeleton ObjectSkeleton;
+typedef struct _ObjectSkeletonClass ObjectSkeletonClass;
+typedef struct _ObjectSkeletonPrivate ObjectSkeletonPrivate;
+
+struct _ObjectSkeleton
+{
+  /*< private >*/
+  GDBusObjectSkeleton parent_instance;
+  ObjectSkeletonPrivate *priv;
+};
+
+struct _ObjectSkeletonClass
+{
+  GDBusObjectSkeletonClass parent_class;
+};
+
+GType object_skeleton_get_type (void) G_GNUC_CONST;
+ObjectSkeleton *object_skeleton_new (const gchar *object_path);
+void object_skeleton_set_sensor_integer_threshold (ObjectSkeleton *object, SensorIntegerThreshold *interface_);
+
+/* ---- */
+
+#define TYPE_OBJECT_MANAGER_CLIENT (object_manager_client_get_type ())
+#define OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClient))
+#define OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
+#define OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
+#define IS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_MANAGER_CLIENT))
+#define IS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_MANAGER_CLIENT))
+
+typedef struct _ObjectManagerClient ObjectManagerClient;
+typedef struct _ObjectManagerClientClass ObjectManagerClientClass;
+typedef struct _ObjectManagerClientPrivate ObjectManagerClientPrivate;
+
+struct _ObjectManagerClient
+{
+  /*< private >*/
+  GDBusObjectManagerClient parent_instance;
+  ObjectManagerClientPrivate *priv;
+};
+
+struct _ObjectManagerClientClass
+{
+  GDBusObjectManagerClientClass parent_class;
+};
+
+GType object_manager_client_get_type (void) G_GNUC_CONST;
+
+GType object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data);
+
+void object_manager_client_new (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data);
+GDBusObjectManager *object_manager_client_new_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusObjectManager *object_manager_client_new_sync (
+    GDBusConnection        *connection,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error);
+
+void object_manager_client_new_for_bus (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GAsyncReadyCallback     callback,
+    gpointer                user_data);
+GDBusObjectManager *object_manager_client_new_for_bus_finish (
+    GAsyncResult        *res,
+    GError             **error);
+GDBusObjectManager *object_manager_client_new_for_bus_sync (
+    GBusType                bus_type,
+    GDBusObjectManagerClientFlags  flags,
+    const gchar            *name,
+    const gchar            *object_path,
+    GCancellable           *cancellable,
+    GError                **error);
+
+
+G_END_DECLS
+
+#endif /* __INTERFACES_SENSOR_THRESHOLD_H__ */
diff --git a/xml/sensor2.xml b/xml/sensor2.xml
new file mode 100644
index 0000000..8d2798a
--- /dev/null
+++ b/xml/sensor2.xml
@@ -0,0 +1,67 @@
+<node>
+	<interface name="org.openbmc.SensorInteger">
+		<method name="getValue">
+			<arg name="value" type="i" direction="out"/>
+		</method>
+		<method name="setValue">
+			<arg name="value" type="i" direction="in"/>
+		</method>
+		<method name="getUnits">
+			<arg name="units" type="s" direction="out"/>
+		</method>
+		<method name="setPollInterval">
+			<arg name="poll_interval" type="i" direction="in"/>
+		</method>
+		<method name="setConfigData">
+			<arg name="config" type="as" direction="in"/>
+		</method>
+
+                <property name="value" type="i" access="read"/>
+		<property name="units" type="s" access="read"/>
+
+		<property name="poll_interval" type="i" access="read"/>
+		<property name="config_data" type="as" access="read"/>
+
+		<property name="heatbeat" type="i" access="read"/>
+
+		<signal name="Changed">
+			<arg name="value" type="i"/>
+		</signal>
+		<signal name="Heartbeat">
+			<arg name="bus_name" type="s"/>
+		</signal>
+	</interface>
+        <interface name="org.openbmc.SensorString">
+                <method name="getValue">
+                        <arg name="value" type="s" direction="out"/>
+                </method>
+		<method name="getUnits">
+			<arg name="units" type="s" direction="out"/>
+		</method>
+                <property name="value" type="i" access="read"/>
+		<property name="units" type="s" access="read"/>
+                <signal name="Changed">
+                        <arg name="value" type="s"/>
+                </signal>
+        </interface>	
+	<interface name="org.openbmc.SensorIntegerThreshold">
+		<method name="set">
+			<arg name="lower_critical" type="i" direction="in"/>
+			<arg name="lower_warning"  type="i" direction="in"/>
+			<arg name="upper_warning"  type="i" direction="in"/>
+			<arg name="upper_critical" type="i" direction="in"/>
+		</method>
+		<method name="getState">
+			<arg name="state" type="i" direction="out"/>
+		</method>
+
+		<property name="lower_critical" type="i" access="read"/>
+		<property name="lower_warning"  type="i" access="read"/>
+		<property name="upper_warning"  type="i" access="read"/>
+		<property name="upper_critical" type="i" access="read"/>
+		<property name="state" type="i" access="read"/>
+
+		<signal name="Warning"/>
+		<signal name="Critical"/>
+	</interface>
+</node>
diff --git a/xml/sensor_threshold.xml b/xml/sensor_threshold.xml
new file mode 100644
index 0000000..022db64
--- /dev/null
+++ b/xml/sensor_threshold.xml
@@ -0,0 +1,21 @@
+<node>
+	<!--  Can I do have interfaces as children of other interfaces? -->
+	<interface name="org.openbmc.SensorIntegerThreshold">
+		<method name="setThresholds">
+			<arg name="lower_critical" type="i" direction="in"/>
+			<arg name="lower_warning"  type="i" direction="in"/>
+			<arg name="upper_warning"  type="i" direction="in"/>
+			<arg name="upper_critical" type="i" direction="in"/>
+		</method>
+		<method name="getThresholdState">
+			<arg name="threshold_state" type="i" direction="out"/>
+		</method>
+		<property name="threshold_lower_warning"  type="i" access="read"/>
+		<property name="threshold_upper_warning"  type="i" access="read"/>
+		<property name="threshold_upper_critical" type="i" access="read"/>
+		<property name="threshold_state" type="i" access="read"/>
+
+		<signal name="Warning"/>
+		<signal name="Critical"/>
+        </interface>
+</node>
