Skip to content

[Feature Request] Possibility to add sensorname prefix #3

@dflvunoooooo

Description

@dflvunoooooo

It would be great to add the possibility to add a prefix to the entity names of the sensors. I will install this on more than one machine and it would be terrible if I had to change every single sensor in home assistant. Here is a config option which lets one choose to set a prefix:

# Define sensor prefix. Options: 0 = none (default and if not 1 or string), 1 = hostname, custom if string
SENSOR_PREFIX_OPTION=0

And here is a function which checks if the option is set and runs itself:

sensor_prefix_generator() {
    if [ $SENSOR_PREFIX_OPTION == "0" ]; then
        SENSOR_PREFIX=""
    elif [ $SENSOR_PREFIX_OPTION == "1" ]; then
        SENSOR_PREFIX=$(cat /proc/sys/kernel/hostname)
    else 
        SENSOR_PREFIX=$SENSOR_PREFIX_OPTION
    fi
    
}
sensor_prefix_generator

The variable SENSOR_PREFIX would have to be added to the sensor names.

I am not good at programming, and I am not yet very familiarly with this awesome program, that is why I didn't create a pull request. For example, I don't know if it is common to define a function and then run it immediately afterwards. If I can help in anyway, please say so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions