Looking for a mentor to help me build a new plugin

Posted on
Fri Sep 10, 2021 6:48 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Looking for a mentor to help me build a new plugin

the logic makes total sense to me and I think I'm writing the right code.

Is there a better way to test than packaging and installing the plugin and running it?

Posted on
Sat Sep 11, 2021 1:15 am
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Looking for a mentor to help me build a new plugin

Let me know if you get stuck as trying to assist rather than interfering. My Octopus energy plugin takes a similar approach but at the device level not the plugin level.

As for testing i didn’t justify a paid pycharm license but use the free version to make edits in situ in the running plugin folder package and use plugin restarts to apply changes (and you can do the same with any editor). Probably not best practice but works for me.

I did request a developer license as well which makes the impact of tinkering more family friendly if you use a separate Mac to write the code.

Posted on
Sat Sep 11, 2021 4:08 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Looking for a mentor to help me build a new plugin

As an FYI, a lot of folks use a free, open source tool called Visual Studio Code (or VS Code). It's not something that I've used myself". Loads of online tutorials use it and, although I can't personally recommend it (not having used it), it seems pretty popular.

* I use the PyCharm for Developers license which is roughly $50US per year to gain access to some additional features.

EDIT: reworded for clarity
Last edited by DaveL17 on Sat Sep 11, 2021 1:51 pm, edited 1 time in total.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Sep 11, 2021 1:21 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Looking for a mentor to help me build a new plugin

Has anyone figured out how to do interactive/integrated debugging of Indigo plugins with VS Code? With PyCharm you need the commercial version because it relies on the remote debugging feature (not remote, but since plugins must run in a separate process it works like a remote debug session).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Sep 11, 2021 1:29 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Looking for a mentor to help me build a new plugin

neilk wrote:
Let me know if you get stuck as trying to assist rather than interfering. My Octopus energy plugin takes a similar approach but at the device level not the plugin level.

As for testing i didn’t justify a paid pycharm license but use the free version to make edits in situ in the running plugin folder package and use plugin restarts to apply changes (and you can do the same with any editor). Probably not best practice but works for me.

I did request a developer license as well which makes the impact of tinkering more family friendly if you use a separate Mac to write the code.


Ok, I have a working version https://github.com/ryanbuckner/life360-plugin

A few things I need help with:

1) How do I set the device.address to a value from my JSON?
2) My config validation logic only works for field validation. It's allowing the UI to be closed even if the API call fails and I return False

Posted on
Sat Sep 11, 2021 3:18 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Looking for a mentor to help me build a new plugin

ryanbuckner wrote:

A few things I need help with:

1) How do I set the device.address to a value from my JSON?
2) My config validation logic only works for field validation. It's allowing the UI to be closed even if the API call fails and I return False


The first one is really easy, it is the device state “address” and you don’t need to define it. Took me ages to figure it out though.

On 2 - I will take a look.

Neil

Posted on
Sat Sep 11, 2021 3:28 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Looking for a mentor to help me build a new plugin

And on 2 - I think it may not be returning an error/ throwing an exception when get_new_life360json fails so the except never happens, I think you can just add the api authenticate test as the condition in the callback and that should do the trick but I am not 100% how the credentials are getting passed as you need to use the ones passed to the callback

Posted on
Sat Sep 11, 2021 4:03 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Looking for a mentor to help me build a new plugin

jay (support) wrote:
Has anyone figured out how to do interactive/integrated debugging of Indigo plugins with VS Code? With PyCharm you need the commercial version because it relies on the remote debugging feature (not remote, but since plugins must run in a separate process it works like a remote debug session).


VS Code Docs wrote:
Remote debugging
VS Code does not itself support remote debugging: this is a feature of the debug extension you are using, and you should consult the extension's page in the Marketplace for support and details.

There is, however, one exception: the Node.js debugger included in VS Code supports remote debugging. See the Node.js Debugging topic to learn how to configure this.


Sounds like it would require someone to write an extension.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Sep 11, 2021 4:21 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Looking for a mentor to help me build a new plugin

neilk wrote:
ryanbuckner wrote:

A few things I need help with:

1) How do I set the device.address to a value from my JSON?
2) My config validation logic only works for field validation. It's allowing the UI to be closed even if the API call fails and I return False


The first one is really easy, it is the device state “address” and you don’t need to define it. Took me ages to figure it out though.

On 2 - I will take a look.

Neil


For the first one, I use a callback which just returns a list of firstNames to populate a dropdown that the user can choose from when configuring the device. I guess my question is: How do I know which one they choose ? Is it the menuChanged(). method? What if the user cancels?

Posted on
Sun Sep 12, 2021 4:05 am
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Looking for a mentor to help me build a new plugin

It will be in the dictionary passed to the callback. The callback can also make changes, you update the dictionary and return it. So for example if you want to duplicate address (so it shows in the UI as the name) but want to use a more meaningful device state name you can do that in the callback.

My WLED plugin does exactly this, it was my first plugin and I created an ipaddress config field rather than just using address and then took ages to figure it out.

In terms of “how to I know” it is passed to the callback, and you need to test for and catch the potential error if the user cancels, so the plugin needs to elegantly handle updating a partially configured device.

Posted on
Sun Sep 12, 2021 6:25 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Looking for a mentor to help me build a new plugin

I'm currently able to: https://github.com/ryanbuckner/life360-plugin
    -
    Deploy the plugin
    Configure the plugin
    Validate the plugin settings (to include the API connectivity)
    Create devices
    Update the devices states with data from Life360 *
    Update the device address with the member unique id

Before I create a forums page to get a few testers out there, I have 1 question:

I would like to change the plugin CFBundleIdentifier to com.ryanbuckner.indigoplugin.life360. I made the change, deleted the plugin, restarted Indigo, and redeployed the plugin and I started getting errors that the pluginPrefs dictionary items were not defined any longer. Is there a trick to changing the CFBundleIdentifier ?

Code: Select all
   Life360 Error                   Error in plugin execution InitializeMain:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "plugin.py", line 40, in __init__
KeyError: key authorizationtoken not found in dict


When I change the CFBundleIdentifier back, the error goes away

Posted on
Sun Sep 12, 2021 6:47 pm
FlyingDiver offline
User avatar
Posts: 7217
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Looking for a mentor to help me build a new plugin

Your preferences file is named with the old identifier. You need to rename that by hand.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Sep 12, 2021 7:13 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Looking for a mentor to help me build a new plugin

The plugin identifier is also used in the Indigo database file. You'll need to change it there, too. Best make a backup of the file before editing it (especially if you're developing on the same database as your main Indigo install). As long as you make the change before rollout, you're the only one that suffers.

Is there a trick to changing the CFBundleIdentifier ?

Yeah....don't do it. :)

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun Sep 12, 2021 8:01 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Looking for a mentor to help me build a new plugin

DaveL17 wrote:
The plugin identifier is also used in the Indigo database file. You'll need to change it there, too. Best make a backup of the file before editing it (especially if you're developing on the same database as your main Indigo install). As long as you make the change before rollout, you're the only one that suffers.

Is there a trick to changing the CFBundleIdentifier ?

Yeah....don't do it. :)


This makes sense. How do I delete if from the DB? I am developing against my own production instance because I don't know another way

Posted on
Sun Sep 12, 2021 8:39 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Looking for a mentor to help me build a new plugin

It's not too tough, but there is inherent peril.

Stop your Indigo server and quit the Indigo client. Navigate to the Indigo database file and make a copy. Open the original in your favorite editor and do a find/replace (to make sure you get them all). Restart the Indigo server and you should be good to go. If something breaks (probably won't) just rinse and repeat. Making the backup gets rid of the peril.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Who is online

Users browsing this forum: No registered users and 6 guests