🆕 PiKVM Integration for Home Assistant

PiKVM Integration for Home Assistant :rocket:

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

I’m excited to announce a new custom integration for Home Assistant: PiKVM Integration! This integration allows you to monitor your PiKVM devices seamlessly from within Home Assistant. This integration brings powerful monitoring capabilities right to your Home Assistant dashboard.

Key Features:

  • CPU Temperature Monitoring: Keep an eye on your PiKVM’s CPU temperature.
  • Fan Speed Tracking: Monitor the fan speed to ensure optimal cooling.
  • Device Throttling Status: Check if your PiKVM is being throttled due to overheating or power issues.
  • MSD Status and Storage Monitoring: Track the status and storage of your Mass Storage Device.
  • Service Monitoring: Keep tabs on additional PiKVM services like IPMI, Janus, VNC, and Webterm.

image

image

Installation:

Automagic Installation via HACS:

Due to a current issue with HACS hitting some rate limit and no longer accepting contributions, you must manually add this repository to use it with HACS.

Use the Home Assistant My link to add this repository to HACS.

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

Manual Installation:

  1. Download the custom_components folder from the GitHub repository.
  2. Copy the pikvm folder into your Home Assistant custom_components directory.
  3. Restart Home Assistant.

Configuration:

Both DHCP and Standard data entry config flows are available. DHCP will automatically detect your device and either add it, or request additional information.

Configuration via Standard Config Flow

  1. Go to Configuration > Integrations in Home Assistant.
  2. Click on the “+ Add Integration” button.
  3. Search for “PiKVM” and follow the setup instructions.

Automatic configuration via DHCP

  1. Reboot PiKVM or re-plug the PiKVM ethernet cable.
  2. Wait 15s and check Settings>Devices for any additional steps.

Troubleshooting:

  • Ensure your PiKVM device is accessible from your Home Assistant instance.
  • Double-check that you have provided the correct URL, username, and password.
  • Review Home Assistant logs for any error messages related to the PiKVM integration.

Contributing:

Contributions are welcome! Fork the GitHub repository and open a pull request with your improvements.

To contribute your own changes, it’s super easy to get started.

  1. Clone the Repository: Clone the repository to your Home Assistant /config directory.
cd /config;
git clone https://github.com/adamoutler/pikvm-homeassistant-integration;
  1. Open with VSCode: Use Visual Studio Code with SSH to open the repository workspace in /config/pikvm-homeassistant-integration/.vscode/.
    Note: this works best in Home Assistant OS with Advanced SSH Addon.
    3 Use the IDE: Assistive scripts are built into the repository so you can just F1->Tasks->Link the code, and then F1->Tasks->Restart home assistant.

Join the Discussion:

I’m looking forward to your feedback and seeing how you utilize this integration. Feel free to share your automations, ask questions, or suggest features.

V 0.3 is available.

  • Fixed sensor unavailable when using MSD
  • Added temp sensor localization
  • Fixed database warning when many files are on MSD.

Create a management dashboard

  1. Create a new dashboard
  2. Add a Template Card
  3. Use the “Use Code Editor” option
  4. Paste the following in:
type: markdown
title: PiKVM CPU Temperatures
content: >
  {% set domain = 'sensor' %}
  {% set suffix = 'cpu_temp' %}
  {% set entities = states[domain] | selectattr('entity_id', 'search', suffix) %}
  {% for entity in entities %}
    {% set device_id = device_id(entity.entity_id) %}
    {% if device_id is not none %}
      {% set device_name = device_attr(device_id, 'name') %}
   **{{ device_name if device_name is not none else 'Unknown Device' }}**: {{ state_attr(entity.entity_id, 'ip') }}
    {% endif %}
  {% endfor %}

Is it incompatible with 2FA?

1 Like

No. It cannot handle 2FA. The system would require your original TOTP code or API keys to handle that. It would be a bad idea to store the TOTP generator password outside of a password manager. Currently API keys are not implemented in PiKVM. I don’t have a good work-around for TOTP users.

1 Like

It’s working now if you append the 2FA code to the password when setting it up!

With enabled 2FA, you will need to add the one-time code to the password without spaces. That is, if the password is foobar and the code is 123456 , then you need to use foobar123456 as the password.

Right, that will work temporarily. Upon restarting PiKVM or HA, you’ll need to use the configure button to change the password.

yeah… it’s not permanent…

1 Like

image
Is anyone getting this error after trying to add an integration?

Please share relevant logs from settings>system>logs

I create issue on github.

Here log:

Source: /usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py:421
First occurred: 08:59:06 (6 occurrences)
Last logged: 09:22:58

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 70, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 172, in post
    return await self._post_impl(request, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 179, in _post_impl
    return await super()._post_impl(request, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl
    result = await self._flow_mgr.async_init(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1262, in async_init
    flow, result = await self._async_init(flow_id, handler, context, data)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1292, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pikvm_ha/config_flow.py", line 114, in async_step_user
    self.translations = await get_translations(self.hass, self.hass.config.language, DOMAIN)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/pikvm_ha/utils.py", line 35, in get_translations
    translations = await async_get_translations(language, "config")
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: async_get_translations() missing 1 required positional argument: 'category'```

After downgrade to 0.3 version all works

After i downgrade version to 0.3 from HACS
Add PiKVM integration
Update PiKVM to 0.4
All works

1 Like

Any chance you’re planning to add power commands (like soft power, hard power, etc.?). I know it’s just a web API call. I’m trying to create an energy efficient way of waking/sleeping some of my network headless PCs currently controlled by PiKVM. Automating with HA would be ideal.

Yes. Maxim and I talked. My roadmap is dependent on the PiKVM itself.

  1. Max will be implementing ZeroConf.
  2. New version of Integration will support ZeroConf (1-day)
  3. Unit Tests will verify 100% code coverage of Config Flow. (A few days)
  4. Short maintenance period to ensure we have no issues.(Maybe a week or two)
  5. Submit to Home Assistant Core.(Month of code review)

At this point, adding features will occur in the current HACS integration and be ported to HA core. HA devs state in docs that it’s best to stick with sensors only for initial integration to HA.

Some upcoming features after step 5:

  • Power Controls buttons
  • Live stream (screenshot+video)
  • Send keys actions
  • GPIO indicators+switches
  • UI controls such as mouse jiggler
  • Maybe terminal commands eg. pikvm-update
  • Anything else

Currently I’m holding back on any changes until about a week after we get ZeroConf.