How to send random text messages from a list


#9

Is the URL random one? Sorry, a little slow, on mobile.

Edit: I tried this and it worked. random(“http://www.url1.com”,“http://www.url2.com”,“http://www.url3.com”,“http://www.url4.com”)


#10

The url is to have the speech go through my sonos setup on my unraid server with a docker. When I set it up the way you have it, webCore gave an error. This is the error:

║Error executing virtual command [].httpRequest: (10ms) java.lang.NullPointerException: Cannot invoke method replace() on null object


#11

Ah I just tested it with random() in the console and didn’t do the actual web request. I don’t have a sonos to test it on.


#12

It does seem to work but it won’t accept any variables. ie: {whoCameHome}


#13

Yep, you’re right about the variables within the random(). I thought someone came up with a workaround on that but I don’t remember where I’ve seen it. Maybe one of the more skilled @webCoRE_Minions can chime in.


#14

heres an example of combining random and variables:


#15

Thank you! That’s where I saw it before but didn’t bookmark it. I had pistons where I wanted to do that before but just gave up on it and have not updated it since.


#16

So you know the Arrival piston that you created for me, would I be able to incorporate the whoCameHome variable into random statements? It doesn’t seem to work when I put them in the statement.


#17

Should work. Will take a look later today. Please post a snapshot if you have a modified version of what’s not working.


#18

Here is the piston right now. I was trying to have greetings based on {whoCameHome}. But the random() doesn’t seem to like having a variable in it. Also, I might have messed something up because now when someone leaves it is also triggering this arrival piston. I think it is because the Contact Sensor is always Closed.


#19

I have this piston and something similar setup for departures based on this one. But both are using the Contact Sensor is closed but the departure uses the presence sensor changes to not present and this one uses the presence sensor changes to present. Yet they are both firing when someone leaves.


#20

ok. should we go back to the original and start from there then? if yes, please post:

  1. the post with the original piston if you have a link to it. otherwise i will search thru my history to find it.
  2. the messages as text so i dont have to hand type those in.

thanks.

sorry didnt see this till now … somehow did not get a notification. the reply button on the post notifies the poster there is a response but the reply button on the thread does not. :slight_smile:


#21

both will trigger because they both subscribe to the presence event. question is are the presence conditions being evaluated correctly. they should be.


#22

Not sure. Let’s pick this up after Christmas! I am going to be busy the next couple of days. Have a good Christmas!


#23

sure, ping me whenever you want to get back to it.

now that we have permission: :wink:

merry christmas!


#24

Hey, I’m back! So looking at the above piston, I am not sure what the point of the virtual sensor is? When I took it out of the piston for arrival, it seemed to fix the issue of firing when someone left also. This would be because the presence sensor is always on. Then I started to wonder why we need it in either piston? There is nothing telling it to change to “off” so it is always “on”.


#25

welcome back! do you mean piston xpgwi or another piston? which one is the virtual sensor? it seems to only have 3 presence sensors and 1 contact sensor.


#26

This one…


#27

i may be getting old … but this looks almost the same as xpgwi :slight_smile: which one is the virtual sensor?


#28

So what seems to be happening now is that for some reason if someone leaves the house it will then also tell me that Tom is in the house and then the greeting will fire. Except he didn’t leave. This is the Leaving piston…