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 feature : object alias #689

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

marsman7
Copy link
Contributor

Object alias

An alias can be assigned to each object. This means that the object can be accessed not only with the page number and ID (pXbY) but also by alias. The advantage of this is that the position of the object does not have to be known. For example, it is possible to change the status of a button on several plates with a single command via MQTT, even though the button has a different position on different plates.
When using the alias, the command must be preceded by an '@', for example "@Alpha.text"

To be able to use alias, USE_OBJ_ALIAS must be greater than zero when compiling.

#define USE_OBJ_ALIAS 1

Example :

pages.jsonl

{"page":1,"comment":"---------- Page 1 ----------"}
{"id":0,"bg_color":"#000050","text_color":"#555555"}
{"page":1,"id":10,"obj":"label","x":10,"y":10,"w":120,"h":36,"text":"Red","text_font":24,"bg_color":"#ff0000","bg_opa":255,"radius":7,"align":"center","alias":"Alpha"}
{"page":1,"id":11,"obj":"label","x":10,"y":50,"w":120,"h":36,"text":"Green","text_font":24,"bg_color":"#00ff00","bg_opa":255,"radius":7,"align":"center","alias":"Bravo"}
{"page":1,"id":17,"obj":"btn","x":245,"y":200,"w":75,"h":70,"toggle":false,"text":"\uE05D","text_font":32,"bg_color":"#005000","alias":"Marsman","action": {"down": "@alpha.text example"}} 

MQTT :

Topic : hasp/plates/command/@bravo.bg_color
Payload : #888800

@marsman7
Copy link
Contributor Author

I work again on this feature.

@fvanroie
Copy link
Collaborator

I don't think using SDBM for storing a hash of user defined alias names is the right way to go...
Please add your view to the discussion here as there are multiple views to achieve this.

I think the alias should be reversible, so needs to be stored. It can also impact the event which are send out to pXbY topics now, but maybe should also use the alias if set. What about multiple objects with the same alias etc...

@marsman7
Copy link
Contributor Author

Yes, I've already thought about that. I'm working on extending that. I would then like to save the hash and the string.

A check as to whether the hash already exists will also be added. However, the question is what should happen if the hash already exists? Just display an error message?

Further discussion here: #365

@marsman7
Copy link
Contributor Author

marsman7 commented Apr 6, 2024

Please review

warning for duplicate removed - Does not run reliably and leads to problems when starting openHasp

#365

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.

2 participants