Great! Homebridge works very stable and reliable now,
and the graphical UI for controlling the server is also very handy!
Thanks @makerken and @Moors7 for your fantastic guidance. I could not have done it without this great community...
Switching lights ON and OFF with Siri has no secrets for me anymore.
But now I'm trying to explore the communication possibilities in the other direction:
Reading sensors ...
From the sample "config.json" file, I kept this "device":
{
"accessory": "ParticleTemperature",
"name": "Room Temperature",
"deviceid": "222042000b47348882313031999",
"type": "SENSOR",
"sensorType": "temperature",
"key": "temperature",
"event_name": "tvalue"
}
And I read @krvarma 's explanation:
The devices array contains all the accessories. You can see the accessory object defines following string objects:
accessory - Accessory name, this is the name of the accessory.
name - Display name, this is the name to be displayed on the HomeKit app.
deviceid - Device ID of the Particle Device (Core, Photon or Electron). It is defined in accessory so that you can use different Particle Devices for different accessory.
type - Type of the accessoy. As of now, the plugin supports 2 type, LIGHT and SENSOR. Type LIGHT represents a light, such as bedroom light, kitchen light, living room light, etc… Type SENSOR represents sensor accessory such as Temperature sensor, Humidity sensor, Light sensor, etc…
sensorType - Optional Sensor Type, this string object is optional. This is only valid when the accessory type is SENSOR. As of now the plugin supports 3 types of sensors, Temperature Sensor, Humidity Sensor and Light Sensor. More sensor will be supports in future versions.
function_name - name of the Particle Function declared in the firmware. This function will be called when the light is turned on/off with the arguments as per the args property.
args - defines the argument to be passed to the Particle Function defined by the function_name. Whatever is declared here will be passed to the Particle Function. You can define a special token {STATE} in the argument. This token will be replaced by 1 or 0 depending on whether user turns on or off the light. In this example the Particle Function is named as “onoff” and the argument is defined as 0={STATE} . So when the user turns on the light by saying “Hey Siri, turn on bedroom light”, the Particle plugin will call the function onoff with argument 0=1. In case the user turns off the light by saying Hey Siri, turn off bedroom light, the onoff function will be called with argument 0=0. A sample firmware to test this config is given above.
event_name - The name of the event to listen for sensor value update. This is only valid if the accessory type is SENSOR. If the accessory is a type of SENSOR, then the plugin listens for events published from Particle Device (using Particle.publish). The device firmware should publish the sensor values in the format key=value. The key identifies the sensor value. For a temperature sensor the key should be temperature. For a humidity sensor the key should be humidity. For light sensor it should be light.
key - Name of the key, this is not used in this version of the plugin. This is included for future purpose.
Based on this, I tried various combinations of Particle.publish commands, such as:
Particle.publish("tvalue", "key=37",60,PRIVATE);
But the value shown in the Apple HOME App does not change: It shows 20° continuously...
Any experience with this somebody?
Edit: Applying the bold text above, I found the correct syntax for the event to publish:
Particle.publish("tvalue", "temperature=37",60,PRIVATE);
All works now! Thanks @krvarma