Custom Component - ESXi Stats

Thank you. No more dangling connections.

ok, i have loaded it as a custom, working great
how to define a second esxi server? can i just add the config again with another name?

I installed button-card via HACS
added this to ui-lovelace.yaml, even tried in raw editor

  - url: /www/community/button-card/button-card.js
    type: module

But when i try to make a manual card i just get No card type found, please explain more how you got it workingā€¦

Have you restarted the system in meantime? Iā€™m afraid it is required to make it visible to hassioā€¦

hi, really like the uptime sensors, but how to convert them to days? :slight_smile:

how to define a second esxi server? can i just add the config again with another name?

Only 1 host/vcenter supported at this time.

uptime sensors, but how to convert them to days?

You can break them out as separate sensors and use a value_template to convert hours to days.

ah ok, i cant add the code below just 2 x times in the config?
just change the host ip

esxi_stats:
  host: <ip or fqdn here>
  username: <username>
  password: <password>

No, you will get an error in your config.

Ah ok, donā€™t have the second one yetā€¦ Is it planned in future release?

Here is my original sensor updated to return value already converted to days, hours, minutes (I skipped seconds as plugin does not provide granular enough data):

      esx_host_uptime_hours:
        friendly_name: "ESXi Host Uptime"
        value_template: >-
          {{ ((states.sensor.esxi_stats_hosts.attributes["esxi.local"]["uptime_hours"] | float) * 3600) | float | timestamp_custom("%-jd %Hh %Mm") }}
        icon_template: mdi:timer-sand

Sample ouput would be like: 165d 07h 06m

1 Like

Aha, great , thnx

Yes between every change.

Hi @wxt9861

I was wrongā€¦ Iā€™m not seeing the connections to the esxi host but Iā€™m seeing a increase in the open TCP sockets like this:

hass       4804  4835 hass                  lyra    8u     sock                0,9      0t0   25339543 protocol: TCP
hass       4804  4835 hass                  lyra    9u     sock                0,9      0t0   25341959 protocol: TCP 
hass       4804  4835 hass                  lyra   14u     sock                0,9      0t0   25339582 protocol: TCP

it seems that the pyvmomi bug is still there.:frowning:

What are the states of the connections?

Edit: Because youā€™re not seeing a connection on the host makes me wonder if they are established connections or another state (time_wait, close_wait, something else?)

Hi,

Itā€™s something else :-). I guess that the socket handle is created but not connection is made. ā€œlsofā€ command shows the above ouput, but a netstat doesnt show a connection made.

v0.3 is out

Big thank you to @revin for his patience and willingness to help test vCenter licenses

New release includes the following additions:
1 - Service to control VM power states - this option will only be available if you have

  • vCenter
  • a full license on a stand-alone host

Unfortunately, a free ESXi license provides read-only API, so services for those hosts will not be registered.
Look for esxi_stats.vm_power service in home assistant and check documentation for usage here

2 - VM snapshot count. This will be available in the vm sensor attributes like other VM stats.

If you run into any issues, please submit a new issue here

2 Likes

Hi @wxt9861, Glad to help :wink:

Iā€™ve tested with 0.97.2 and 0.98.1. The sensor works perfectly on both versions. Iā€™ll try in a few days the service call once I return to home from holidays.

Thanks.

Hi @wxt9861

Iā€™ve been playing with the custom cards examples that you propose. Iā€™ve created a PR (my first one) to correct a mismatch that I found.

Also Iā€™ve found that if the VM name includes ā€œ-ā€ (mine always are lx- or wn- ) it doesnā€™t show any value on the custom card. Iā€™ve tried other names without the dash and it shows the data.

finally, Iā€™ve problems with size of the cards.

any idea how can I reduce the size? Iā€™ve been playing with the size option in the template without luck

Thanks!

You should be able to change the sizes of the cards. Have a look here.

styles:
  card:
    - height: 100px
    - width: 100px

And I think if you use the height/width option you might need to remove or change the aspect_ration option.

Helloā€¦ need your input on a few things.

  1. RIght now, when sending a service call, there is no way to tell (other than looking at debug logs) if the command was successful. I added persistent notifications to combat this problem - this is especially useful if you send a service call which takes a while to complete (like suspend/resume VM, or take snapshot with memory dump). Every time you send a service call, this notification will pop up.
    Is this something you want to have the ability to enabled/disable via configuration?

  2. What are some of your snapshot use cases, specifically when it comes to removing snapshots? Taking snapshots is easy, but removing snapshots via the API requires information which you might not have on-hand (like a snapshot name/id). To keep things simple Iā€™m thinking to have the following options:

    • remove all snapshots
    • remove the oldest snapshot
    • remove the youngest snapshot

What do you think?