Dialog with Ok Google using Sharptools


(Glen King) #1

I just built a profile that asks "is the corner lamp on?"
Tasker, by looking at the object attribute in Sharptools, replies… then asks “would you like to switch it?”

The action temporarily enables AutoVoice Continuous. It receives my response.
If I respond YES, Sharptools toggles the lamp.
If I respond with anything other than YES, it does not toggle the lamp.
Finally it closes out AutoVoice Continuous, and replies with the current status of the lamp.

It can do this for all objects. I’m going to try regex next, to see if I can make a single profile - dialog work for multiple devices and contexts. If not, multiple profiles is acceptable as a solution.

It’s time to purchase a Chamberlain MyQ controller, and do this for my garage door.


(Joshua Lyon (SharpTools.io Dashboard)) #2

That sounds like an awesome use of SharpTools - thanks for sharing!

If you haven’t already seen it, check out the Voice Control tutorial on the SharpTools microsite. You may be able to take the RegEx concept used there and extend it to your use case.


(Glen King) #3

As I think on it, I question my method. I might be curious as to whether the washing machine is still running, and therefore ask ST its current status. But is there ever a time where we really care about the current state of an “action-thing”, such as a light or a lock or a door? Or is it more accurate to simply act on desire?

Take the case of the garage. I cannot see the garage from inside the house. If I ask whether it is open or closed, it’s almost impossibly unlikely that I am doing so from mere curiousity. Odds are nearly 100% that I instead want it to be a certain way, either open or closed, in that moment.

So I might be better off simply building commands, and having Tasker reply with a thing state report. So instead of asking whether the garage is open, simply say “Ok Google, open the garage” - and then have Tasker check thing state. And if it’s already open, report it as such. And if it was closed, then open it… and report that it is open.

Then again, doing that means I’m conforming my word choices, and my computer programs, to a particular (and somewhat strained) model of efficiency. And losing natural language tendencies, along with interesting computer interaction, in the process.

Just some thoughts on the whole person-machine interaction concept. I will of course program both direct commands AND inquisition - reply commands.

And Josh, I’m already using regex with the commands. Integrating it into these ‘dialogs’ will be fun. And I’m thinking ahead to the thermostat I do not yet own. I don’t really care what the temperature reading on it might be. All I really care about is whether I want to adjust it, right? Do I want it warmer or cooler? But I don’t want it to use air conditioning to make the house cooler in wintertime…

So I need these things: the thermostat itself, external temperature/wind readings, internal temp sensors.

Whether I ask “what is the current temp?” or issue an “Ok Google, make it warner/cooler in here” command, in most instances the change desired is incremental.


(Glen King) #4

More items to consider if you want to do something like this:

  • You have to re-get the device status after you’ve said’yes’ to the question to switch it in order for the post-action status report to be accurate.
  • the AutoVoice function occasionally gets stuck. So at the end of the actions, toss in a command to turn off Continuous mode so it can start responding to Ok Google commands again.
  • I hve my tablet rebooting daily, at random times, just to ensure there’s nothing else that’s stuck (and so it’s unpredictable, from a security standpoint. You don’t want people to be able to identify the scheduled time of a reboot cycle for your security system).

(Joshua Lyon (SharpTools.io Dashboard)) #5

You can also subscribe to a devices status (push events) and react to those in Tasker. This keeps your phone up to date with the status of your devices and you can even use the events to trigger your feedback mechanism or other actions.


(Glen King) #6

Josh, I’m struggling a bit. I want to have a routine that displays or says the names of devices whose contact thing state is ‘open’. I keep getting ALL items displayed, or NONE.

I started with a thing state event that gets every attribute of every device. That seems to work fine. I then tried conditional actions, where for example it should display the %st_thing_name IF the %st_attr_value ~ *open.

I just can’t seem to get it to work.
What am I missing?


(Joshua Lyon (SharpTools.io Dashboard)) #7

Can you post a Description export of your Tasker profile so far? There are a few ways to go about this, so it would be helpful to see what approach you have started taking.

Note that if you don’t mind a 2-3 second delay while you query the SmartThings servers for status, you could use the Thing: Get Attribute plugin to get the status of all contact sensors in a single command. If you switch to variable mode using the tag icon in the action bar, the result will be a set of arrays instead of individual strings.

%st_attr_names()
%st_attr_values()
%st_thing_ids()
%st_thing_names()

http://tasker.dinglisch.net/userguide/en/variables.html#arrays


(Glen King) #8

Did that. And what comes back is the full list of device names, followed by the full list of contact sensor statuses. They are in order; if the third device in the list is “bathroom window” and that window is open, then e third status in e list will be ‘open’.

Obviously, I don’t need to display the statuses. Nor do I need to display the names of closed devices. I just need to display the names of those devices that are open.

No time today, will try to export and post soon


(Joshua Lyon (SharpTools.io Dashboard)) #9

It sounds like you are close.you just need to loop through that list you got and build up your own variable containing just the data you want.

See the attached screenshots for an example. I took your example and instead of contact sensors, i used motion sensors since I have more of those which works better for the screenshots.

For Loop Example (19)
	A1: Thing: Get Attribute [ Configuration:Thing: 
		Attribute: motion

		The following variable arrays are set when triggered:
		%st_attr_names()
		%st_attr_values()
		%st_thing_ids()
		%st_thing_names() Timeout (Seconds):15 ] 
	<just for demonstration>
	A2: Notify [ Title:%st_attr_values() Text:%st_thing_names() Icon:null Number:0 Permanent:Off Priority:3 ] 
	A3: For [ Variable:%index Items:1:%st_attr_values(#) ] 
	A4: Array Push [ Name:%active Position:1 Value:%st_thing_names(%index) Fill Spaces:Off ] If [ %st_attr_values(%index) ~ active ]
	A5: End For 
	<just for demonstration>
	A6: Notify [ Title:Final Result Text:%active() Icon:null Number:0 Permanent:Off Priority:3 ] 


(Glen King) #10

I finally got a chance to do this… works beautifully. It’s simple once you see it, but I would not have guessed the format of the ‘For’ line.

Thank you very much for sharing it.


(Joshua Lyon (SharpTools.io Dashboard)) #11

Thanks for the follow up! I’m glad it’s working for you!

I totally agree on the For loop. I couldn’t recall the syntax, so I had to look it up again and try it out to make sure I was giving you good advice!