Closed nagyrobi closed 3 years ago
Next and prev page services could be replaced with this, as the firmware supports directly these commands.
The number of services could be reduced with this.
After applying the PR, some examples (no need to know the node name):
Jump to page:
service: openhasp.command
data:
keyword: page
parameters: '1'
target:
entity_id: openhasp.plate_3
Next page:
service: openhasp.command
data:
keyword: page
parameters: 'next'
target:
entity_id: openhasp.plate_3
Set Long idle time:
service: openhasp.command
data:
keyword: '{"idle2":120}'
command: config/gui
target:
entity_id: openhasp.plate_3
Draw BSOD:
service: openhasp.command
data:
keyword: jsonl
parameters: >-
{"page":0,"id":99,"obj":"obj","x":0,"y":0,"w":240,"h":320,"radius":0,"hidden":0,"bg_grad_dir":0,"bg_color":"blue"}
target:
entity_id: openhasp.plate_3
Delete BSOD:
service: openhasp.command
data:
keyword: p0b99.delete
target:
entity_id: openhasp.plate_3
keyword is very misleading, specially in the "Set long idle time" example
I'm thinking along the lines of raw mqtt messages like:
service: openhasp.publish
data:
topic: command/jsonl
payload: >-
{"page":0,"id":99,"obj":"obj","x":0,"y":0,"w":240,"h":320,"radius":0,"hidden":0,"bg_grad_dir":0,"bg_color":"blue"}
target:
entity_id: openhasp.plate_3
to send anything without validation.
Other more specific services can handle specific commands with input validation as required.
this just slightly better then mqtt.publish...
I would keep the "command" instead of topic and a list of available commands for validation
Thank you. openhasp.command
and openhasp.config
services fulfill this request.
Is your feature request related to a problem? Please describe. openHASP supports a handful of commands. Some of them would be useful in HA automations, like setting dim values or change theme based on day/night, etc.
Instead of having services in HA translated to each command, we could use one single service which could wrap them all in one.
Describe the solution you'd like A universal service which would accept 2 or 3 parameters:
If the
config
or any other commands exceptcommand
would be deprecated, only thekeyword
andparameters
would suffice.Describe alternatives you've considered Sending commands directly to the plate is currently possible outside the component like this example:
Instead of this, it would be a lot better to wrap this inside the component like above, as they can be used with automations and blueprints more consistently. You can reference to a plate universally using it's entity_id, instead of having to keep separately track of MQTT topics belonging to that plate.
Additional context Extra benefit is that commands list can freely change on the firmware side, the component doesn't have to implement new services for them if they are requested, changed or added.