hubitat2prom/Controllers/HubitatController.cs
/// <summary>
/// Get the Prometheus exporter values for a specific device configured on the Hubitat hub.
/// </summary>
/// <returns>
/// A valid response looks something like this:
/// <example>
/// switch{device_name="bathroom"} 0.0
/// </example>
/// </returns>
Get the Prometheus exporter values for a specific device configured on the Hubitat hub.
Get the Prometheus exporter values for a specific device configured on the Hubitat hub .
[HttpGet]
    [Route("/metrics/{deviceId:int}")]
    public async Task<ContentResult> GetMetrics(int deviceId)
    {
        var deviceDetails = await _hubitat.DeviceDetails(deviceId);
        var responseContent = new StringBuilder();
        var deviceAttributes = HubitatDeviceMetrics.Export(new[] { deviceDetails }, HubitatEnv.Instance.HE_METRICS);
        foreach (var deviceAttribute in deviceAttributes)
        {
            responseContent.AppendLine(deviceAttribute.ToString());
        }
        return new ContentResult
        {
            Content = responseContent.ToString()
        };
    }
[ HttpGet ] [ Route ( " " ) ] public async Task < ContentResult > GetMetrics ( int deviceId ) { var deviceDetails = await _hubitat . DeviceDetails ( deviceId ) ; var responseContent = new StringBuilder ( ) ; var deviceAttributes = HubitatDeviceMetrics . Export ( new [ ] { deviceDetails } , HubitatEnv . Instance . HE_METRICS ) ; foreach ( var deviceAttribute in deviceAttributes ) { responseContent . AppendLine ( deviceAttribute . ToString ( ) ) ; } return new ContentResult { Content = responseContent . ToString ( ) } ; }
Get the Prometheus exporter values for a specific device configured on the Hubitat hub.
Get the Prometheus exporter values for a specific device configured on the Hubitat hub .
A valid response looks something like this.

switch{device_name="bathroom"} 0.0
A valid response looks something like this . switch { device_name = " bathroom " } 0 . 0
deviceId
int