GithubHelp home page GithubHelp logo

Comments (17)

codetheweb avatar codetheweb commented on May 23, 2024

This is great, thanks for your work.
The option to change multiple DPS indexes at once is a good idea, I'll try to include that in the next release.

See this comment for details, but eventually when TuyAPI gets split up I'd love it if you published a package for controlling heaters using TuyAPI as a dependency. The more device-specific community packages the better.

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

Also, did you have to modify requests.json at all @TarxBoy?

from tuyapi.

GabesSmith avatar GabesSmith commented on May 23, 2024

No modification of requests.json was required.

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

Huh, interesting.

from tuyapi.

deiphid avatar deiphid commented on May 23, 2024

I have managed to get one of these heaters working on Homebridge by essentially adding it as a power outlet using the homebridge-tuya-outlet plugin. Now I can turn it on and off through my home app, or ask Siri to turn it on and off.

Any suggestions on how I might add other functionality?

For me, the most used functions would be turning the heater on and off (done), turning the LED on and off, and checking the room temperature. It would be great to do this all in one HomeKit "device", but would be equally useful to have three separate devices: heater (fan), led (light) and temperature (sensor).

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

I would suggest you make a custom Homebridge plugin for your heater. The gist of the process:

  1. Call .get({schema: true}) to find the DIP index of each property you want to use.
  2. Look at the source code of homebridge-tuya-outlet and base your plugin off that.
  3. For each property (fan, light, temperature)( you want to be controllable/readable, you'll have to create a separate class and publish that class as an accessory. For example, here's a snippet for temperature:
// -- Common to all accessories:
module.exports = function(homebridge) {
  Service = homebridge.hap.Service;
  Characteristic = homebridge.hap.Characteristic;
  //...
  // params: plugin name, accessory name, accessory constructor
  // call .registerAccessory for each parameter you want to control
  homebridge.registerAccessory("homebridge-tuya-heater", "TuyaHeaterTemperature", TuyaHeaterTemperature);
  //...
}

// -- End common code

//...

function TuyaHeaterTemperature(log, config) {
  // create a tuya instance

  // ...

  this._service = new Service.TemperatureSensor(this.name);
  this._service.getCharacteristic(Characteristic.CurrentTemperature).on('get', this._get.bind(this));
}

TuyaHeaterTemperature.prototype._get = function(callback) {
  debug("Getting temperature...");
  this.tuya.get({schema: true}).then(data => {
    debug("Data", data); // <- figure out the right DIP
    return callback(null, data.dip.2);
  }).catch(error => {
    callback(error, null);
  });
}
  

Find supported characteristics and services here.

Hopefully you can figure it out from there.

from tuyapi.

deiphid avatar deiphid commented on May 23, 2024

Awesome, thanks! I am going to have a play with this over the next few weeks. If I’m successful I’ll share it.

from tuyapi.

charlietomo avatar charlietomo commented on May 23, 2024

@TarxBoy thanks for this it looks interesting. Are you happy share a complete (without keys etc) file that can be used to control the heater?

I have got my uuid, productID and localKey however am having trouble doing any basic control. I'm trying to get the minimum amount to turn heater on/off to start with but the following does not work (running as node filename.js).

I get the error UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error communicating with device. Make sure nothing else is trying to control it or connected to it.

Any ideas?

const TuyaDevice = require('tuyapi');

let tuya = new TuyaDevice({
  id: 'uuid',
  key: 'key'});

tuya.set({dpscommand:'{"1":false}'}).then(() => console.log('heater was turned off')); 

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

@charlietomo please see the docs on set() here. Your set command should look like this:

tuya.set({dps: 1, set: false}).then(() => console.log('heater was turned off')); 

from tuyapi.

charlietomo avatar charlietomo commented on May 23, 2024

Thanks. It was the rest of the code I was struggling with but got it to work. Full code:

const TuyaDevice = require('tuyapi');

let tuya = new TuyaDevice({
  id: '[id]',
  key: '[key]'});

tuya.resolveId().then(() => {  
  tuya.set({dps: 1, set: false}).then(status => {
    console.log('Status:', status);

        return;
  });
});

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

Glad to hear you got it working @charlietomo. I realize now that your issue was that you didn't pass in an IP or call resolveId(), so tuyapi was trying to connect to an undefined IP address.

I've added a check which throws an error if the IP is missing.

from tuyapi.

charlietomo avatar charlietomo commented on May 23, 2024

@codetheweb that check sounds useful. You are right, it was the missing IP / resolveID which was the main issue, but not apparent to me.

@deiphid I am also interested in a home bridge plugin so please update this thread if you make progress. I am actually more interested in a Home Assistant plugin, and then would expose it to homebridge (and iOS Home) that way.

from tuyapi.

nicole-ashley avatar nicole-ashley commented on May 23, 2024

While not strictly related to this repo, I've developed an initial Home Assistant integration (made possible by the awesome research done in this thread). It needs specs and a few more features (eg, adding extra sensors and supporting power levels) but it's working well as a climate device and is robust enough for automation.

https://github.com/nikrolls/homeassistant-goldair-heater

// @charlietomo who specifically mentioned HA

from tuyapi.

charlietomo avatar charlietomo commented on May 23, 2024

Amazing @nikrolls that looks great. Will test it on my heaters / HA setup. Thanks in advance for the work you put into this.

from tuyapi.

deiphid avatar deiphid commented on May 23, 2024

I have found that the homebridge-igenix-air-conditioner plugin works for these heaters. The plugin provides on/off, current temp, and target temp functionality. I am going to see if I can figure out a way to add control of the led screen, and maybe tailor the plugin towards a heater rather than an air conditioner.

from tuyapi.

nicole-ashley avatar nicole-ashley commented on May 23, 2024

Just another heads-up: for those using Home Assistant, my integration now also supports the LED light, child lock, a standalone temperature sensor, and manual power levels. Now I'm working on official integration into the core so it can work on hass.io and HassOS.

from tuyapi.

codetheweb avatar codetheweb commented on May 23, 2024

Closing this because of inactivity.

from tuyapi.

Related Issues (20)

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.