Code Monkey home page Code Monkey logo

smarthome-washer's People

Contributors

fleker avatar shannonhwu-google avatar tonicorinne avatar vibgy avatar yoichiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

smarthome-washer's Issues

[Step 3] Eslint: Unexpected token =>

I could not deploy with firebase deploy due to a rudimentary issue with ESLint. Note: this is not an error with the published code, however, a versioning issue with ESLint and ecmaVersion.
I installed @babel/eslint-parser Version 7.16.0 to the node modules via

$ npm install @babel/preset-env --save-dev 

The patch.txt file {patch.txt}

Shows the following changes:

  1. Addition of: parser: "@babel/eslint-parser" in .eslintrc.js line 2
  2. Addition of "no-unused-vars": "warn" in .eslintrc.js line 14
  3. Removal of .eslintrc.json
  4. Addition of babel.config.json

Finally, the resulting configuration should resemble:

eslint-compile

To go further you can remove the warnings with "off" instead of "warn" explained here.

Google Home Mini always reply "Sorry, it looks like the washer is unavailable right now"

I am able to deploy the cloud fulfillment to the firebase.
I am able to add the device-washer to the Google Home app.
I am able to turn on /off the washer at Google Home app graph UI. There is On/off button at Washer. The changes can be reflected on firebase realtime database
However when I try to use voice command to Google Home Mini or Google Home app like, "Turn on washer " or "Turn on living room washer". Google Home Mini always reply "Sorry, it looks like the washer is unavailable right now"
This is also happen when I try to type the command in Google Home app.

Information:

  1. The firewall for AP and desktop are turned off.
  2. Same wifi has been connected with Phone, desktop, Google Home Mini one.
  3. System Firmware: 250118. cast firmware version: 1.54.250118. Android Google Home app: 2.39.1.7
  4. same owner account for Google Home mini, Google Home app, desktop Chrome.

To fix this, I have try out

  1. Link and relink washer to google home app and put under living room, Google Home mini is located at same living room .
  2. Use owner account, same wifi 2.4GHz with my desktop and google home mini and phone
  3. Speak "Sync devices " to google home mini, Google Home mini reply as "Got it, sync devices "
  4. Reboot Google Home mini
  5. Factory reset, plug out the power cable for more than 1 min, unlink and relink washer , try voice control to Google Home app or Google Home mini" turn on living room washer" or "turn on washer, get reply as ""Sorry, it looks like the washer is unavailable right now"
  6. For my Home router, there is no special setting for enable/ disable AP isolation.

ReportState /Firebase and AC control

Hi Nick

Sorry for posting as an issue, but I couldn't find another place to contact you.

In your smarthome-washer you store the states of the devices in the firebase db, which triggers the ReportState to also store the same states.
Why not store directly to ReportState and when needed, read the state from ReportState?

Thanks for your help and comments.

Best regards

Javier!!

Devices shown as loading for around 10-15 seconds in Google Home app

Everything seems to work fine but my Google Home shows my device state as "loading" for around 10-11 seconds every time I open the app. Same thing is observed in Home Control in my Nest Hub 2.

But devices from other vendors like sinric pro take only 1-2 seconds to show their device state in Google Home.

@Fleker Please help as I am using this code on my several ESP8266 with Google Nest Hub to control my home. And I have to wait for 10-15 seconds every time to even turn on the lights.

"Await" Errors in building Washer

There are so many errors in this example it's hard to get through.

My latest is index.js contains the statement: await Promise.all(queryPromises) (line 278)
Deploying gives the error: SyntaxError: await is only valid in async functions and the top level bodies of modules

Which is true. Couldn't find the Promise function to change it. I suspect this worked with an earlier version of node.js, but wish the example kept up with the node.js versions.

So, how should this be fixed?

Another error, which I figured out, was to get the => arrow functions to 2019 in the eslint config ECMAScript tag. Took a few hours to figure that one out.

Build fails at step 3 - Error on actions for google webpage

Hi

I've just cloned this project and have been following the tutorial step by step, but when i try to start the test in the simulator (as mentioned in the tutorial) i get this error:

GoogleFulfillment 'actions.fulfillment.devices' is not supported

and therefore i can't carry on with the guide.

node v: 6.12.3
npm v: 3.10.10
firebase v: 6.3.1

Tunnel ---------ngrok.io not found

I am trying out hidden eye from GitHub as a test with my friends. Hidden eye works like this it makes a fake login page and then uses ngrok to forward this it people outside your network. When my friend does it works but when I ask him to run for example 2107f2ac.ngrok.io it says Tunnel 79cd0b59.ngrok.io not found. I have restarted, reinstalled and done everything under the moon. I thought that ngrok passes firewalls but my only guess is maybe my firewall is blocking it so I added a firewall exception of the ngrok port but it still does not work. Please help

Where is the image defined that the washer displays in Google Home?

This is not a bug, but the question is related to the washer example.
Where is the image defined/identified that shows up in Google Home once the device is linked successfully? I spent time reading the documents but didn't find the answer to this. I'm just looking for a link to a webpage that can explain how to make my own.

Thank you in advance.

How to respond with "not found" on app.onSync

Hi.

I know this is not an issue, and very sorry for asking this here, but can't find another place.

I followed the washer example and it is working. I update onSync to request the devices from a database (using an email as ID). It works properly.
The problem is when the email doesn't exist on my DB.... how do I return a "response.status=400" (o similar)??

This is the idea:

app.onSync((body,headers) => { if (emailExists) return (listOfDevices(email)); else return ( ?????????? ); //this should be a response.statuscode != 200 });

Thanks for your help

Question - Push notification & security system

@Fleker Is there any way to send push notification using gcm?
I added a virtual security system, searched for motion-door windows sensors but they are not available...

Is there any plan for adding security system to touch control?
Arm - Disarm like on off maybe... (becuase i have to arm-disarm by talking to asistant which has a language limit)

Setup Screen and APP visibility to other account

Hi Guys,

I followed SmartHome Documentation with the sample and the basic demo is working fine for me, but I'm still unclear about the authentication between my Application and the Smart home.

Let me explain in details:-

  1. We have created a Smart Home application same like the
    eWeLink
  2. Now we are working on the Google Smart Home integration with the application.
  3. We have a number of users on our own smart home application(same like eWeLink).
  4. In Google Home when we add a device it ask us to select a provider, in case of eWeLink we select provide "eWeLink" and when click on setup button it redirect us to eWeLink server to authenticate and upon the successfull authentication it redirect user back to Google Home application with thye list of devices that are related to particular eWeLink user. This stage is unclear for me.
  5. In a sample Google Home application that I created by reading the article is missing the setup process.

So finally my questions are below:-

  1. How I can implement a SETUP process in Smart Home API integration?
  2. My test Google Home provide is in test mode, what are steps to make it public or in production?
  3. Is there any demo app available for complete smart home api compatible to handle Sensors, fans speed, light dimming features?

Looking forward to any helpful answer...

Thanks

Re-Sync everytime is normal usage? - Question

@Fleker
When i sync the Google Home screen, after sometime (max a few hours) i have to re-sync the Google Home screen by pulling down the screen.
If i dont make sync:

(orginal code)
app.onQuery(async (body) => {
  const {requestId} = body;
  const payload = {
    devices: {},
  };
  const queryPromises = [];
  for (const input of body.inputs) {
    for (const device of input.payload.devices) {
      const deviceId = device.id;
      queryPromises.push(queryDevice(deviceId)
        .then((data) => {
          // Add response to device payload
          payload.devices[deviceId] = data;
        }
      ));
    }
  }

...

which goes to

(orginal code)
const queryDevice = async (deviceId) => {
  const data = await queryFirebase(deviceId);
  return {
    on: data.on,
    isPaused: data.isPaused,
    isRunning: data.isRunning,
    currentRunCycle: [{
      currentCycle: 'rinse',
      nextCycle: 'spin',
      lang: 'en',
    }],
    currentTotalRemainingTime: 1212,
    currentCycleRemainingTime: 301,
    currentModeSettings: {
      load: data.load,
    },
    currentToggleSettings: {
      Turbo: data.turbo,
    },
  };
}

doesnt remember my email (username) so device is not responding.

Re-Sync everytime is normal usage for Google Home?

note my app published.

No toggle in home app

I see washer in android home app (with a gear on right top) when i click on it it goes to device settings. There is nothing about on-off, turbo etc.

Is this normal?

image

deploy fails in Step #3

First error:

Error: package.json in functions directory has an engines field which is unsupported. The only valid choices are: {"node": "8"} and {"node": "6"}.

After I change the package.json file to use "node":"8", then I get following error:

i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

TypeError: Cannot read property 'databaseURL' of undefined
    at RepoManager.databaseFromApp (/Users/prafulll/code/personal/direkshanProjects/googleAssistant/smarthome-washer/washer-start/functions/node_modules/@firebase/database/dist/index.node.cjs.js:14985:39)
    at Object.instance.INTERNAL.registerService.Reference [as database] (/Users/prafulll/code/personal/direkshanProjects/googleAssistant/smarthome-washer/washer-start/functions/node_modules/@firebase/database/dist/index.node.cjs.js:15526:130)
    at FirebaseAppImpl._getService (/Users/prafulll/code/personal/direkshanProjects/googleAssistant/smarthome-washer/washer-start/functions/node_modules/@firebase/app/dist/index.cjs.js:134:66)
    at FirebaseAppImpl.(anonymous function) [as database] (/Users/prafulll/code/personal/direkshanProjects/googleAssistant/smarthome-washer/washer-start/functions/node_modules/@firebase/app/dist/index.cjs.js:323:31)
    at Object.serviceNamespace [as database] (/Users/prafulll/code/personal/direkshanProjects/googleAssistant/smarthome-washer/washer-start/functions/node_modules/@firebase/app/dist/index.cjs.js:308:32)
    at Object.<anonymous> (/Users/prafulll/code/personal/direkshanProjects/googleAssistant/smarthome-washer/washer-start/functions/index.js:28:30)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

Having trouble? Try firebase deploy --help

Improve Logs readability

In the codelab documentation at https://codelabs.developers.google.com/codelabs/smarthome-washer/#5, the log for a smarthome request shows an “info” log with the details of the Request object as shown below:

Screen Shot 2021-02-08 at 9 34 09 AM

However, when running the codelab, the request object is not shown:

LogWithoutDebug

Digging into the code, it appears that option “debug” must be enabled when instantiating smarthome, as shown below:

const app = smarthome({ debug: true });

However, after this is done, one will quickly notice readability issues of the log entries. Unfortunately, one log message appears with multiple log entries as shown below:

LogWithDebug

This appears to be caused by the fact that the smarthome node.js client library (actions-on-goole-nodejs) uses console.log(). These readability issues are mentioned in the Cloud Functions documentation “Write and view logs”. It is suggested the following:

With console.log, you may notice issues in the readability of your logs when migrating from the Node.js 8 runtime to Node.js 10 or 12. To work around this temporarily, add the following library to your functions:
require("firebase-functions/lib/logger/compat");
The recommended long-term solution for migrating to Node.js 10 or 12 is to refactor code to use the logger SDK.

The codelab does not use console.log() so this does not apply here. Rather, it is the use of console.log() in the node.js client library that is the issue.

Given that, would be great to do the following:

  • update documentation to clarify that app option “debug” must be set to true to see request and header details when the smarthome endpoint is called.
  • Ideally, the node.js smarthome client could be configured to use the cloud functions logging mechanism. For that, I’ll follow up with an issue at https://github.com/actions-on-google/actions-on-google-nodejs.

Upgrade to Blaze plan in firebase deploy command

When I deploy firebase, I get a error like below.

Your project must be on the Blaze (pay-as-you-go) plan to complete this command. Required API cloudbuild.googleapis.com can't be enabled until the upgrade is complete. To upgrade, visit the following URL:

It is really required to upgrade to blaze plan for just connecting Google Home app with Firebase Database?

Washer fails to connect

I've gone through the example and added the washer to my phone, but it fails to connect. Here are the logs

I replaced the washer-start example with the washer-done example, just in case I typed something wrong, but it still throws this error:

{
  "insertId": "1q5xl8qg1z19oc2",
  "jsonPayload": {
    "locale": "en-US",
    "executionLog": {
      "executionResults": [
        {
          "latencyMsec": "83",
          "requestId": "11498087478043784573",
          "executionType": "PARTNER_CLOUD",
          "actionResults": [
            {
              "action": {
                "actionType": "STATE_QUERY"
              },
              "status": {
                "externalDebugString": "Error querying agent backend. State: URL_UNREACHABLE, reason: 2",
                "statusType": "EXECUTION_BACKEND_FAILURE"
              },
              "device": {
                "deviceType": "WASHER"
              }
            }
          ]
        }
      ]
    }
  },
  "resource": {
    "type": "assistant_action_project",
    "labels": {
      "project_id": "smart-home-example-39c50"
    }
  },
  "timestamp": "2021-02-28T22:40:56.720383524Z",
  "severity": "ERROR",
  "logName": "projects/smart-home-example-39c50/logs/assistant_smarthome%2Fassistant_smarthome_logs",
  "receiveTimestamp": "2021-02-28T22:40:56.720383524Z"
}

Typo in Washer onSync response

Error occurred while parsing your function triggers.

/home/fleker/voice-tech-to/smarthome-washer/washer-start/functions/index.js:83
          defaultNames: 'My Washer'],
                                   ^

SyntaxError: Unexpected token ]
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at /usr/lib/node_modules/firebase-tools/lib/triggerParser.js:21:11

Cannot link device, SYNC fails

I'm at Step 3, trying to link my Google Assistant. After I click [test] Smarthome Washer in the Assistant's settings menu, I get an error: "Coultn't update the settings. Check your connection."

This is the error log from Stackdriver:

{
 insertId:  "8c32v2g18s0e5o"   
 logName:  "projects/smarthome-washer-c7c7a/logs/actions.googleapis.com%2Factions"   
 receiveTimestamp:  "2018-09-02T18:48:37.606671463Z"   
 resource: {
  labels: {
   action_id:  "SMART_HOME_SYNC"     
   project_id:  "smarthome-washer-c7c7a"     
   version_id:  ""     
  }
  type:  "assistant_action"    
 }
 severity:  "ERROR"   
 textPayload:  "SYNC: Request ID 14832988310373986323 update devices failed: INVALID_ARGUMENT. Detail: Error: [Cannot find field: attributes in message home.graph.sync.DevicesSyncResponse.DeviceInfo] while parsing JSON [{"payload":{"agentUserId":"123","devices":[{"deviceInfo":{"attributes":{"pausable":true},"hwVersion":"1.0","manufacturer":"Acme Co","model":"acme-washer","swVersion":"1.0.1"},"id":"washer","name":{"defaultNames":["My Washer"],"name":"Washer","nicknames":["Washer"]},"traits":["action.devices.traits.OnOff","action.devices.traits.StartStop","action.devices.traits.RunCycle"],"type":"action.devices.types.WASHER"}]},"requestId":"ff36a3cc-ec34-11e6-b1a0-64510650abcf"}]"   
 timestamp:  "2018-09-02T18:48:37.597624026Z"   
}

Thanks!

while installing getting error : npm --prefix functions/ install

Hi Team,
Am getting below error tried npm --prefix functions/ install in windows 10

C:\Users\Test\Downloads\smarthome-washer\washer-start>npm --prefix functions/ install
npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Test\AppData\Roaming\npm-cache_logs\2019-08-07T03_32_26_252Z-debug.log

C:\Users\Test\Downloads\smarthome-washer\washer-start>firebase use --add
? Which project do you want to add? smarthomeprojectforcodel-f0d40
? What alias do you want to use for this project? (e.g. staging) bathap

Created alias bathap for smarthomeprojectforcodel-f0d40.
Now using alias bathap (smarthomeprojectforcodel-f0d40)

C:\Users\Test\Downloads\smarthome-washer\washer-start>firebase deploy
! functions: package.json indicates an outdated version of firebase-functions.
Please upgrade using npm install --save firebase-functions@latest in your functions directory.

=== Deploying to 'smarthomeprojectforcodel-f0d40'...

i deploying database, functions, hosting
i database: checking rules syntax...

  • database: rules syntax for database smarthomeprojectforcodel-f0d40 is valid
    i functions: ensuring necessary APIs are enabled...
  • functions: all necessary APIs are enabled
    i functions: preparing functions directory for uploading...

Error: Error parsing triggers: Cannot find module 'firebase-functions'

Try running "npm install" in your functions directory before deploying.

C:\Users\Test\Downloads\smarthome-washer\washer-start>npm --prefix functions/ install
npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Test\AppData\Roaming\npm-cache_logs\2019-08-07T03_33_53_110Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli 'functions/',
1 verbose cli 'install' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 21d993010ea83c1a
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file: Could not install from "" as it does not contain a package.json file.
8 timing stage:rollbackFailedOptional Completed in 1ms
9 timing stage:runTopLevelLifecycles Completed in 45ms
10 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\Test\Downloads\smarthome-washer\washer-start\package.json'
11 verbose cwd C:\Users\Test\Downloads\smarthome-washer\washer-start
12 verbose Windows_NT 10.0.18362
13 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "--prefix" "functions/" "install"
14 verbose node v10.16.2
15 verbose npm v6.9.0
16 error code ENOLOCAL
17 error Could not install from "" as it does not contain a package.json file.
18 verbose exit [ 1, true ]

firebase use -add error:Server Error. read ECONNRESET

when i follow step 3 and use "firebase use -add", there was an error:
Server Error. read ECONNRESET
My firebase-debug.log is ``

[debug] [2019-03-01T01:56:57.906Z] ----------------------------------------------------------------------
[debug] [2019-03-01T01:56:57.908Z] Command: D:\Program Files (x86)\nodejs\node.exe C:\Users\chongting.li\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js use --add
[debug] [2019-03-01T01:56:57.908Z] CLI Version: 6.4.0
[debug] [2019-03-01T01:56:57.909Z] Platform: win32
[debug] [2019-03-01T01:56:57.909Z] Node Version: v10.15.0
[debug] [2019-03-01T01:56:57.913Z] Time: Fri Mar 01 2019 09:56:57 GMT+0800 (GMT+08:00)
[debug] [2019-03-01T01:56:57.913Z] ----------------------------------------------------------------------
[debug]
[debug] [2019-03-01T01:56:57.938Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2019-03-01T01:56:57.940Z] > authorizing via signed-in user
[debug] [2019-03-01T01:56:57.948Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects

[debug] [2019-03-01T01:57:37.691Z] Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:111:27)
[error]
[error] Error: Server Error. read ECONNRESET

Step 3: cannot open washer page

Firebase deploy completed (in washer-done directory),
But when I click [test] app on Assistant settings menu, it didn't return a washer webpage, it only showed the white page and text "Accounts now linked".

image

2 devices onSync

app.onSync((body) => {
  return {
    requestId: body.requestId,
    payload: {
      agentUserId: '123',
      devices: [{
        id: 'washer',
...

Only returns 1 device. If i have 2 devices how can i response?

deploy fails in Step 3 (again)

I'm getting the following error during deploy:

Error: Error occurred while parsing your function triggers.

TypeError: Cannot read property 'databaseURL' of undefined
at firebase.INTERNAL.registerService.Reference ([...]\smarthome-washer\washer-start\functions\node_modules\firebase\database-node.js:256:95)
at Object.factories.(anonymous function) [as database] ([...]\smarthome-washer\washer-start\functions\node_modules\firebase\app\firebase_app.js:245:32)
at FirebaseAppImpl.getService ([...]\smarthome-washer\washer-start\functions\node_modules\firebase\app\firebase_app.js:108:78)
at Object.serviceNamespace [as database] ([...]\smarthome-washer\washer-start\functions\node_modules\firebase\app\firebase_app.js:263:40)
at Object. ([...]\smarthome-washer\washer-start\functions\index.js:26:30)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

More info:

npm --version
5.6.0

node --version
v8.11.4

package.json:
{
"name": "smarthome-washer",
"description": "Codelab for controlling devices through the Google Assistant",
"engines": {
"node": "8" -> changed this one from 6 to 8, didn't help
},
"dependencies": {
"actions-on-google": "^2.2.0", -> tried removing all "^", didn't help
"cors": "^2.8.4",
"firebase": "^4.0.0",
"firebase-admin": "^5.13.0",
"firebase-functions": "^2.0.0",
"googleapis": "^27.0.0"
},
"private": true,
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1"
}
}

Thanks!

Deployed application running failed since some changes of firebase database api?

When I followed your steps and deploy the application in the firebase, it gives me the message like this:

@firebase/database: FIREBASE FATAL ERROR: Cannot parse Firebase url. Please use https://<YOUR FIREBASE>.firebaseio.com

Would you consider keeping this repository up-to-date, so that people won't say google home sucks (even for developer)?

Link to Google Assistant unclear and not working

OS: Android 11
Device: Pixel 4 XL

I am attempting to create a new device in the Actions Console and following the smart home washer example.

The following instruction:

Step 4. Create a Washer
Link to Google Assistant section
Step 3. Select the plus (+) icon in the bottom right corner

There is no plus icon in the corner. The only thing I can think of is opening the Google Home app and adding a new device.

However, there is no test device to add in this section either.

I can't go with the example as there is no way to test out whether the device is added

Device not showing up in linked devices

I followed the codelabs, but on SYNC, there was a "Signing in" popup, and then nothing. The device did not show up in linked devices.

The last log says
"Function execution took 6 ms, finished with status code: 302"
the one before that says
"undefined?code=xxxxxx&state=undefined"

codelab tutorial is not complete

on step 3, after calling firebase deploy we're told to "Configure your project in the Actions on Google console"

we're then shown a photo of "account linking(optional)"

this photo lead me to believe it was an optional step when in fact it is not optional. not to mention you have to click on "Overview" before seeing the account link option.

then you're also required to give "invocation" a name, which the codelab doesnt mention

then we are told
Enter the following client information:

Client ID ABC123
Client secret DEF456

...click save

but there are also 2 additional fields before being able to click save.

was hoping someone could improve the clarity of step 3. i was stuck not being able to retrieve the washer for some time.

switch to esm

  • Update NodeJS version to something newer like 18+ that have fetch built in and other goodies
  • Update package json to have type module:
  "type": "module",
  "engines": {
    "node": "18"
  },
  • change eslint parser optino to something like
    "parserOptions": {
      "ecmaVersion": 2022,
      "sourceType": "module"
    },

in public html: use type="module

<script src="main.js" type="module"></script>

fyi, i think it's better to keep all exports at the bottom, it's easier to refactor such code and easiely see what kind of stuff is being exported

so removing exports.reportstate = stuff and just declaring it as a variable and then later at the bottom.
then it's just a matter of just doing one small change

- module.exports = {
+ export {
   everything
 }

it's also way more easier to see what is getting exported.

Database not created when configuring the Firebase project

When initializing the Firebase project with on firebase version 11.20.0
firebase init

The options for the features provided differ from the example.

Example: Database: Configure Firebase Realtime Database and deploy rules
Appears: Realtime Database: Configure a security rules file for Realtime Database and (optionally) provision default instance

next step should be the following prompt:

? It seems like you haven't initialized Realtime Database in your project yet. Do you want to set it up?
Yes

but the option doesn't appear, this leads to the database not being created in the project console.

Step 3: click `[test] My Washer` didn't return a list of devices

Firebase deploy completed (in washer-done directory),
My configurations in the Actions on Google console are:

Fulfillment URL: <Hosting URL>/smarthome
Client ID: ABC123
Client secret: DEF456
Auth URL: <Hosting URL>/fakeauth
Token URL: <Hosting URL>/faketoken

Hosting URL is https://<my-project-id>.firebaseapp.com

But when I click [test] My Washer on Assistant settings menu on my Pixel Phone, it didn't return a list of devices, it showed the webpage of hosting URL, I cannot link to the Google Assistant:

ezgif com-video-to-gif

Please help, thanks!

TypeError: Cannot read property 'databaseURL' of undefined

I follow the instruction on https://codelabs.developers.google.com/codelabs/smarthome-washer/index.html#2. But when I run 'firebase deploy', it show the error:
Error: Error occurred while parsing your function triggers.

TypeError: Cannot read property 'databaseURL' of undefined
at RepoManager.databaseFromApp (C:\Users\ERCLab\Desktop\smarthome-washer\washer-start\functions\node_modules@firebase\database\dist\index.node.cjs.js:14985:39)
at Object.instance.INTERNAL.registerService.Reference [as database] (C:\Users\ERCLab\Desktop\smarthome-washer\washer-start\functions\node_modules@firebase\database\dist\index.node.cjs.js:15526:130)
at FirebaseAppImpl._getService (C:\Users\ERCLab\Desktop\smarthome-washer\washer-start\functions\node_modules@firebase\app\dist\index.cjs.js:134:66)
at FirebaseAppImpl.(anonymous function) [as database] (C:\Users\ERCLab\Desktop\smarthome-washer\washer-start\functions\node_modules@firebase\app\dist\index.cjs.js:323:31)
at Object.serviceNamespace [as database] (C:\Users\ERCLab\Desktop\smarthome-washer\washer-start\functions\node_modules@firebase\app\dist\index.cjs.js:308:32)
at Object. (C:\Users\ERCLab\Desktop\smarthome-washer\washer-start\functions\index.js:26:30)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)

I don't know how to fix it

Is ReportState stored in Firebase?

Hi.

I followed all steps of washer demo and is working, but I really don't fully understand the reportstate function from step 10. The logic says that it will be triggered when firebase is written and will call "app.reportState" to update HomeGraph. That is what I understand.

But I did this example.

  1. Remove the reportstate trigger from step 10 (no app.reportState is called)
  2. Manually update firebase database.
  3. Ask googlehome if light is on, and it answers correctly based on the status of firebase. Of course, this is true because "app.onQuery" retrieve status from firebase.

With that in mind, when app.OnExecute is called, firebase is updated. When I ask for light status, app.onQuery retrieve status from firebase.... so, what is "app.reportState(postData)" used for? Is HomeGraph database same as firebase database?

Thanks for any clarification.

Report state on screen

image
When i change OnOff value to true or false (from firebase or web update) it doesnt sync immediately on this screenshot.
Go back to home screen an re enter to device show updated value no problem.

How can i see device position immediately?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.