Google Home Notifier

Something else is tying up your port 8080. Check to see if you have another instance of this app running. If not you may have to change to a different port number. Edit the example.js file and change the port in there.

If you change the port the app listens on, don’t forget to make the same change to whatever piston you’re using to make the POST requests.

Thanks… working now. I had indeed another old one running in fg

1 Like

I’m running BubbleUPnP Server on an Android Tablet and setup Google Home as a DLNA speaker through that… then you can use Media Connect to sent TTS to it. There’s a bit of a delay, but it works pretty well.

The benefit of this is that you don’t need to have pre-recorded messages ready to cast. You can setup any text you want and have it speak it.

Bookmarked this to fix.

3 Likes

In case anyone is interested, I modified the example.js file again to accept GET requests instead of POST so it can be triggered by CoRE without having to modify CoRE code. I have 3 GH devices, so this is set up to send requests to different ones by hitting different endpoints. If you make requests to all 3 endpoints at the same time (like the piston below), it will execute the commands in parallel so the notifications come out mostly at the same time. Unless you have 3 GH’s in the Office, Kitchen, and Master Bedroom you’ll probably want to tweak to fit your needs.

Example.js script:

var express = require('express');
var officeGH = require('./google-home-notifier');
var kitchenGH = require('./google-home-notifier');
var mbrGH = require('./google-home-notifier');
var app = express();
const servicePort = 8071;
const officeIP = '192.168.0.112';
const kitchenIP = '192.168.0.121';
const mbrIP = '192.168.0.119';

app.listen(servicePort, function () {
    console.log('http://192.168.0.110:8071/(gh-location)?text=hello');
})
    
app.get('/gh-office', function (req, res) {
    if(!req.query) return res.sendStatus(400)
    console.log(req.query);
    var officeText = req.query.text;
    if(officeText) {
        res.send(officeIP + ' will say: ' + officeText + '\n');
        officeGH.notify(officeText, officeIP, function(res) {
            console.log(res + ' ' + officeIP + ' (office)');
        });
    } else {
        res.send('Office: Please GET "text=hello"');
    }   
})

app.get('/gh-kitchen', function (req, res) {
    if(!req.query) return res.sendStatus(400)
    console.log(req.query);
    var kitchenText = req.query.text;
    if(kitchenText) {
        res.send(kitchenIP + ' will say: ' + kitchenText + '\n');
        kitchenGH.notify(kitchenText, kitchenIP, function(res) {
            console.log(res + ' ' + kitchenIP + ' (kitchen)');
        });
    } else {
        res.send('Kitchen: Please GET "text=hello"');
    }
})

app.get('/gh-mbr', function (req, res) {
    if(!req.query) return res.sendStatus(400)
    console.log(req.query);
    var mbrText = req.query.text;
    if(mbrText) {
        res.send(mbrIP + ' will say: ' + mbrText + '\n');
        mbrGH.notify(mbrText, mbrIP, function(res) {
            console.log(res + ' ' + mbrIP + ' (mbr)');
        });
    } else {
        res.send('MBR: Please GET "text=hello"');
    }
})

Here’s the piston:. Requests are send as FORM and send the variable named {text}, where {text} contains whatever you want GH to say.

So does this work with core only or is there any thing else needed?

CoRE and a computer running node.js app are needed.

1 Like

Is there a step by step instruction on how to do this, please?

Try this, it’s easier than the posts I made. I’ve actually stopped using the node app I posted above and started using this one instead. Only downside is that if you are sending speech to multiple devices at the same time, they all wake up and speak one after another rather than in parallel.

Thank you, I’ve fixed it in CoRE (published) and taking care of it in webCoRE as well. Implementing the http requests…

1 Like

You are the man! This got it working for me! Had a little issue with case sensitivity of my local variable in CoRE - so instead of welcoming me home it announced “NULL!” to the house. Hahaha. So many things I can do now! Thanks!

1 Like

For some reason the latest CoRE still wasn’t able to send my request without this change.

This worked like a charm for me, made a hybrid with NGROK for public calls without port forwarding as well… works wonderfully! Thanks!!

1 Like

Hi there,

Sorry for pulling this thread back from the grave, but I had a question on your CoRE Piston. Can you tell me why you immediately set the {text} string variable to “”? Doesn’t that remove any text that was in there?

Also, how did you get it to “Immediately” set string? What does that mean?

I think that was a bug in the screenshot display. There was actually a value there.

I’ve moved over to webCore now instead of the original CoRE so my memory may not be the best, but when you choose the set variable option there should be a little slider in there somewhere that says to set it immediately. Immediately means to set te variable value before performing any other actions, this ensures that the variable has the correct value before the Speak command is sent to the GH device.

Hmm, I can’t seem to find that slider anywhere. Any chance it might have been labeled something else?

Do you think it might have been “Execute during evaluation stage”? I can’t seem to get CoRE to let me to activate this slider. It keeps saying “Please check the value range of input fields.” which I’m normally able to get around by hitting the back button on Android.

Side note - you said you were using WebCoRE now, correct? Is there anything different about the Make Web Requests command vs the old CoRE? Could I still just use my internal IP address in the URL? Or would I need an external URL (like ngrok?)

That sounds right. I remember having to play around with it to get it to stick, might try enabling, then going into a different field and backing out before selecting ok/done/whatever.

FYI, I’m using Chromecast Manager now for my GH devices, it still requires a node.js web server in the background but allows adding Google Home / Chromecast devices as actual media devices in ST, so instead of making web requests through CoRE or whatever, you can select the device and issue a Speak command instead. Probably the same capability but a little more intuitive after initial setup IMO.

WebCoRE web requests are similar to CoRE, here’s one for voice commands to my Harmony hubs.

Ok cool, thank you! I’ll try and replicate my voice announcements in WebCoRE then, since there appears to be a bug in the Android UI for CoRE.

1 Like

WebCoRE should be more user friendly, you can create your pistons via web interface instead of the limited ST app, and all of the actions execute sequentially so there’s no worry about setting variables during execution and that sort of thing.