bertreb / pimatic-home-connect

Pimatic plugin for connecting home-connect devices to Pimatic
MIT License
1 stars 0 forks source link

Question: how can use the proof of concept #1

Open heiko1988 opened 4 years ago

heiko1988 commented 4 years ago

Hi,

I have installed the plugin in pimatic directly over github. I have type my client ID and secret key.

No device found from home connect and no debug message in pimatic.

Can you write a little guide on how to set it up. I know it's a concept for now

bertreb commented 4 years ago

Hi, i added a small installation guide and updated the pimatic-home-connect.coffee.

heiko1988 commented 4 years ago

Thanks.

i have try. pimatic say error error [pimatic]: Cannot find module './lib/utils'

heiko1988 commented 4 years ago

ok, i have clone direct in /home/pi/pimatic-app/node_modules/ and then change the main.js, the lib error dosent come again

now say the console log [pimatic-home-connect] Home-connect offline

bertreb commented 4 years ago

Ok, i forgot in the instruction that you need to install home-connect-js and lodash first. In the pimatic-home-connect directory run command -> npm install This will install home-connect-js and lodash and then replace main.js

heiko1988 commented 4 years ago

ok, i have new reinstall now say the console log [pimatic-home-connect] Home-connect offline

no popup come in pimatic

what for date use you in the dev application in home connect?

Access Private Private access is limited to a single Home Connect user account as defined. Home Connect user account for testing: here i have my Private acc OAuth Flow: Device Flow Client ID: the application id Client Secret (optional): the applcation secret Success Redirect ? One Time Token Mode: Disabled

bertreb commented 4 years ago

Its not the device flow but the Authorisation Code Grant Flow you need to use for the application. It will probably change but for the POC its the ACGF

bertreb commented 4 years ago

The redirect uri is http://localhost:3000/o2c

bertreb commented 4 years ago

This is all part of the extended instruction 😄

heiko1988 commented 4 years ago

ok :)

say the same: [pimatic-home-connect] Home-connect offline

is the port 3000? or my pimatic port? and must the port be accessible externally?

bertreb commented 4 years ago

its 3000 not your pimatic port

heiko1988 commented 4 years ago

no i use intern 81 and externally 23003

bertreb commented 4 years ago

yes, but you must use 3000. It's not related to the pimatic ports

heiko1988 commented 4 years ago

ok, then I don't have to change anything? must the port be accessible externally and do I have to change the local host to my ip or my dns?

heiko1988 commented 4 years ago

ok, i reinstalled everything. i think: the error will be that authorization popup does not appear

before the question comes i have no popup blocker or other active things

bertreb commented 4 years ago

The plugin runs for authentication a webserver on port 3000 and opens a browser window on it self

bertreb commented 4 years ago

A checklist

bertreb commented 4 years ago

ok, then I don't have to change anything? must the port be accessible externally and do I have to change the local host to my ip or my dns?

No you don't need to change anything

heiko1988 commented 4 years ago

Ok, I try again

bertreb commented 4 years ago

You need to have the browser on the same computer as pimatic is running on!

heiko1988 commented 4 years ago

so i have try agian: this is my way

`root@raspberrypi:~ # cd /home/pi/pimatic-app root@raspberrypi:/home/pi/pimatic-app # cd ./node_modules root@raspberrypi:/home/pi/pimatic-app/node_modules # git clone https://github.com/bertreb/pimatic-home-connect Klone nach 'pimatic-home-connect' ... remote: Enumerating objects: 119, done. remote: Counting objects: 100% (119/119), done. remote: Compressing objects: 100% (83/83), done. remote: Total 119 (delta 69), reused 81 (delta 33), pack-reused 0 Empfange Objekte: 100% (119/119), 22.52 KiB | 0 bytes/s, Fertig. Löse Unterschiede auf: 100% (69/69), Fertig. root@raspberrypi:/home/pi/pimatic-app/node_modules # cd ./pimatic-h pimatic-harmonyhub/ pimatic-home-connect/ root@raspberrypi:/home/pi/pimatic-app/node_modules # cd ./pimatic-h pimatic-harmonyhub/ pimatic-home-connect/ root@raspberrypi:/home/pi/pimatic-app/node_modules # cd ./pimatic-home-connect/ root@raspberrypi:/home/pi/pimatic-app/node_modules/pimatic-home-connect # npm install npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

core-js@2.6.11 postinstall /home/pi/pimatic-app/node_modules/pimatic-home-connect/node_modules/core-js node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:

https://opencollective.com/core-js https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN pimatic-home-connect@0.0.2 requires a peer of pimatic@0.9.* but none is installed. You must install peer dependencies yourself. npm WARN pimatic-home-connect@0.0.2 No license field.

added 153 packages from 137 contributors and audited 280 packages in 42.704s

13 packages are looking for funding run npm fund for details

found 0 vulnerabilities

root@raspberrypi:/home/pi/pimatic-app/node_modules/pimatic-home-connect #`

then i have the main.js frome here /home/pi/pimatic-app/node_modules/pimatic-home-connect to here /home/pi/pimatic-app/node_modules/pimatic-home-connect/node_modules/home-connect-js

then i type in the config:

    {
      "plugin": "home-connect",
    }

then start pimatic, and in the plugin i have type the cliendid and secret

   "plugin": "home-connect",
      "clientId": "xxxxx",
      "clientSecret": "xxxxx",
      "simulation": true,
      "debug": true,
      "active": true

and then i have restart, and now come nothin prompt.

what make i wrong ;)

heiko1988 commented 4 years ago

can make a buttom in plugin conf to start the auth?

bertreb commented 4 years ago

In the current setup the browser must run on the same computer Pimatic is running on. So you can't use a head-less configuration!

bertreb commented 4 years ago

For the headless setup (what most a the user use) i need to change the authentication flow to the Device Flow. The home-connect-js lib doesn't support that and there some work to do.

bertreb commented 4 years ago

can make a buttom in plugin conf to start the auth?

no, thats not a solution (see my 2 posts above)

heiko1988 commented 4 years ago

ok, that's the problem ;)

I have my pimatic on the pi and try it from my laptop.

then it is clear that it does not work.

is there a way that i can do it via the pc or directly with curl or so on the pi in the console?

bertreb commented 4 years ago

No curl will not work. You need to have to login with something like vnc.

bertreb commented 4 years ago

But if you have a laptop. Its not very complex to install basic pimatic(+nodejs) and do the install steps for pimatic-home-connect. You start/stop pimatic via commandline.

heiko1988 commented 4 years ago

Ok, and can this transfer to my pimatic on the pi? After all work?

bertreb commented 4 years ago

It could work, i will test that and let you know. This is still a POC way-of-working!

bertreb commented 4 years ago

Please remove your ClientId and ClientSecret from the thread :)

heiko1988 commented 4 years ago

It could work, i will test that and let you know. This is still a POC way-of-working!

Ok thanks

heiko1988 commented 4 years ago

Please remove your ClientId and ClientSecret from the thread :)

I have removed and delete the application on home connect dev page.

bertreb commented 4 years ago

Thats not what I ment, but its also a solution 😅 You need a new application to test

heiko1988 commented 4 years ago

I am aware of that :)

But safe is safe

heiko1988 commented 4 years ago

ok, i have check again.

so,

now i have a vnc server on the pi and am connected.

I use the chromium browser and did the whole thing again, including new id and secret.

Unfortunately I can't get it done;)

bertreb commented 4 years ago

You are logged in via vnc to the pi? can you open a chrome window in vnc screen?

bertreb commented 4 years ago

You need a vnc app on your laptop, you can't use a browser!

heiko1988 commented 4 years ago

yes i connect per vnc to the pi and in the pi session i open a chromium browser

Unbenannt

see is localhost:81 my pimatic

bertreb commented 4 years ago

Ok, looks good. What is the log saying?

heiko1988 commented 4 years ago

the pimatic log say nothing

bertreb commented 4 years ago

but there should be information in the deamon.log file on what happened at the startup of Pimatic.

heiko1988 commented 4 years ago

startup pimatic:

12:26:38.265 [pimatic] info: Loading plugin: "pimatic-home-connect" (0.0.2)

when search device:

12:28:42.556 [pimatic] info: pimatic-home-connect: Searching for new devices 12:28:42.557 [pimatic-home-connect] info: Home-connect offline

tis is the only from home-connect, and no errors from other in the log

heiko1988 commented 4 years ago

the login promp not comming

bertreb commented 4 years ago

can you check in the home-connect-js directory and then the node_modules if fs is installed?

bertreb commented 4 years ago

if not then install fs. Go to home-connect-js and execute command npm install fs

bertreb commented 4 years ago

These are normally all automatic installs, but in this manual installation and lot of manual patches need to be done. The fs module is probably missing.

heiko1988 commented 4 years ago

yes that was missing, I installed it with npm i fs and rebooted the vnc session. unfortunately no popup to log in

bertreb commented 4 years ago

Please restart pimatic

heiko1988 commented 4 years ago

unfortunately does not work. I also installed the EventSource.

unfortunately it still doesn't work.

how do you do the restart via console or in plugin and then restart?

bertreb commented 4 years ago

You can use ssh in a terminal on your laptop or in the vnc window open a terminal. The commands are the same sudo service pimatic restart. You can also restart pimatic via the gui (plugin page)