openhab / openhab-mycroft

Mycroft skill for openHAB
Eclipse Public License 2.0
20 stars 45 forks source link

Problems with mycroft #87

Open sesma24 opened 4 years ago

sesma24 commented 4 years ago

I am trying to work with the mycroft suite together with openhab and I am trying to use irtrans devices. For the operation of these, it appears to me in the openhab documentation that I need items of type string, however when entering an item of that type mycroft does not detect it as an item when listing the available items. Would there be any possible solution to work with this convention?

mortommy commented 4 years ago

Hi, I had that kind of request before. it's a problem of not real natural language. In that case you can use a proxy item, when that item is triggered (by a vocal command) another one can be triggered to send the string command to your device.

FloatingBoater commented 4 years ago

Hi,

The proxy item technique works well to trigger any device, or even a whole set of states such as to turn many devices off last thing at night.

Here's my example from working code which is triggered with 'Hey Mycroft, turn Good Night ON' :

Define a proxy switch item:

Switch  GoodNight       "Good Night [%s]"   ["Switchable"]

Then create a rule which triggers on the proxy being turned ON by Mycroft, then turns itself off:

rule "GoodNight Scene"
when
    // only supports ON, not OFF. Self-resets back to OFF.
    Item GoodNight changed to ON
then
    logInfo("GoodNight", "Rule entry...")
    logInfo("GoodNight", "State: " + GoodNight.state.toString())

    // ls /etc/openhab2/sounds/
    //playSound("alert.mp3")

       // add your Item code here to trigger IPTrans

    // reset state ready for the next ON without triggering actions
    // https://www.openhab.org/docs/configuration/rules-dsl.html#manipulating-item-states
    GoodNight.postUpdate(OFF)

    logInfo("GoodNight", "Rule exit...")
end