ITEAD Sonoff TH10/16 without firmware flash

This guy [Ipsum Domus] seems to have a way of fooling the Sonoff devices without flashing the firmware. He has some JSON code. Someone who’s an expert in bindings might be able to produce one based on this?

Hyperlink didn’t work! https://blog.ipsumdomus.com/sonoff-switch-complete-hack-without-firmware-upgrade-1b2d6632c01

2 Likes

The hack isn’t working anymore as Sonoff impemented a certificate check, but I found another way, by simply leveraging the ewelink API.

  1. Connect your TH10 as usual with the Ewelink app.

  2. Do an npm install for this repository https://github.com/skydiver/ewelink-api (it’s probably also possible to write a binding, but my node-skills are a lot better than my knowledge of creating binding, therefore I used this workaround).

  3. Create a very small index.js file to access the ewelink-api package:

    (async function() {
    const ewelink = require(‘ewelink-api’);

    /* instantiate class */
    const connection = new ewelink({
    email: ‘username’,
    password: ‘password’,
    region: ‘eu’
    });

    /* get all devices */
    const devices = await connection.getDevices();
    console.log(devices[0].params.currentTemperature);
    })()

  4. Now I used the exec binding to execute this script:

    node ./scripts/watertemperature/index.js

  5. Finally convert the output into a Number:Temperature item:

    rule “Pooltemperature”
    when
    Item Pooltemperatur changed
    then
    Pooltemperature.sendCommand(new Float(Pooltemperatur.state.toString))
    end

Hope this helps someone

2 Likes

Hi airbone42.
Thanks for your article. I like that much better to avoid flashing the firmware. Currently the devices are working using the iOS app. So I always have a test possibility.

During my daily work I’m developing Apps for process implementations using node ( typescript / Angular 9 ). --> so frontend.
I like the structured approach etc. But I never built a sever application with node or Angular. I know there is a solution ‘express’ and it runs for me, but only for baby steps.

My openHab runs on Ubuntu Linux on a nice and cheep Lenovo - AMD laptop. Works very well.

? How do you test your scripts for Sonoff? Can you debug them ?
? Where do you get the credentials for the new ewelik connection ?
? Then I assume you need to place this script only inside the script directory ?
? Do you have or know other scripts / examples ?

Thanks

For all users who want to build their own node.js app based on Typescript here my small implementation.
const ewelink = require(‘ewelink-api’);

main();

class SonoffDevice {
  status: string;
  state: String;
  channel: '1' 
}

// password and email are defined during setup of the devices
function main () {
const connection = new ewelink({
email: “your email address”,
password: " your own password",
region: “eu”
});

  async function SetChannel ( channel: string, command: string ) {
    // const devices = await connection.getDevices();
    const chanelStatus = await connection.getDevicePowerState('1000caed61', channel );
    const Channel: SonoffDevice = chanelStatus; 
    console.log (Channel);
    if (Channel.status === 'ok' && Channel.state === command) {
      console.log ( `Channel 1 ist bereits gesetzt wie vorgegeben auf ${command}`) 
    } else {
      const statusToggle = await connection.toggleDevice('1000caed61', channel);
      console.log ( 'Channel 1 geschalten') 
    }
  }

  if ( !process.argv[2] ) { 
    console.error( 'kein Channel Parameter angegeben !')
    } else {
      if ( !process.argv[3] ) {
        console.error( 'kein Command Parameter !')
        } else {
        SetChannel( process.argv[2], process.argv[3]);
      }
  }
  
}