Usually you would structure this like so:
- first, both the sensor and the thermostat have to be networked devices known to SmartThings. (A “device” could also be a web service.)
Each has their own individual device handler.
you write a smartapp (not a device handler) that subscribes to changes in temperature from the sensor device.
when that smart app is triggered by the change in temperature on the sensor device, it sends a display value to the thermostat.
Provided the physical thermostat device will accept an appropriate command to display that value, it will work.
You can think of this as being similar to the situation where you use a motion sensor to turn on a light.
Both the motion sensor and the light have their own device handler, and both are known to SmartThings.
A smart app subscribes to the events of the motion sensor, and then sends the turn on command to the light.
In some of your previous code, you have been trying to combine the two devices into one device handler, and it won’t work that way.
Logically, smartthings is having two conversations: One with the sensor, and one with the thermostat. It’s the smart app that is talking to both, taking information in from the sensor through an event subscription and sending information out to the thermostat.
- Alternatively, you could have the smart app poll the sensor for the temperature periodically, and then use the same set command to update the thermostat. But you would still have two separate device handlers.
Two devices, two device handlers, and one smart app talking to both devices.
(Of course, all of this assumes that the physical thermostat has been manufactured to accept an update command that will change the displayed value on the thermostat, not all thermostats will do this.)