Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to prefix entites with device name #389

Merged
merged 3 commits into from
Nov 11, 2023

Conversation

tekand
Copy link
Contributor

@tekand tekand commented Sep 16, 2023

It was removed in 4210d84.
The problem is that Home Assistant uses the name of the entity to generate it's entity_id and not the provided unique_id. This can result in identical entities in Home Assistant (if using auto discovery).

Or maybe an alternative to this would be to provide the value of unique_id in object_id as well. Reference: https://www.home-assistant.io/integrations/mqtt/#naming-of-mqtt-entities

Or maybe both? ;)

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@yozik04
Copy link
Collaborator

yozik04 commented Sep 18, 2023

Prefixing name with device name is wrong. #381
https://developers.home-assistant.io/docs/core/entity#entity-naming

I think we need to provide unique_id.

People were requesting a prefix to distinguish between alarm panels: #329
Your pull request can be easily modified to cover that =)

@tekand
Copy link
Contributor Author

tekand commented Sep 18, 2023

I use HA as well, and have seen #381, but didn't find anything like that in my HA logs. Maybe I missed something.
Intead of unique_id you meant object_id, right? unique_id is already provided.

Regarding #329, it would only mean to remove 'Paradox' from it and leave only the serial, right? Or you prefer to have this configurable?

BTW are you still active on gitter? I have a problem with the target_state, that is a bit harder/longer to explain. :)

@yozik04
Copy link
Collaborator

yozik04 commented Sep 18, 2023

I use HA as well, and have seen #381, but didn't find anything like that in my HA logs. Maybe I missed something. Instead of unique_id you meant object_id, right? unique_id is already provided.

Sorry for confusion. I thought we do not provide unique_id. Then we should be all set. I do not think we need an object_id in addition.

BTW are you still active on gitter? I have a problem with the target_state, that is a bit harder/longer to explain. :)

Probably I am. Have not seen any notifications for a long time already.

@@ -40,7 +40,7 @@ def serialize(self):
return dict(
availability_topic=self.availability_topic,
device=self.device,
name=f'{self.entity_name}',
name=f'Paradox {self.device.serial_number} {self.entity_name}' if cfg.MQTT_PREFIX_DEVICE_NAME else f'{self.entity_name}',
Copy link
Collaborator

@yozik04 yozik04 Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's better have

f'{cfg.ENTITY_NAME_PREFIX}{self.entity_name}' if cfg.ENTITY_NAME_PREFIX else f'{self.entity_name}',

Default prefix can be "Paradox "

Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@yozik04 yozik04 merged commit 1ef7958 into ParadoxAlarmInterface:dev Nov 11, 2023
5 of 6 checks passed
@yozik04
Copy link
Collaborator

yozik04 commented Nov 11, 2023

Usage:
MQTT_HOMEASSISTANT_ENTITY_PREFIX = '' - default

MQTT_HOMEASSISTANT_ENTITY_PREFIX = 'Paradox {serial_number} ' - will prefix with "Paradox abcdef"

Note the space in the end of prefix.

@clau-bucur
Copy link
Contributor

Can this be documented or included in pai.conf.example?

@yozik04
Copy link
Collaborator

yozik04 commented Nov 15, 2023

It is there :)

Look for
MQTT_HOMEASSISTANT_ENTITY_PREFIX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants