[SOLVED] MAP function or oder to connect Max! Thermostat "Mode" to Dummy item for Google Home interaction

Selection item=BF_Cinema_Mode icon=“radiator” label=“Mode:” mappings=[AUTOMATIC=AUTOMATIC, MANUAL=MANUAL, BOOST=BOOST]

That’s a sitemap element linked to an item
What is the item?

I guess this item:

Number BF_Cinema_ModeFake “Cienma Heating/Cooling Mode” (BF_Cinema, gBF_CienmaTS, gBF_ShowerT) [ “homekit:HeatingCoolingMode” ]

is for allowing the use of homekit or google home. Fair enough.

Rules are the way, with MAP functions too!!

According to the homekit integration docs, the values accepted are OFF, AUTO, HEAT, COOL
So a map file may look like this:
heatingmode.map

AUTOMATIC=AUTO
MANUAL=OFF
BOOST=HEAT
AUTO=AUTOMATIC
OFF=MANUAL
HEAT=BOOST

Then you need a rule:

rule "heating mode"
when
    Item BF_Cinema_Mode changed or
    Item BF_Cinema_ModeFake
then
    if (triggeringItem.name.contains("Fake")) {
        BF_Cinema_Mode.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    } else {
        BF_Cinema_ModeFake.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    }
end

Oooh, that is so cool, never knew about the possibility to check the name itself.

Is it possible to make this work genericall if any item with the name “Mode” trigger this rule?

Thanks.

Yes of course,

1 Like

Can you also show me how?
I have 11 thermostats with the same convention. Mode for the Max based Mode and ModeFake for the Google exposure.

Thanks.

Put all the items in the same group, for example: gThermostats

Then the rule is:

import org.eclipse.smarthome.model.script.ScriptServiceUtil //AT THE VERY TOP OF THE RULES FILES!!

rule "heating mode"
when
    Member of gThermostats changed
then
    if (triggeringItem.name.contains("Fake")) {
        val realItem = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.toString.replace("_Fake", ""))
        realItem.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    } else {
        val fakeItem = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.toString + "Fake")
        fakeItem.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    }
end

You’re welcome

See also:

and

For a different approach

Couldn’t get this to work yet :frowning:

2019-02-23 17:40:50.267 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert ‘AUTOMATIC’ to a state type which item ‘BF_Cinema_ModeFake’ accepts: [DecimalType, QuantityType, UnDefType].

Your code please

Items:

Group gBF_CienmaTS "Cinema Thermostat" [ "Thermostat", "Celsius" ]
Number   BF_Cinema_Temperature            "Cinema Temperature"             <temperature>      (BF_Cinema, gBF_CienmaTS, gTemperature, gLog_60s) [ "CurrentTemperature" ]   	 {channel="max:thermostat:KEQ0817097:OKF0004435:actual_temp"}
Number   BF_Cinema_Heating                "Cinema Heating"                 <heating>          (BF_Cinema, gBF_CienmaTS, gHeating)               [ "TargetTemperature" ]   	 {channel="max:thermostat:KEQ0817097:OKF0004435:set_temp"}
String   BF_Cinema_Mode                   "Cinema Mode"                    <radiator>         (BF_Cinema, gModes)                  											 {channel="max:thermostat:KEQ0817097:OKF0004435:mode"}
Number   BF_Cinema_ModeFake 			  "Cienma Heating/Cooling Mode" 					  (BF_Cinema, gBF_CienmaTS) 

Rules:
rule “Max Thermostat”

when
    Item BF_Cinema_Mode changed     or
    Item BF_Cinema_ModeFake changed
then
    if (triggeringItem.name.contains("Fake")) {
        BF_Cinema_Mode.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    } 
    else {
        BF_Cinema_ModeFake.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    }
end

Map:
AUTOMATIC=AUTO
MANUAL=OFF
BOOST=HEAT
AUTO=AUTOMATIC
OFF=MANUAL
HEAT=BOOST

Compared to your suggestion, I added one “changed” in the rule after the OR
I also installed the MAP binding (not sure if it is needed).
I am wondering if I need the homematic binding too?

I think I fixed it by changing the fake to a STRING, but still glitchy, need to figure it out a bit better… :confused:

Solved.
New map:

heat=BOOST
cool=VACATION
heatcool=AUTOMATIC
off=VACATION
AUTOMATIC=heatcool
MANUAL=heatcool
BOOST=heat
VACATION=off

Do you guys have an idea what the voice command to switch the HeatingCoolingMode is? I would like to switch the thermostat to off or boost. Thanks!

I think the above is my choice.

There is no equivalent for each item.

When I tried that, I got stuck in a long list of things changing (rather than the item triggering the change):

019-02-24 01:59:51.477 [vent.ItemStateChangedEvent] - FF_Bath_ModeFake changed from AUTOMATIC to heatcool

2019-02-24 01:59:51.479 [vent.ItemStateChangedEvent] - FF_MasterBedroom_ModeFake changed from heatcool to AUTOMATIC

2019-02-24 01:59:51.499 [vent.ItemStateChangedEvent] - FF_MasterBedroom_ModeFake changed from AUTOMATIC to heatcool

I know why the infinite loop occurs.

I made “Mode_Fake” and “Mode” part of the same group.
But I need a way of changing Mode, when Mode_Fake receives a command (because that would be triggered by via google home).
But I need a way of changing Mode_Fake, when Mode changes (because that would be triggered by sitemap)

Solved it by waiting for “received command” rather than state change:

import org.eclipse.smarthome.model.script.ScriptServiceUtil //AT THE VERY TOP OF THE RULES FILES!!

rule "heating mode"
when
    Member of gThermo received command
then
    if (triggeringItem.name.contains("Fake")) {
        val realItem = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.toString.replace("_Fake", ""))
        realItem.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    } else {
        val fakeItem = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.toString + "Fake")
        fakeItem.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    }
end

2019-02-24 02:41:02.619 [ome.event.ItemCommandEvent] - Item ‘GF_Toilet_Mode’ received command MANUAL

2019-02-24 02:41:02.634 [nt.ItemStatePredictedEvent] - GF_Toilet_Mode predicted to become MANUAL

2019-02-24 02:41:02.640 [vent.ItemStateChangedEvent] - GF_Toilet_Mode changed from AUTOMATIC to MANUAL

2019-02-24 02:41:02.713 [vent.ItemStateChangedEvent] - GF_Toilet_ModeFake changed from NULL to heatcool

2019-02-24 02:41:37.828 [ome.event.ItemCommandEvent] - Item ‘GF_Toilet_ModeFake’ received command heat

2019-02-24 02:41:37.846 [vent.ItemStateChangedEvent] - GF_Toilet_ModeFake changed from heatcool to heat

2019-02-24 02:41:37.857 [vent.ItemStateChangedEvent] - GF_Toilet_ModeFake changed from heat to BOOST

Sorry I was too happy.

Still not working.
I changed the rule as follows:

rule "heating mode"
when
    Member of gThermo received command
then
    if (triggeringItem.name.contains("Fake")) {
        val realItem = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.toString.replace("**Fake**", ""))
        realItem.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    } else {
        val fakeItem = ScriptServiceUtil.getItemRegistry.getItem(triggeringItem.name.toString + "Fake")
        fakeItem.postUpdate(transform("MAP", "heatingmode.map", triggeringItem.state.toString))
    }
end

The bolded “Fake” was previously “_Fake”.
But no impact.

“not working” is unhelpful. logs?

You’re right. I will play a bit and share the detailed progress or lack of.

Can someone tell me what is the Alexa voice command to switch the Homekit:HeatingCoolingMode?

Say, to switch a thermostat to off?