cflurin / homebridge-mqtt

Homebridge-mqtt is a Plugin for Homebridge.
Apache License 2.0
229 stars 38 forks source link

How can I add rotationspeed characteristic to a thermostat service? #26

Closed uronito closed 7 years ago

uronito commented 7 years ago

How can I add rotationspeed characteristic to a thermostat service?

Thanks!!!!!

cflurin commented 7 years ago

You can only define/add the optional characteristics to a thermostat:

/**
 * Service "Thermostat"
 */

Service.Thermostat = function(displayName, subtype) {
  Service.call(this, displayName, '0000004A-0000-1000-8000-0026BB765291', subtype);

  // Required Characteristics
  this.addCharacteristic(Characteristic.CurrentHeatingCoolingState);
  this.addCharacteristic(Characteristic.TargetHeatingCoolingState);
  this.addCharacteristic(Characteristic.CurrentTemperature);
  this.addCharacteristic(Characteristic.TargetTemperature);
  this.addCharacteristic(Characteristic.TemperatureDisplayUnits);

  // Optional Characteristics
  this.addOptionalCharacteristic(Characteristic.CurrentRelativeHumidity);
  this.addOptionalCharacteristic(Characteristic.TargetRelativeHumidity);
  this.addOptionalCharacteristic(Characteristic.CoolingThresholdTemperature);
  this.addOptionalCharacteristic(Characteristic.HeatingThresholdTemperature);
  this.addOptionalCharacteristic(Characteristic.Name);
};

and add a service (using v0.3.0) defined in:

https://github.com/KhaosT/HAP-NodeJS/blob/master/lib/gen/HomeKitTypes.js

Please have a look at README.

uronito commented 7 years ago

I try version 0.3.0 and i can add fan service.

But can i add characteristics of this service?

Thanks!!!!

Regards

cflurin commented 7 years ago

try this:

1) remove your Thermostat.

topic: homebridge/to/remove
payload: {"name":"my_thermostat"}

2) add the Thermostat again:

topic: homebridge/to/add
payload: 
{
    "name":"my_thermostat",
    "service_name":"my_temperature",
    "service":"Thermostat"
}

3) add the Fan service (including the optional characteristics):

topic: homebridge/to/add/service
payload:
{
    "name":"my_thermostat",
    "service_name":"my_rotationspeed",
    "service":"Fan",
    "RotationSpeed":"default"
}
cflurin commented 7 years ago

Please download the latest version:

sudo npm install -g cflurin/homebridge-mqtt
alesoblak commented 7 years ago

hi, Im trying to get it work with my mqtt light switch and I managed to make it work with plugin homebridge-mqttswitch where I can configure simple switch in config.json file,... but it seems that I dont get it how to add devices with this plugin,... is there any documentation with explenation how I add device? I know i need to type topic: "something" and payload:"something", but I just cant figure it out how or where to do this? Can someone help? Thanks :)

cflurin commented 7 years ago

Take a look at README:

1) install homebridge-mqtt 2) define config.json 3) run homebridge 4) add an accessory (in your client, e.g. node-red):

topic: homebridge/to/add
payload: {"name": "flex_lamp", "service_name": "light", "service": "Switch"}

5) set a value (in your client, e.g. node-red):

topic: homebridge/to/set
payload: {"name": "flex_lamp", "service_name": "light", "characteristic": "On", "value": true}

Also have a look at the Wiki.

alesoblak commented 7 years ago

Hi, thanks for help. I was trying to add devices with mosquitto_pub.... and after trying to make it work i finally found out that in wiki there is a typo in code where adding device with mosquitto_pub. All the time I was using copy-paste. I am new in all this mqtt, homebridge etc.. so this take me a few million of tries :)

https://github.com/cflurin/homebridge-mqtt/wiki/homebridge2ESP8266

typo: m**u**squitto_pub -h 127.0.0.1 -t homebridge/to/add -m '{"name":"esp_temp","service":"TemperatureSensor"}'

cflurin commented 7 years ago

Okay fixed! But that isn't too hard to find out, just read the error message :-)

musquitto_pub
bash: musquitto_pub: command not found
alesoblak commented 7 years ago

yes I know no but like I said I am just starting to get to know with all this stuff,.. so it took me a while because I didnt even know that there is somewhere a log from where I can read what is going on :)

cflurin commented 7 years ago

No problems just ask. If appropriate, open a new issue. There are several users willing to help.