conditional Vera Alerts message (added to existing message)

I have a scene set up which every evening sends a tts command to my tablet

{tone:tts}Master Bedroom temperature {device([261]service[urn:upnp-org:serviceId:TemperatureSensor1].CurrentTemperature)} degrees

Now, I would like to add something to that message and cannot get my head round of how to do it. I have 2 bedroom windows, both with sensors. I would like to add to the message if the windows are open or closed. It doesn’t matter if only one window is open. So if 1 or 2 windows are open, I want to add ‘windows are open’ to the end of the message, if none is open ‘windows are closed’
I could easily define a condition in PLEG to say if either window is open the status is open, if not closed. But how do I go from there ?

There are lots of ways to do this …

You could export the condition (in this example called ConditionName)

Then you could use:

{device([11111]service[urn:rts-services-com:serviceId:User].[b]ConditionName[/b]) | Choose(0=Closed,1=Open)}

Where 11111 is the PLEG device ID.

Ok that makes sense so far. But how do I now get that to a tts message ? or could I just add another action in the scene after the first action ({tone:tts}Master Bedroom temperature {device([261]service[urn:upnp-org:serviceId:TemperatureSensor1].CurrentTemperature)} degrees) where I send this to Vera Alerts:

{tone:tts} bedroom windows are {device([11111]service[urn:rts-services-com:serviceId:User].ConditionName) | Choose(0=Closed,1=Open)}

which then in turn should say ‘bedroom windows are open’ or ‘bedroom windows are closed’

?

If you do this as an action from PLEG then you can access the PLEG condition directly

{tone:tts} bedroom windows are {(ConditionName) ? “Open” : “Closed”)}

The previous syntax was if this was part of a notification on another device.

In this case you do not need to export the condition!

when I try adding this as a message to Vera Alerts in my scene (advanced)

{tone:tts} bedroom windows are {(Windowstatus) ? “Open” : “Closed”)}

it gets changed to

{tone:tts} bedroom windows are {(Windowstatus) ?

as soon as I click into the recipient field. When I run the scene it says ‘bedroom windows are windowstatus open closed’

weird…

You can’t use:
{(XXXX)} in a SCENE!
This is available syntax in a PLEG ACTION

Sorry now I am totally confused. I have created this PLEG condition

Windowstatus No LWindowOpen or RWindowOpen false 0 0

so I have my windowstatus in Windowstatus. So how do I get Vera Alerts to say bedromm windows are… after its reported the bedroom temp, which is in a scene

If it’s in a Scene … you need to use my first example … export the condition.

Ok I’ve exported the condition. My PLEG device is 250. I have added this to a new scene, in the Luup section

{device([250]service[urn:rts-services-com:serviceId:User].Windowstatus) | Choose(0=Closed,1=Open)}

After saving I have an error in scene

Are you calling from LUA or as the SendAlert action in the advanced tab ?

I have tried from the Luup section of the scene. But even without the error, I would then still dont know how to send it to VeraAlerts as tts. So if there is a way to send it from the SendAlert action in advanced that would probably be best. Also I wanted it to follow the temperature tts, which is a sendalert action in advanced

Just put:

Windows are: {device([250]service[urn:rts-services-com:serviceId:User].Windowstatus) | Choose(0=Closed,1=Open,Other=Unknown)}

In the message field of the Advanced tab of a Vera Alerts SendAlert action.

Send me your LUA code if you want me to look at that and see why you are getting an error.

It seems to be working now, with your last code and {tone:tts} before it in SendAlert in advanced

just for my understanding, the way it is configured now, I do not need to export the PLEG condition, it is accessed directly from PLEG, correct ?

problem solved. thanks

Conditions are NOT accessible outside of PLEG unless you export them.
So in order for the scene to access them you need to export them.
When you export a condition … it actually creates a Vera Variable for that condition.
The variable is created on the PLEG Device (250) with a ServiceID of: “urn:rts-services-com:serviceId:User” and a Variable Name equal to the name of the exported Condition.

Any device variable can be accessed by Vera Alerts when you have the appropriate 3 pieces of information … using the syntax I showed you.

Ok great, that all makes sense now. See what else I can do with the new knowledge… :slight_smile: