G-Homa plugs controlable in Homeassistant [ hacky approach]

My Father in law is using this G-Homa WiFi Plugs and proposed to me that I schould integrate them in HomeAssistant… HA… fml - Luckaly there is tig-robertgrundeken wich made himself a php script!
Took me several hours to get it working - But it finaly did.

to get the credentials you have to setup an older version on the g-homa app wich dont use https - that you can intercept the hashed password, and device ID (I used 2.2.4)

then we use the directions from the repo

as soon you finaly found the device ID and the hashed Password you just change this curl command wich I put into secrets

FUserAccount, FPassword, and FActionNo are the things to change.

secrets.yaml

curl_ghoma_plug1_on: curl -X POST -H 'Content-Type:text/xml' --data '<?xml version="1.0" encoding="UTF-8"?><v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><service xmlns="http://www.thinkhome.com.cn/" id="o0" c:root="1"><json i:type="d:string">{"head":{"code":"120"},"body":{"authentication":{"FUserAccount":"[email protected]","FPassword":"PASSWORDHASH"},"action":{"FActionType":"5","FActionNo":"XXXXXXXX-xxxx-xxxx-xxxx-XXXXXXXXXXXX","FKeyNum":"0","FAction":"1","FValue":""}}}</json></service></v:Body></v:Envelope>' http://m.g-homa.com/wsi/action/ActionWebService.asmx
curl_ghoma_plug1_off: curl -X POST -H 'Content-Type:text/xml' --data '<?xml version="1.0" encoding="UTF-8"?><v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"><v:Header /><v:Body><service xmlns="http://www.thinkhome.com.cn/" id="o0" c:root="1"><json i:type="d:string">{"head":{"code":"120"},"body":{"authentication":{"FUserAccount":"[email protected]","FPassword":"PASSWORDHASH"},"action":{"FActionType":"5","FActionNo":"XXXXXXXX-xxxx-xxxx-xxxx-XXXXXXXXXXXX","FKeyNum":"0","FAction":"0","FValue":""}}}</json></service></v:Body></v:Envelope>' http://m.g-homa.com/wsi/action/ActionWebService.asmx

switch:
  platform: command_line
  switches:
    plug1:
      command_on: !secret curl_ghoma_plug1_on
      command_off: !secret curl_ghoma_plug1_off  

Next thing i meight try to get the https endpoint
And here - my Feature Request you could vote on when you also have one of these plugs

Hello, I have got half of this to work but i cannot get the off part to work. Do you have any ideas that world help

maybe you have the same payload?
The FAction 0/1 is either off/on - I checked the function by simply running the curl command in the shell.

The FAaction is set to 1 and 0 in the diffrents commands but when i check the app the devices is still one

The app need a push to “sync”. I just closed it and reopend the app to get the right power status. When you check charles you see another server or request for the status - Was after the hours of friggeling to tired to check the payload for the command_state, and to tired to tinkering bout it.
Do it like me - take one of the switches to your side and listen for the click

I have tryied to update the app and still the same problem. I am also wondering what FActionNo":"XXXXXXXX-BBFD-4467-9D3E-XXXXXXXXXXXX the none xxx part is ment for.

The FActionNo is the indentifyer of the plug.
I’cant just past the credentials and indentifyers into here so I replaced the text there with X.
the older version of the app is needed for getting these infos.
FUserAccount, FPassword, and FActionNo are the things to change.
soo… Turning on your plugs is working - turning off not?

Correct i can not turn off my plugs. But I was wondering about the numbers you put in between the xxxxs

“fixed” but I’m soon out of ideas to help you…
Copy the working on command again and cange the 1 from FAction to a 0.

I have tryied the curl commands in a normal linux terminal and there both of them work but whem I am using them in the way you descirbe I only get the on part to work

New year and everything over now.
The command_line platform is just doing this.
Putting the command into secrests ist just for a tiny bit of security. you could write the command just into the switch itself - my guess is that there is an extra space or something else what yaml dont like.

Unfortunately it seems, that this g-homa hack is not working anymore.

  1. G-homa denied the old HTTP connections, so now the old versions of g-homa app is useless for gathering passwordhash and deviceID (all requests including the login are rejected by “connection expired” message), so now you have to capture and decrypt HTTPS requests, what is much more difficult - I had to root my bluestack and install root certificate of my Fiddler HTTP proxy to do this.

  2. Also for HTTPS connection, there’s completely another “protocol” used, so the CURL scripts are not working anymore. The old one sends data by POST in XML structure, but the new one uses JSON, and also credentials are sent in one hash (accessToken) only. Now I’m not sure, if this token is constant, or it’s calculated everytime in some previous HTTPS handshake from username and passwordhash.

I’m not expert for building curl messages, so maybe someone of you can help me to do it, there’re the captured JSONs for switching ON and OFF:

For switching ON:

{"body":{"accessToken":"th.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-xxxxxxxx-xxxx-xxxx-xxxx-XXXXXXXXXXXX","command":{"deviceNo":"XXXXXXXX-xxxx-xxxx-xxxx-XXXXXXXXXXXX","action":"1","key":"0","value":"1"}},"system":{"ver":"1.0.0","sign":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","appKey":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","time":"1610475146","clientSys":"android-7.1.1","appVer":"3.0.24","clientModel":"OnePlus ONEPLUS A5000"}}

For switching OFF:

{"body":{"accessToken":"th.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-xxxxxxxx-xxxx-xxxx-xxxx-XXXXXXXXXXXX","command":{"deviceNo":"XXXXXXXX-xxxx-xxxx-xxxx-XXXXXXXXXXXX","action":"0","key":"0","value":"0"}},"system":{"ver":"1.0.0","sign":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","appKey":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","time":"1610475146","clientSys":"android-7.1.1","appVer":"3.0.24","clientModel":"OnePlus ONEPLUS A5000"}}

These messages are sent to https://rc.g-homa.com

Definitelly my environment for capturing is set up now, so I’m able to capture more, if needed.

I also wrote it down as a new issue to the original GIT source to tig-robertgrundeken

Feel free to DM me on discord or some other chat tool then we can try figure it out.

Hello,

i found my ghoma plug yesterday. I would like to integrate it in hassio aswell.
If you find a solution for https connection i appreciate if you can share a little workaround.

Thanks