Maybe this is a stupid question but I'm writing my first driver so bear with me... It supports to show the outdoor temperature. I'm wondering how I could set this up. Do I need to get the outdoor temperature information from another driver (such as the Open Weather Map)? Is this even supported? What would be the best thing to do in my case? Any examples on how to do it?
If you are connecting to a cloud hosted api and it can provide the weather information, you're driver can support more than one capability, including the one for temperature recording (I'd need to look it up or find the link to the capabilities for you). Does that make sense?
I recently contributed a code change to this one that you might want to consider. The Hubitat Thermostat is only set up for one temperature -- i.e., the indoor Thermostat temperature. One thought you might want to borrow from this is to set up the outside thermostat as a child device using the "Generic Component Temperature Sensor" driver. The code for this is shown at lines 754-762 of the TCC driver which I've paste below
Using a separate child device for the Outdoor temperature sensor let's you use it as a separate device in rule machine so it can be used to trigger rules or as a condition in a rule just like any other temperature sensor.
The code below gets called with your new temperature value. If the child device doesn't exist, it gets created (usually this should happen on initialization).
void setOutdoorTemperature(value){
def cd = getChildDevice("${device.id}-Temperature Sensor")
if (!cd)
{
cd = addChildDevice("hubitat", "Generic Component Temperature Sensor", "${device.id}-Temperature Sensor", [name: "Outdoor Temperature", isComponent: true])
}
String unit = "°${location.temperatureScale}"
cd.parse([[name:"temperature", value:value, descriptionText:"${cd.displayName} is ${value}${unit}.", unit: unit]])
}
I don't know if I undestood correctly but it seems the outdoor temperature is coming from a the honellwell website itself. In my case I don't have this information from the manufacturer of my thermostat. This information would need to come from another source but I don't know yet what are my options.
For the functionality that I have now, everything is local. I'm able to send/receive information from/to the thermostat hub and the hub send the information to the thermostat (through a not public API). If you are able to find an example to what you meant, please let me know
I was wrong about one or two things, but it still may be useful to expand on what I said earlier....
I suspect thermostats are included in any listings for devices that measure temperature, such as when creating rules, etc. They would probably clash anyway, I think they have the same temperature attribute. I thought I had included this temperature capability myself for my Mitsubishi MelCloud driver, but I only have thermostat and refresh:
But the educational benefit is still there in understanding what is possible. My own understanding is that by nominating the capability like this you essentially have to adhere to the definition of that capability, including the attributes and developing the methods required. Here's a link to the Thermostat capability documentation as an example.
The process is essentially the same if you include one capability or many capabilities, you just have to make sure you cover each of the attributes and methods listed in the definition of each capability in your driver.
In terms of your situation there are a couple of other points I would make:
Given you plan to source the outside temperature and/or other weather information from a separate weather site / app, then I think it would make more sense to develop a driver which is separate to your thermostat driver you are currently developing, or find an existing driver if one has already been developed. This way the code for the weather readings is able to be used by others, not just those with the same thermostat. Also, by looking outside the offering from you thermostat manufacturer, you can choose whatever weather source you want, as long as it can be integrated in some way with HE. You may also want to look at a personal weather station at some point to give your more personalised readings for your home. There are a couple I have seen on the forum, but I personally own a EcoWitt PWS which has a set of drivers available here on the Community.
Thanks a lot for taking the time to write your reply Let's say I use the OpenWeatherMap driver as it exposes the variable "temperature" . How can I access that from inside my driver?