Comments (17)
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.
Also, did you have to modify requests.json
at all @TarxBoy?
from tuyapi.
No modification of requests.json was required.
from tuyapi.
Huh, interesting.
from tuyapi.
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.
I would suggest you make a custom Homebridge plugin for your heater. The gist of the process:
- Call
.get({schema: true})
to find the DIP index of each property you want to use. - Look at the source code of
homebridge-tuya-outlet
and base your plugin off that. - 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.
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.
@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.
@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.
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.
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.
@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.
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.
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.
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.
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.
Closing this because of inactivity.
from tuyapi.
Related Issues (20)
- Error: GET_TOKEN_FAILED 1114, your ip(xxx.xxx.xxx.xxx) don't have access to this API HOT 1
- Some of my localtuya devices periodically become unavailable HOT 2
- App show "no access". I turn on all permissions when creating new Cloud Project. And I cheched my region. All right. HOT 1
- Implement 3.5 protocol
- Setting brightness overrides color / set multiple properties only applies last HOT 2
- Weird encrypted response from tuya bulb ? HOT 6
- Philips Avent Baby Monitor uses Tuya HOT 3
- Virtual device timed out HOT 1
- Tuya IOT Platform error 1106: permission deny HOT 1
- Cannot install with "npm install codetheweb/tuyapi" HOT 1
- device.get() never returns HOT 9
- Not being able to connect using device.connect() HOT 7
- tuya-cli get does not work, ECONNRESET error. HOT 1
- 302 status on my TuyaPlatform plugin HOT 1
- `dp-refresh` fire for all devices of the gateway instead of the only one concerned HOT 1
- is there a breaking change at tuya ? HOT 6
- Use Insecure Algorithm AES-ECB as Default Encryption Method HOT 1
- npm install codetheweb/tuyapi Infinite loading occurs during installation.
- virtual ID HOT 1
- Just lost all my Local Tuya devices HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tuyapi.