2024.2: More voice, more icons, more integrations, more... everything!

After this update my Python Command line sensors stopped working with this error… This was pulling info on my projector lamp and power status. Now im not sure why its not working.

  • Command failed (with return code 1): python3 /config/python_scripts/cli.py ‘-p’ ‘192.168.30.139’ ‘status’
  • Command failed (with return code 1): python3 /config/python_scripts/cli.py ‘-p’ ‘192.168.30.139’ ‘lamps’
  • Command failed (with return code 1): python3 /config/python_scripts/cli.py ‘-p’ ‘192.168.30.139’ ‘power’
  • Command failed (with return code 1): python3 /config/python_scripts/cli.py ‘-p’ ‘192.168.30.139’ ‘errors’

Python was updated in 2024.2 , maybe your scripts are not compatible anymore…

I rolled my homeassistant version back to 2024.1.6 and the python command line sensor is working in that verson. Not sure why its not in the new 2024.2 version

Check your scripts against the new python
Probably a package not compatible

Hmm, not sure what you mean… what should I look for exactly?

In your script, check the requirements… Probably the imports

hmm this is the script.

import argparse

try:
from ConfigParser import (
NoSectionError,
SafeConfigParser as ConfigParser
)
except ImportError:
from configparser import (
NoSectionError,
SafeConfigParser as ConfigParser
)

from getpass import getpass
from os import path
import sys

import appdirs

from pypjlink import Projector
from pypjlink import projector
from pypjlink.cliutils import make_command, print_error

def cmd_power(p, state=None):
if state is None:
print(p.get_power())
else:
p.set_power(state)

def cmd_input(p, source, number):
if source is None:
source, number = p.get_input()
print(source, number)
else:
p.set_input(source, number)

def cmd_inputs(p):
for source, number in p.get_inputs():
print(‘%s-%s’ % (source, number))

def cmd_mute_state(p):
video, audio = p.get_mute()
print(‘video:’, ‘muted’ if video else ‘unmuted’)
print(‘audio:’, ‘muted’ if audio else ‘unmuted’)

def cmd_mute(p, what):
if what is None:
return cmd_mute_state(p)
what = {
‘video’: projector.MUTE_VIDEO,
‘audio’: projector.MUTE_AUDIO,
‘all’: projector.MUTE_VIDEO | projector.MUTE_AUDIO,
}[what]
p.set_mute(what, True)

def cmd_unmute(p, what):
if what is None:
return cmd_mute_state(p)
what = {
‘video’: projector.MUTE_VIDEO,
‘audio’: projector.MUTE_AUDIO,
‘all’: projector.MUTE_VIDEO | projector.MUTE_AUDIO,
}[what]
p.set_mute(what, False)

def cmd_info(p):
info = [
(‘Name’, p.get_name()),
(‘Manufacturer’, p.get_manufacturer()),
(‘Product Name’, p.get_product_name()),
(‘Other Info’, p.get_other_info())
]
for key, value in info:
print(‘%s: %s’ % (key, value))

def cmd_lamps(p):
for i, (time, state) in enumerate(p.get_lamps(), 1):
print(‘Lamp %d: %s (%d hours)’ % (
i,
‘on’ if state else ‘off’,
time,
))

def cmd_status(p):
for i, (time, state) in enumerate(p.get_lamps(), 1):
print(‘%d’ % (
time,
))

def cmd_errors(p):
for what, state in p.get_errors().items():
print(‘%s: %s’ % (what, state))

def make_parser():
parser = argparse.ArgumentParser()
parser.add_argument(‘-p’, ‘–projector’)

sub = parser.add_subparsers(dest='command', title='command')
sub.required = True

power = make_command(sub, 'power', cmd_power)
power.add_argument('state', nargs='?', choices=('on', 'off'))

inpt = make_command(sub, 'input', cmd_input)
inpt.add_argument('source', nargs='?', choices=projector.SOURCE_TYPES)
inpt.add_argument('number', nargs='?', choices='123456789', default='1')

make_command(sub, 'inputs', cmd_inputs)

mute = make_command(sub, 'mute', cmd_mute)
mute.add_argument('what', nargs='?', choices=('video', 'audio', 'all'))

unmute = make_command(sub, 'unmute', cmd_unmute)
unmute.add_argument('what', nargs='?', choices=('video', 'audio', 'all'))

make_command(sub, 'info', cmd_info)
make_command(sub, 'lamps', cmd_lamps)
make_command(sub, 'status', cmd_status)
make_command(sub, 'errors', cmd_errors)

return parser

def resolve_projector(projector):
password = None

# host:port
if projector is not None and ':' in projector:
    host, port = projector.rsplit(':', 1)
    port = int(port)

# maybe defined in config
else:
    appdir = appdirs.user_data_dir('pjlink')
    conf_file = path.join(appdir, 'pjlink.conf')

    try:
        config = ConfigParser({'port': '4352', 'password': ''})
        with open(conf_file, 'r') as f:
            config.readfp(f)

        section = projector
        if projector is None:
            section = 'default'

        host = config.get(section, 'host')
        port = config.getint(section, 'port')
        password = config.get(section, 'password') or None

    except (NoSectionError, IOError):
        if projector is None:
            raise KeyError('No default projector defined in %s' % conf_file)

        # no config file, or no projector defined for this host
        # thus, treat the projector as a hostname w/o port
        host = projector
        port = 4352


return host, port, password

def main():
parser = make_parser()
args = parser.parse_args()

kwargs = dict(args._get_kwargs())
func = kwargs.pop('__func__')
kwargs.pop('command', None)

projector = kwargs.pop('projector')
host, port, password = resolve_projector(projector)

if not password:
    password = getpass

proj = Projector.from_address(host, port)
rv = proj.authenticate(password)
if rv is False:
    print_error('Incorrect password.')
    return

func(proj, **kwargs)

if name == ‘main’:
main()

Run the script in a terminal, and troubleshoot there

so when i try to do that from homeassistant it says python command not found… but on the older version of homeassistant version 2024.1 it works

As @pergola.fabio already mentioned check your scripts for incompatible packages.
You can also give the logger a try, maybe it reveals some new insights…

service: logger.set_level
data: 
 python_script: info

Unfortunately, 2024.2.2 has significantly increased the memory usage on my Home Assistant OS system (Rpi4 8GB Ram, w SSD). From 10-20% to 35-60%.

Unused RAM is wasted RAM.

9 Likes

ABSOLUTELY true, Tom… but when you’re borderline…

I started getting random memory exhaustion crashes every 8-10 hours after 2024.2.x (I was surviving a week or so previously, I’m pretty sure one of my custom integrations has a memory leak but I didn’t have time to chase)

finally forced me into a NUC.

3 Likes

I did notice the new release uses more memory. I would like the ability to disable more components I don’t use like voice assist.

I run home assistant on a NanoPi Neo with 512MiB RAM. I was on 2022.7 for the last 18 months. I upgraded to 2024.1 recently because yaml editing broke on iOS when I upgraded to ios 16.x, but this was fixed in HA recently.

1 Like

Now that this came up, i actually checked my usage ( in Ha-Settings/system )
only about 100MB increase ( of 2GB total ), CPU at an average 1-2%, about as usual

However, i have also just added 1 High-res Cam, 2plugs and a handful of template sensors, and 2 dusins custom:buttons.

I Opened ( Beside the cpu/ram -hardware page in 1 tab ) 1 tab, with 6 cams, another tab the Overview (+2000 rows and 2 dusins Buttons-cards, with twice as many templates, and yet another tab (View ) +1000 rows , with only half amount of custem-buttons, and templates

CPU topped at 20% and went down to average 8-9%
RAM topped around 48% and went down to average of 45%

closed the 6 cams Tab, only did 1 % on CPU and a half to 1, on the Ram ?, that i found weird !

Waited 5 min, still same, Then i Closed the +2000 rows Overview, and both cpu/ram dropped right back in the bottom ! , now with only tha Hardware-tab and +1000row View opened

I Opened the cam-view again , boom Up ( Obviously ) same behavior as before ( Nothing strange about that )
+10% cpu
+45% ram

Closed it again, as before only slight decrease !

So what caused it to keep up before, Until i closed +2000row view ?

i closed +1000row(view)

And it released and dropped to 1-2% vs 44%

However, i guess the HIGH usage view ( cams ) wold eventually have been released, if i had clicked around in another View.
Actually i have seen this behavior ( Guess it’s quite normal ) on my views with graphs also.

For the same reason i have started to “hide” graphs and certain cams and even quite some custom:button-cards in " yet-another-expander-card " … View loads faster, and usage is lower, unless ofcause you expand all :grin:

So if anyone for some reason wonder, Graphs And Cams are resource-crawing, High-Res cams obviously higher

And sometimes it seems the memory handler need a little help, to release ( or maybe patience , which i don’t have so much of ) :crazy_face:

1 Like

If you have not installed the whisper/piper/wake word add-ons and integrations it is not enabled.

That depends on the amount of ram installed :rofl:

More isn’t always better

Correct. I have 8GB in the system I am running HA OS on (just because it was there). It runs about 20% use max. That’s 6GB of wasted RAM.

100% agree…I did competitive PC overclocking for a minute (expensive hobby) and it’s silly quad channel ram actually slows a pc down because memory controllers are bottlenecking performance. I love the simplicity of the hardware required to run HA. Folks like you and others make this an amazing endeavor !!!

Definitely has become an addiction for me to learn as much as possible.

I depend heavily on the Proximity integration and initially was annoyed by the changes as well. But after getting to make sense of them actually got to like it better now. One of the benefits is that now I can calculate the speed directly from the distance sensor while before I had to create an intermediate sensor that fed my derivative.