Need help "customizing" the modem_callerid component

I’ve made an enhancement to the existing modem_callerid sensor.py script. Since so many calls come in as “Wireless Caller” and other obfuscated names, I created an enhancement that queries a local database where I have positioned known numbers with actual names. Now, when a call comes in for a number I’ve recorded in the database, instead of the custom Alexa component announcing a call from “Wireless Caller”, I get an announcement of who it really is. Sweet.

The problem is, to achieve this customization, all I did was modify the modem_callerid sensor component in situ here: /usr/src/homeassistant/homeassistant/components/modem_callerid/sensor.py

While this works, it’s not ideal since updates to the HA docker container overlay my changes, forcing me to reapply the customization after the update.

Can anyone explain to me how to configure the existing modem_callerid component in the custom component directory so that I can then apply my tweaks in a more durable manner? I took a run at it, but, not being skilled in creating custom components, it didn’t work.

Larry

What about submitting a change to the base code? If the sensor.py component were to look for a file in the /config directory and use that if it existed, it should be an easy enhancement.

I doubt a PR for the specific change described by the OP would be accepted. There are already ways to perform table lookups from Home Assistant’s configuration. The methods that currently exist are all sucky in one way or another. In some cases, any change to the table requires restarting HA (not just reload scripts or automations, but a complete restart). In other cases, the amount of glue required is error-prone, or large. Etc… However, if the issue of performing table lookups is going to be improved, we need a general solution, not a solution specific to just one sensor.

My question still holds. What if I want to modify the behavior of an existing module, like the modem_callerid sensor, without waiting for an official enhancement that may never happen?

There must be a way to set up an existing component in the custom component section, but I am not exactly sure what all the requirements are to make it work.

Try this…

https://developers.home-assistant.io/docs/en/creating_component_loading.html

You can override a built-in component by having a component with the same name in your config/custom_components folder. If the built-in component is inside a subfolder, take care to place your customization in a folder with the same name in config/custom_components/folder . Note that overriding built-in components is not recommended and will probably break things!

Thanks! I’ll try that. I didn’t think about replicating the folder structure within the custom component directory.

Thanks! That actually worked.

This is exactly what I am after, have you released your custom component code?