Few questions from newbie ;)

Hm strange ... About 3h ago I have created routines in Alexa based on virtual switch to turn on or off heaters ,so... I'm confused :blush:
I have even tied several times for testing and it work.
Maybe we do not understand each other...

Are you using an official Hubitat Virtual Switch driver? If not, what Virtual Switch driver are you using?

You created a routine where you speak and get an output (your virtual switches).
What @ogiewon is referring to is input. Your motion or contact sensor triggers, and this kicks off the routine, instead of speaking to activate the routine.

You can do this via a Rule Machine rule too, by using some simple groovy code.

I assume official , create virtual switch button , on the right top button

Yes , exactly. Smarthomeprimer

Is the thermostat you want to control already in Hubitat? If so, I apologize for any confusion. I was assuming the thermostat was integrated in Alexa, and you were trying to control it via Hubitat.

Sounds like the thermostat is in Hubitat, and you'd like to use voice commands to control the thermostat via Alexa. Is this correct?

Yes, exactly. :blush: Now I have simple control just to turn heaters on or off . I'm dreaming about controling temperature using , Alexa set heaters 19 deegres :blush:
When 19 can be changed whatever I want

I think I understand what the problem is, having done something similar myself.

You want a software version of a "three position retractive switch" where the switch has three positions - ON (push to top), OFF (push to bottom) and NOTHING (middle, resting position).

So in Alexa he can go "Heat UP" and the switch will go ON, then revert to NOTHING (middle). Or "Heat DOWN" and the switch will go OFF, then revert to NOTHING (middle) again.

Then in HE he has one device that he can use as a trigger to increment / decrement the temperature each time it is triggered.

As ever though there's a load of different ways to achieve the end result .... rules, multiple virtual devices, etc.

But I think it's a reasonable request .... after all a "virtual" device is a virtual of a real device .... and a 3 state switch does exist :slight_smile:

1 Like

Yes , exactly martyn

I would still just do it with 2 virtual switches, but :man_shrugging:

Anyway. That shouldn't be hard to do. If someone else doesn't crank it out before I get to it, I'll try to make a stab at it this weekend. Sounds simple (which means it probably is not :smile: ).

I don't use Alexa though, so wouldn't be able to fully test the device on my end.

Yes and pray that Alexa will discover such combo :grin:

SPDT on-off-on

Single-Pole Double-Throw but the center position is off, not nothing, because the switch reports the controlled device's current state.

One problem with this idea, however, is that the Alexa Skill would also need to support a tri-state switch. To the best of my knowledge, Alexa only supports a two-state switch, with optional Dimmer functionality.

So, why not use a virtual dimmer switch? You can use the dimmer levels of 0 to 100 as temperature setpoints. Then, in Hubitat, use RM to adjust the thermostat.

You could also use a Virtual Dimmer as a three-state switch. Use values of 1, 50, and 100. 1 = On, 100 = Off, and 50 as your unknown state. Just have Hubitat always return the value to 50 after Alexa sets it to 1 or 100.

Just another idea... :wink:

1 Like

I thought about it but I don't know how to set up rule machine that dimmer will lead temperature to thermostat and another way for thermostat to dimmer

You can use a trigger of "Virtual Setpoint Dimmer level changed," then in your actions, you can set the temperature of the thermostat to the value of the Virtual Setpoint dimmer's "level" attribute. I did this with a custom app back before Rule Machine had the ability to use device attributes as values for assignment (not sure if I still have that app, but if I do, that's another possibility). I do think it's possible now, however.

I think the three-state switch is a bad idea. Hubitat's official Switch capbility only allows the "switch" attribute to have a value of "on" or "off," so if you add non-standard states to that , you risk breaking its use with other things that only depend on it having one of two correct attributes (e.g., Dasbhoard). You could certainly do it, but I don't think it's the best way to fix this problem. The best way would be if Hubitat added thermostat support to the Alexa skill, but since it doesn't, a dimmer you can control with Alexa is probably the next-best (tied with using SmartThings and integrating the thermostat there via HubConnect, which is what I'm still doing, but I assume that's not an option for you).

1 Like

Could You please tell me what kind of rule I need to set up for this dimmer ? I can figure it out :confused:

OK, I just tried and I was wrong: apparently setting thermostats to a setpoint based on another device attribute (or variable or anything other than direct input) was not added. :slight_smile:

However, a small custom app like this might work. This will "sync" the dimmer level of a virtual switch to the selected thermostat and also "sync" the setpoint of that thermostat back to the switch (you might not really need that part but could use it if you wanted to display this somewhere like on a Dashboard):

/**
 *  Thermosat/Dimmer Sync Helper
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
 
definition(
name: "Thermostat/Dimmer Sync Helper",
namespace: "RMoRobert",
author: "RMoRboert",
description: "Syncs the setpoint of a thermostat and the dimmer level of a virtual dimmer (bidirectional), intended for using the virtual devices with other platforms (e.g., Alexa) that do not natively support thermostat integration",
category: "Convenience",
iconUrl: "",
iconX2Url: """,
iconX3Url: ""
)

preferences {
    mainPage()
}

def mainPage() {
    page(name:"mainPage", title:"Settings", install: true, uninstall: true) {
        section("Choose thermostat and virtual dimmers to sync with") {
            input (name:"thermostat", type: "capability.thermostat", title: "Thermostat", required: true, multiple: false)
            input (name:"setpointDimmer", type: "capability.switchLevel", title: "Setpoint dimmer", required: true, multiple: false)
        }
        section("Help", hideable: true, hidden: true) {
            paragraph('Above, choose the "real" thermostat whose setpoint will be bidirectionally syncled with the "setpoint dimmer" of your chooising (i.e., changing one will also change the other). The current reported temperature of the thermostat will also be synced to the "temperature dimmer" (one-way only, as for real thermostats this is the only direction that makes sense).')
            paragraph("This app is intended to help you use thermostats on Hubitat with other platforms that do not integrate well or at all with Hubitat thermostats--for example, you can use the setpoint dimmer with the Alexa skill or app to change the setpoint, not currently supported on Hubitat's Alexa integrations. You can also use both of the virtual switches with the community Other Hub app to sync with Smart Things, then use a custom SmartApp to sync the dimmers with a simulated thermostat and use SmartThings' Alexa integration to set and query these thermosat properties.")
        }
        section("Logging", hideable: true, hidden: true) {
            input ("debugLogging", "bool", title: "Enable verbose/debug logging")
        }
    }
}

def installed() {
    initialize()
}

def updated() {
    unsubscribe()
    unschedule()
    initialize()
}

def initialize() {
    log.debug "Initializing"
    subscribe(thermostat, "thermostatSetpoint", realSetpointHandler)
    subscribe(setpointDimmer, "level", virtualSetpointHandler)
}

def realSetpointHandler(evt) {
    if (debugLogging) log.debug("Thermostat setpoint changed...")
    def newSetpoint = thermostat.currentValue("thermostatSetpoint") 
    def currLevel = setpointDimmer.currentLevel
    if (currLevel > newSetpoint - 0.5 && currLevel < newSetpoint + 0.5) {
        log.debug "Virtual dimmer not changed because setpoint of ${newSetpoint} is already close to virtual dimmer level of ${currLevel}"
    }
    else {
        setpointDimmer.setLevel(newSetpoint)
        log.debug "Changed virtual setpoint dimmer level to ${newSetpoint} because thermostat setpoint changed"
    }
    if (debugLogging) log.debug("...done handling thermostat setpoint change.")
}


def virtualSetpointHandler(evt) {
    if (debugLogging) log.debug("Virtual setpoint dimmer level changed...")
    def targetSetpoint = setpointDimmer.currentLevel
    def currSetpoint = thermostat.currentValue("thermostatSetpoint") 
    def thermostatMode = thermostat.currentValue("thermostatMode")   
    if (debugLogging) log.debug("Target setpoint = ${targetSetpoint}; current setpoint = ${currSetpoint}; thermostat mode = ${thermostatMode}")
    if (currSetpoint > targetSetpoint - 0.4 && currSetpoint < targetSetpoint + 0.4) {
        log.debug "Thermostat not changed because setpoint of ${currSetpoint} is already close to virtual dimmer target of ${targetSetpoint}"
    }
    else {
        if (thermostatMode == "cool") {
            thermostat.setCoolingSetpoint(targetSetpoint)
               log.debug "Set thermostat cooling setpoint to ${targetSetpoint} because virtual dimmer changed"
        }
        else if (thermostatMode == "heat") {
            thermostat.setHeatingSetpoint(targetSetpoint)
               log.debug "Set thermostat heating setpoint to ${targetSetpoint} because virtual dimmer changed"
        }
        else {
            log.debug "Thermostat not adjusted because not in heat or cool mode (mode = ${thermostatMode})"
        }
    }
    if (debugLogging) log.debug("...done handling virtual setpoint dimmer change.")
}

Haven't tested it much, so no guarantees, but it's similar to something I used to use that I mentioned above. :slight_smile:

Alternatively, if you just want to turn the thermostat setpoint up or down but don't care about specifying an exact value, perhaps two virtual switches, "Virtual Thermostat Up" and "Virtual Thermostat Down", or whatever you want to call them, would work. Set them to turn off after a few seconds, then every time you ask Alexa to turn them off or on, they could increase or decrease the setpoint by 1 degree or whatever. No custom code needed, just lots of awkwardness like we need in any case with these workarounds.

2 Likes

I understand the idea here.
I have on my own customized thermostat this kind of desires.
By example, my system can be heating, cooling or doing nothing (not heating or cooling, like in the middle of may).
If I switch the heating OFF, that doesn't mean the cooling is ON, it can be "nothing".
I work with 3 virtual switches and some rules, it standardise the use of switches with only 2 positions.

It's what I did for my custom Venstar thermostat. the "up" virtual button adds 0.5C (I work in Celsius) and the "down" virtual button removes 0.5C. The global variable is the result and is injected in the real thermostat "temp setting".

1 Like