Amazon echo text to speech simple OH3

Hi there, I was able to get the pushover commands to work to send commands for washing machine done via text to my wife’s phone and mine, however she wants the echo to say it also.

I read the echo literature but all of it seems to be about editing rules files and and things files from pre OH3.

Is there a simple 1 or 2 lines I can use in the DSL rule builder that works for this?

I already have my account name, echo device name, so just need the line for how to use the sendmessage or whatever it is in OH3 DSL rules.

Once someone has posted, I’ll also happily make a YouTube video for future users. Thanks.

The Amazon Echo Control Binding supports text to speech. Just create an item and send a command with the text you want it to say.

It’s just my opinion, but if you want to document things for the benefit of others then I suggest posting step-by-step tutorials in the community. Tutorials can be edited by the author as things change (e.g. OH2 gets replaced by OH3), and other community members can help when a reader is having trouble. As well, very specific tasks can often be generalized in a tutorial so that they’ll be valuable to a broader audience.

When someone comes here and says they saw something on a Youtube video, it’s very difficult for us to help them without a lot of back and forth to figure out their starting point. Some will declare that the video must be right, because it’s a video, and others will be annoyed that we don’t keep our videos up to date.

In this case, you’ll just need an item and a rule. :wink:

Thanks this worked, at least in my test file. I’ve now got a pushover notification, and one of my Echo’s saying something when I manually run the rule, but when trying to use this for the dryer, I’ve manually watched the temp change (in HabPanel), and it doesn’t trigger anything; am I using that wrong as well?

  - id: "1"
    configuration:
      itemName: Sonoff1_Temperature
      state: <=28
      previousState: ">28"
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-
        val myAction = getActions("pushover",
        "pushover:pushover-account:a3272e5b52")

        var receipt = myAction.sendMessage("The Dryer is Done!", "Arnett Manor")
    type: script.ScriptAction
  - inputs: {}
    id: "3"
    configuration:
      itemName: LivingRoomEcho_Speak
      command: The clothes might be dry.  But probably not.
    type: core.ItemCommandAction

If you can trigger it manually, then something is wrong with your triggering condition. What does your log say?

@Jon_A - FYI - you probably don’t need to route your push notifications through another service. If pushover is working well for you, no worries, but most mobile carriers support email to text too. For example, I can send a real-time notification to my phone that shows up as a text by sending an email to:

5551234567@txt.att.net

Just something to consider; hope those clothes ARE dry over there by now…

As @rpwong suggested - seemingly something must be ‘off’ with the trigger, particularly if it works when run manually via the Main UI > settings > rules section. The rule looks fine to me overall, but wouldn’t you want to trigger based on the Dryer Cycle completed, and not a Temperature reading?

:slight_smile:
.

1 Like

Huh, I had no idea you could do this. Just checked it out and it works for me on Telus in Canada, too.

1 Like

@rpwong - Less hops and faster response is the idea, although I haven’t personally thoroughly tested end to end yet with OH3, I expect delivery should work better than going through a variety of 3rd parties… Although in any case, its being routed somewhere else many times :slight_smile:

That’s cool on the carrier text thing, I never thought to do that, but used it years ago for another purpose (like 10 years ago), I may try it, but I am liking the speed of pushover, as well as ability to include rich media graphics, as I will be setting up my cameras to use it with snapshots as well.

Regarding the cycle completed vs. temperature, these are “dumb” machines, so the only reading I have on the dryer is a sonoff temp sensor that I’ve sealed into the dryer tube, and essentially the 28C point is when I can be sure the dryer is on, because the room itself can never be that hot. Do you see anything wrong with my syntax?

Going back to my earlier post, what does your log say? It’s your best friend for debugging rules, and without it we’re just guessing. It’s always useful to post your log, even if just to confirm that it all makes sense.

Saying that, this is most likely due to how you’ve defined your states.

state: <=28
previousState: ">28"

I note that you’ve used quotes around one set and not around the other. More importantly, I’m not sure if you can use “greater than” statements this way (I’m not using UI rules).

If I were doing this in Rules DSL, I would probably have a condition that the temperature must rise above 28 in order for this rule to be active. And then I would just check at every temperature change to see if it has fallen below 28.

The quotations thing is something to do with openhab. If I put quotations on both and save, when I go back into the rule it has removed the quotations from the first one.

For logging, which file should I look at? The openhab.log file doesn’t seem to have any details on this one.

Lastly, how would you write this in the DSL rules, as I’m happy to try that too.

Thanks.

It would be in events.log, but the Log Viewer will show you both so you just need to run the dryer and show us the log entries as the temperature drops.

In DSL, the trigger would be Sonoff1_Temperature changed. Then you would have an if condition that the command should only trigger if the previous state was over 28 and the new state is equal to or under 28. That’s pretty much the DSL version of your UI rule.

I can’t remember how to get previous state in DSL rules, but you should find that easily if you search the community and docs. Also, I’m not sure if there was any change to how previous state works in OH3 (versus OH2), so keep that in mind.

OK so here are the two logs, which show the temperature rising, and the rule just ignoring it.

From openhab.log:

2021-03-17 12:57:52.821 [DEBUG] [onoff.internal.connections.Websocket] - Pong Response received
2021-03-17 12:57:59.590 [DEBUG] [noff.internal.handler.HandlerAccount] - Sonoff Connection Check Running
2021-03-17 12:57:59.613 [DEBUG] [ding.sonoff.internal.connections.Api] - Api Discovery Request:{"appid":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"U7YFa8vQ","ts":1616000279613,"version":8}
2021-03-17 12:58:52.719 [DEBUG] [onoff.internal.connections.Websocket] - Websocket Sending Message:ping
2021-03-17 12:58:52.840 [DEBUG] [onoff.internal.connections.Websocket] - Pong Response received
2021-03-17 12:58:59.592 [DEBUG] [noff.internal.handler.HandlerAccount] - Sonoff Connection Check Running
2021-03-17 12:58:59.617 [DEBUG] [ding.sonoff.internal.connections.Api] - Api Discovery Request:{"appid":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"mw1HR3uO","ts":1616000339617,"version":8}
2021-03-17 12:59:39.616 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"16.8"},"from":"device"}
2021-03-17 12:59:49.613 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"18.8"},"from":"device"}
2021-03-17 12:59:52.734 [DEBUG] [onoff.internal.connections.Websocket] - Websocket Sending Message:ping
2021-03-17 12:59:52.845 [DEBUG] [onoff.internal.connections.Websocket] - Pong Response received
2021-03-17 12:59:59.593 [DEBUG] [noff.internal.handler.HandlerAccount] - Sonoff Connection Check Running
2021-03-17 12:59:59.621 [DEBUG] [ding.sonoff.internal.connections.Api] - Api Discovery Request:{"appid":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"XdSfFpAc","ts":1616000399621,"version":8}
2021-03-17 12:59:59.645 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"21.1"},"from":"device"}
2021-03-17 13:00:09.643 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"23.5"},"from":"device"}
2021-03-17 13:00:19.643 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"26.0"},"from":"device"}
2021-03-17 13:00:29.656 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"28.4"},"from":"device"}
2021-03-17 13:00:39.669 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"30.6"},"from":"device"}
2021-03-17 13:00:49.686 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"32.6"},"from":"device"}
2021-03-17 13:00:52.746 [DEBUG] [onoff.internal.connections.Websocket] - Websocket Sending Message:ping
2021-03-17 13:00:52.861 [DEBUG] [onoff.internal.connections.Websocket] - Pong Response received
2021-03-17 13:00:59.595 [DEBUG] [noff.internal.handler.HandlerAccount] - Sonoff Connection Check Running
2021-03-17 13:00:59.624 [DEBUG] [ding.sonoff.internal.connections.Api] - Api Discovery Request:{"appid":"oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq","nonce":"zlVx5wP3","ts":1616000459624,"version":8}
2021-03-17 13:01:19.720 [DEBUG] [onoff.internal.helpers.MessageSystem] - Websocket received message: {"action":"update","deviceid":"10005b9606","apikey":"53c83924-c0eb-4ffa-a289-190c37aae625","userAgent":"device","params":{"currentHumidity":"unavailable","currentTemperature":"31.9"},"from":"device"}

And From Events.log:

2021-03-17 12:59:27.393 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'BackStairwellLightSwitch_Switch' predicted to become OFF
2021-03-17 12:59:27.400 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BackStairwellLightSwitch_Switch' changed from ON to OFF
2021-03-17 12:59:39.685 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 15.6 to 16.8
2021-03-17 12:59:39.687 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 15.6 to 16.8
2021-03-17 12:59:42.758 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeteramps' changed from -62.403 to -21.575
2021-03-17 12:59:42.801 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeterwatts' changed from -7615.47 to -2432.703
2021-03-17 12:59:49.623 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 16.8 to 18.8
2021-03-17 12:59:49.627 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 16.8 to 18.8
2021-03-17 12:59:59.654 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 18.8 to 21.1
2021-03-17 12:59:59.656 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 18.8 to 21.1
2021-03-17 13:00:02.758 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeteramps' changed from -21.575 to -22.468
2021-03-17 13:00:02.807 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeterwatts' changed from -2432.703 to -2566.359
2021-03-17 13:00:09.707 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 21.1 to 23.5
2021-03-17 13:00:09.709 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 21.1 to 23.5
2021-03-17 13:00:18.918 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ZWaveNode008WAPIRZ1PIRMotionDetector_BinarySensor' changed from ON to OFF
2021-03-17 13:00:18.940 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'ZWaveNode008WAPIRZ1PIRMotionDetector_MotionAlarm' changed from ON to OFF
2021-03-17 13:00:19.653 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 23.5 to 26.0
2021-03-17 13:00:19.655 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 23.5 to 26.0
2021-03-17 13:00:22.759 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeteramps' changed from -22.468 to -22.886
2021-03-17 13:00:22.800 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeterwatts' changed from -2566.359 to -2614.536
2021-03-17 13:00:29.667 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 26.0 to 28.4
2021-03-17 13:00:29.669 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 26.0 to 28.4
2021-03-17 13:00:39.758 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 28.4 to 30.6
2021-03-17 13:00:39.783 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 28.4 to 30.6
2021-03-17 13:00:42.758 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeteramps' changed from -22.886 to -20.566
2021-03-17 13:00:42.799 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeterwatts' changed from -2614.536 to -2200.302
2021-03-17 13:00:49.697 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 30.6 to 32.6
2021-03-17 13:00:49.699 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 30.6 to 32.6
2021-03-17 13:01:02.758 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeteramps' changed from -20.566 to -62.201
2021-03-17 13:01:02.799 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeterwatts' changed from -2200.302 to -7612.718
2021-03-17 13:01:19.803 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DryerSonoff_Temperature' changed from 32.6 to 31.9
2021-03-17 13:01:19.827 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Sonoff1_Temperature' changed from 32.6 to 31.9
2021-03-17 13:01:22.758 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeteramps' changed from -62.201 to -62.676
2021-03-17 13:01:22.800 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HomeEnergyMeterGen5_Electricmeterwatts' changed from -7612.718 to -7685.053

Any thoughts?

Why would your rule react to the temperature rising? I thought you only want it to react to the temperature falling below 28. I’m assuming that didn’t happen either, in which case it’s most likely that your greater-than/less-thans don’t work in UI rules.

Sorry I did another test rule to notify me when temp exceeds 28C because I wanted to use that for quicker testing when I start the dryer. “Dryer is hot” rule.

Then it comes back to your rule triggers not working. I assume that the UI rule is trying to match ">28" and coming up empty.

OK, so any help on how to rewrite my triggers above in a way that it can pick up a greater than value properly?

As I said earlier, trigger the rule on “temperature changed”, and then set up the IF conditions. The rule will run every time the temperature changes, but only send commands when the conditions (temp drops from above 28 to below 28) are met.

I can’t help you with UI or any other rule systems since I don’t use them.

1 Like

Well I tried to use some of the previous examples and came up with the following code for my cooldown rule.

  - id: "1"
    configuration:
      itemName: DryerSonoff_Temperature
    type: core.ItemStateChangeTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: >-
        var TempDryer = DryerSonoff_Temperature.state as Number

        var boolean TempNotif = false
          if( TempDryer <= 28 | °C && TempNotif == false) {
            val myAction = getActions("pushover", "pushover:pushover-account:a3272e5b52")
            var receipt = myAction.sendMessage("The Clothes are dry!", "Arnett Manor")
            item LivingRoomEcho_Speak.sendCommand('The clothes are moist, but not dry')
            logInfo("Dryer Sensor Cooling Down", "Dryer Cold" + TempDryer.toString)
            TempNotif = true
            }
            else if( TempDryer > 28 | °C && TempNotif == true ) {
                TempNotif = false
            }
    type: script.ScriptAction

The tempdryer is defined in the script, but obviously not correctly, since it clearly doesn’t work at all, not sure what else is wrong.

Not sure why LivingRoomEcho is undefined because that’s the name of the thing

var boolean TempNotif = false
  if( TempDryer <= 28 | °C && TempNotif == false) {
    val myAction = getActions("pushover", "pushover:pushover-account:a3272e5b52")
    var receipt = myAction.sendMessage("The Clothes are dry!", "Arnett Manor")
    item LivingRoomEcho_Speak.sendCommand('The clothes are moist, but not dry')
    logInfo("Dryer Sensor Cooling Down", "Dryer Cold" + TempDryer.toString)
    TempNotif = true
    }
    else if( TempDryer > 28 | °C && TempNotif == true ) {
        TempNotif = false
    }
   The method or field item is undefined; line 6, column 303, length 4
2021-03-18 20:23:21.183 [DEBUG] [noff.internal.handler.HandlerAccount] - Sonoff Connection Check Running

Global variables don’t work. Each time a rule runs, it resets the value. If you want to persist a value, you need to use a virtual item to store it. But that’s not actually necessary for what you’re doing.

I wasn’t clear enough when I said “previous state” and “new state”. These are implicit variables that you can use within DSL rules. Sorry, I should have included the link to the docs when I posted that.

So, the equivalent to your attempted UI rule is:

if (Sonoff1_Temperature.state <= 28 && Sonoff1_Temperature.previousState > 28)
{
Do stuff
}

I haven’t tested this, so I’m not sure it’ll work.

I think I’m just getting more confused as this goes on.

I think the code I want then is:

if (Sonoff1_Temperature.state <= 28 && Sonoff1_Temperature.previousState > 28) {
            val myAction = getActions("pushover", "pushover:pushover-account:a3272e5b52")
            var receipt = myAction.sendMessage("The Clothes are dry!", "Arnett Manor")
            LivingRoomEcho_Speak.sendCommand('The clothes are moist, but not dry')}

But in OH3 Settings>Rules, if you click to create a new rule, you can’t simply add this code and save it, you have to add a trigger, and then create a DSL rule based on that trigger. How can I just use what you’re proposing?