any way to check if $args.variable is null or was not passed in?
thanks!
I used if $args.variable is $args.$null
where $null
is an arbitrary thing you know won’t be passed in, or are you saying that a true null
value be passed in and that needs to be tested differently?
trying to come up with a piston that gets executed by IFTTT and also runs on a schedule. from IFTTT it passes in args but when run on schedule there are no args.
i tried checking $args.variable != $args.$undefined and that throws this:
+695ms ║An error occurred while executing the event: java.lang.ClassCastException
thanks!
Are you sure that specific test is throwing the exception and not something else in the piston? It works for me.
Hard to say, the trace just shows that the condition evaluated to false.
yeah. its a scratch piston, so going to skip posting the entire piston for now and look at it later.
thank you.
While discussing alternate notification services today I realized that with the current structure of these pistons it would be very difficult to add more properties for each recipient, like a device ID for Pushbullet. You would have to add a new array, populate it for each contact, create a variable to hold the argument value, add it to the argument list when executing the sender piston, then update the sender to make use of that argument.
Instead, contact info will be maintained in the sender piston with simple local variables for each of the datapoints, populated in a switch based on the recipient name. Adding a datapoint is as simple as creating the variable, setting the value for each recipient, then making use of it.
There are several merits to this change:
with a few concessions:
Maybe it would be easier to add a specialized task in webCoRE that implements the whole logic?
That would be very interesting! Let’s see once this is ironed out and posted in Examples what the response is and what requests come in. I am very near a size limit here, could squeak out a bit more by removing debugging but the debugging is necessary to make it testable.
The latest revision features:
:if-present
et al. with them)(?s)
flagSmart notify piston
Basic sender piston using built-in webCoRE features
Tests
Some issues I had to work around:
arrayItem
, count
, etc barf when array values have commas in them, so I replaced commas in the repeating and presence messages with a unicode character in the private use subset, reverted when read out of the arrayThe next step for me is to switch over all my pistons to use it for some more thorough testing.
Earlier I had forgotten how I got the contactId values. I haven’t found a good way to do this but I’ve been doing the following:
c = $('ng-view').scope().instance.contacts; console.log(Object.keys(c).map(id => `${c[id].f} ${c[id].l}: ${id}`).join('\n'))
and hit enterThe console then displays the names and IDs of your contacts. Any easier way to get these IDs or alternate expressions for sending a notification to a contact?
you dont have ST setup to support notification to contacts? once you have done that go to webcore settings and check the contacts you want webcore to be able to send notification to.
I do, the sender piston uses an expression to deliver to a contact by id rather than selecting the name from the dropdown.
hmm … looking at send notification to contact that seemed to support an expression for contact … that might suggest that there is some possibility here …
Yes the expression works fine, I am just curious whether there is an easier way for the end-user to get a contact into a variable in a way that can be used in this expression. Currently the variable needs to be set to the contact id formatted :0e657415ab1e4b0db90db24d12117ec2:
, a value which can be found using the console snippet posted above.
understood. but, i was thinking about it slightly differently. if send notification to contact supports an expression for contact, was @ady624 expecting users to dig up the contact id via some steps like the one above or is there another way to specify the contact in that expression just as you can specify a device using [name of device]
Exactly, we’ve come back around to my original question of any easier way to get those ids or alternate expressions for sending a notification to a contact.
Oddly, the contactId as a string is no longer working for me - I keep getting “Invalid list of contacts” so I’m checking into that now.
yeah, that would be nice. maybe just following the pattern of how devices can be used anywhere with []
That might be best, similar to how devices work. It looks like this could be worked around by handling strings here if ((operand.vt == 'contact') && (operand.c instanceof List)) {
so that the contacts get loaded but frankly the raw id format is too obscure anyway.
Edit: not a good guess, that code wasn’t related