Fans aren’t related to thermostats, so it’s standalone. This feature is fully implemented now, and works well in my experience. You just need to add the metadata to your fan item.
As far as I know, you can not specify the “default” speed. When turning it on it will always use “100%”.
With your config you would also have to say “Turn fan to default”. (Not sure if it will understand it like that.)
Yep, Google equates “on” to “100%”. I got around this by using a proxy item for my fan. If Google turns the fan on to 100, the rule checks the previous state of the fan and issues that as the command.
Since you just want it to always default to 25, you might be able to define 25=on:low in your metadata.
Hello,
I’m using sonoff iFan03 with tasmota firmware connected via MQTT to OpenHab.
The firmare drive the 3-state fan speed (Min,Med,Max) by a number :(1,2,3) fro speeds plus zero for Fan Off.
Google API use number Item for Thermostat, but for Fan requre dimmers that need a number 0-100 to work well.
The only issue is that when you say “Hey Google, turn the fan on”, it will default to 100. As I suggested in my previous post, you might be able to change the default by adding “on” to one of the speeds. @arunsudhakar, did you confirm whether or not this works?
If this doesn’t work for you, use an unbound proxy item as a go-between. The proxy item would be controlled by Google, and then you’ll need a rule that triggers when the proxy item changes and tells the fan what to do. If you also use the physical controls on iFan03, you’ll also need a rule that updates the proxy item so that the two stay in sync.
Thank you @rpwong . I didn’t pursue this further , since I implemented it on Alexa using the Alexa Openhab skill. Alexa is the goto device in my household for Smart Home control
Your Welcome rpwong,
I already tried to use the metadata as you, but in this way I cant control the fan by screen control, because the allowed value are 0, 1, 3. But the Dimmer accept 0 to 100. A solution could be use nodered to change the value passed to/from the dimmer:
Dimer value:
1 to 33 will be iFan03 1
34 to 66 will be iFan03 2
67 to 100 will be iFan03 3
Or so on.
Return value from iFan 3 will be:
1 = 33
2= 66
3 = 100
In this way, Manually setting the dimer to a value between 1 and 33 the value passed to iFan3 will be 1. The response from iFan3 will set the dimmer to 33.
I don’t know what you mean by “screen control”. Are you talking about a sitemap? If so, you just have to set your sitemap element to friendly display values that it translates to 0-3.
You don’t need NodeRed (though I have nothing against it if tha works for you). What you’re describing is what I suggested with the unbound proxy item.
No, I don’t mean the Openhab UI screen Control. I already create a sitemap with a mapped Switch that work fine. 4 Buttons, with value 0-1-2-3 and proper names, to switch off and on in the 3 different speed.
I mean the google Home App Dimmer control. It accept value 0-100. To work well i need to pass to Google Home a value 0-100 instead 0-3. I don’t know “Unbound proxy items”. I have to study them…
// Google Home Dimmer to/from OpenHab Item
var FanStep = (100/3)
var FanDelta = (FanStep/2)
rule "Ventilatore Camera - Ghome to Item"
when
Item VirGa_Camera_Vent Received Command
then
if (receivedCommand < FanDelta)
{
PT_Camera_Vent.SendCommand(0)
}
else if (receivedCommand < (FanStep + FanDelta))
{
PT_Camera_Vent.SendCommand(1)
}
else if (receivedCommand < ((FanStep *2) + FanDelta))
{
PT_Camera_Vent.SendCommand(2)
}
else
{
PT_Camera_Vent.SendCommand(3)
}
end
rule "Ventilatore Camera - Item to Ghome"
when
Item PT_Camera_Vent Received Update
then
val fanVal = PT_Camera_Vent as Number
switch(fanVal.intValue)
{
case 0:
{
VirGa_Camera_Vent.PostUpdate(0)
}
case 1:
{
VirGa_Camera_Vent.PostUpdate(FanStep)
}
case 2:
{
VirGa_Camera_Vent.PostUpdate(FanStep*2)
}
default:
{
VirGa_Camera_Vent.PostUpdate(100)
}
end
I expect that:
When the Dimmer on Goolge Home change:
From 0 to about 16, the Fan is set to Speed=0
From about 16 to about 50, the Fan is set to Speed=1
From about 50 to about 83, the Fan is set to Speed=2
From about 83 to 100, the Fan is set to Speed=3
When the Fan State change:
0 => Dimmer on Google Home set to 0
1 => Dimmer on Google Home set to 33
2 => Dimmer on Google Home set to 66
3 => Dimmer on Google Home set to 100
Hello,
I found several errors in the rules, this is the last version:
// Google Home Dimmer to/from OpenHab Item
var FanStep = (100/3)
var FanDelta = (100/6)
rule "Ventilatore Camera - Ghome to Item"
when
Item VirGa_Camera_Vent received command
then
logInfo("VirGa_Camera_Vent", "Command = {}", receivedCommand)
switch (receivedCommand)
{
case ON : PT_Camera_Vent.sendCommand(3)
case OFF : PT_Camera_Vent.sendCommand(0)
case INCREASE : PT_Camera_Vent.sendCommand((PT_Camera_Vent.state as Number) + 1)
case DECREASE : PT_Camera_Vent.sendCommand((PT_Camera_Vent.state as Number) - 1)
}
end
rule "Ventilatore Camera - Item to Ghome"
when
Item PT_Camera_Vent received update
then
val fanVal = PT_Camera_Vent.state as Number
logInfo("PT_Camera_Vent", "state = {}", fanVal)
switch(fanVal.intValue)
{
case 0:
{
VirGa_Camera_Vent.postUpdate(0)
}
case 1:
{
VirGa_Camera_Vent.postUpdate(FanStep)
}
case 2:
{
VirGa_Camera_Vent.postUpdate(FanStep*2)
}
default:
{
VirGa_Camera_Vent.postUpdate(100)
}
}
end
At this point I can Switch Off and On (at maximum Speed) the Dimmer for the fan, but on google Home I cant change the speed
Google Home Immediately change the Dimmer control in a button control as soon as I opened the fan object.
I also only have an On/Off switch for my fan dimmer. Speeds are set by voice control. I’ve never known it to be any different.
@michikrug, if we attach speeds to a fan, should we see a speed selector in the Google Home app? I’ve just been assuming that it was limited to an On/Off toggle.
Ok, I suppose that is a Google Home or OpenHan interface limitation. Wold be interesting to log the message exchanged between Google and OpenHab, when the Fan Object is open. Seems that at begin google consider the Object as “dimmer” (like a “Dimmerable Bulb”), but after a query switch to a simple switch control.
I also tried to add the [“Lighting”] tag, but in this case Google transform the fan in a bulb and have some connection problem: continue to loop from “online” and “offline”.