Open rgerrans opened 5 years ago
Sure @rgerrans . I'm actually very glad someone wants to contribute. I must admit I don't usually add new things unless I also need them.
A first step would be adding the needed device/state type(s) here: https://github.com/andrei-tatar/nora-service/tree/master/src/models https://github.com/andrei-tatar/nora-service/tree/master/src/models/states A new file for the device and a new file for the state (if not already there - states are shared between devices, they are the implementation of traits).
https://github.com/andrei-tatar/nora-service/blob/master/src/models/index.ts
This file contains the Device
type that is a unification of all the devices. You also need to import and add the new devices to this type. This is used to generate the schema that validates the input from the node-red client (device types/updates/etc.).
Now you can add the new command (if any) types in the enum: https://github.com/andrei-tatar/nora-service/blob/master/src/google/execute.ts#L11
After that, you only need to update the command execution service: https://github.com/andrei-tatar/nora-service/blob/master/src/http/services/execute.service.ts As you can see most of the commands are pretty generic state updates, some of them do more device specific things.
I was actually thinking of refactoring the entire NORA service to support the new local execution path. It should reduce latency a bit. But it will probably take a while until I get around to doing this.
@andrei-tatar I just submitted the pull requests. I'd suggest taking a look at the code to make sure I edited the copied version of the Blinds that I used to create the Garage Door. For v1, I just focuse don the OpenClose action and not the device errors. Here is the reference on Google - https://developers.google.com/assistant/smarthome/guides/garage.html
Let me know if you see anything I got wrong so I know for next time.
Thanks,
Ron
@andrei-tatar I cleaned up both branches into single pull requests. Let me know anything else I need to do to make it easier
@andrei-tatar I wanted to see if you had a chance to look at those pull requests to verify I set up the new devices right. Thanks. If it works, I'll take on a few of the other devices as well.
I did add a comment to the PR, but actually more changes are needed. I will create a PR and will post it here so you can see all the changes needed for the backend
Here are all the changes needed to support the garage
device:
https://github.com/andrei-tatar/nora-service/pull/5
They were deployed once they were merged to master, so you should be able to test locally your node-red plugin before merging it.
Great, thanks. I'll take a stab at another device this week and make sure I get those changes in as well (going to try locks but know that also requires much more backend changes for the different actions).
Should be similar, only with added support for the lock/unlock trait. https://developers.google.com/assistant/smarthome/traits/lockunlock.html
Let me know if you got to testing the device in the NORA plugin, so I can publish that also.
How could I test it? I don't have a standalone version of your services setup. I'm assuming that's what I would need?
The service is already deployed to support the garage device. You only need a local version of the node-red plugin.
Makes sense. Now I just have to go learn how to roll my own npm ;-) I'll test in the next couple of days.
No need to publish your own package. Read about npm link
.
Thanks. I'm clearly doing something wrong. I first cloned the git branch to my local node-red machine, I first tried just using thenpm install <local folder>
and then uninstalled that and went with the npm link
approach. Both approaches give me the same error message:
4 Nov 13:29:27 - [warn] [node-red-contrib-nora/nora-light] Error: /opt/node-red/node_modules/node-red-contrib-nora/build/nodes/nora-light.html does not exist
I'm not sure how it's supposed to go from the /src/nodes structure to /build/nodes directory structure? Any further suggestions would be appreciated.
Edit: Nevermind, figured out that I needed to initiate an npm build. Now testing....
@andrei-tatar It works with my setup using the same payload.openPercent input/output as the blinds nodes. Thanks for getting me pointed in the right direction. I did clean up a couple of mistakes so will make a new pull request.
@rgerrans no need to create a new PR for each commit. It automatically updates.
@andrei-tatar Good to know, thanks. Obviously, still coming up the learning curve on Git (had a middle of the night panic thought if I'd actually pushed up all the changes....95% sure I did before I did my NPM Build.... Let me know if anything glitches.
Thanks for the guidance through this. Ready to test the lock once you have a chance to update the backend.
@andrei-tatar I was poking around and saw Google has added a tone of devices - https://developers.google.com/assistant/smarthome/guides
I was hoping to add Garage Doors and Locks to the node set. I started playing with the git-hub code on the node side to use your blinds as a template to create a garage door node but realized that there had to be backend services to make the calls. I took a look at Nora-Services and knew I was in way over my head.
If there are just a couple of key files in the Nora-Services to edit, if you can point me at them I'm willing to give it the old college try so it doesn't all fall on you to add new devices. I'm only an amateur self taught coder but can give it a try.