Fan control over http with virtual dimmer and homebridge
Posted: Wednesday 22 December 2021 17:04
I have a pwm fan that is controlled by an ESP. I can control the fan by sending a value, something like http://192.168.1.50?speed=800
To control it, I've set up a dummy dimmer switch and this lua code:

All the above works like a charm 
The "trouble" starts in Homebridge/Homekit. I run homebridge with eDomoticz plugin on the same raspberrypi as where I run Domoticz.
It shows up as a light instead of a fan.
When I add the virtual switch by clicking "Manual Light/Switch" from the switch tab and choose a dimmer with type AC, I get this:

And this does show up as a fan in homebridge/homekit.
Left is the Dimmer of type AC, right Dimmer of type Switch

From what I've read here https://www.sigmdel.ca/michel/ha/x10/pole_04_en.html that last method is not the correct way to set up a virtual dimmer.
With this solution there are steps of 6% and I need to modify the lua, because it doesn't pass along 0-100%, but discrete steps.
I would like to know if anyone managed to create a proper virtual dimmer switch of some sort that shows up as a fan in homebridge/homekit.
To control it, I've set up a dummy dimmer switch and this lua code:

Code: Select all
commandArray = {}
DomDevice = 'myfan';
IP = '192.168.1.50';
if devicechanged[DomDevice] then
if(devicechanged[DomDevice]=='Off') then
DomValue = 0;
else
DomValue = otherdevices_svalues[DomDevice];
CalcValue = (7.23* DomValue) + 300;
end
if CalcValue==nil then CalcValue=0 end
runcommand = "curl 'http://" .. IP .. "?speed=" .. CalcValue .. "'";
os.execute(runcommand);
print("PWM value= "..CalcValue);
end
return commandArray

The "trouble" starts in Homebridge/Homekit. I run homebridge with eDomoticz plugin on the same raspberrypi as where I run Domoticz.
It shows up as a light instead of a fan.
When I add the virtual switch by clicking "Manual Light/Switch" from the switch tab and choose a dimmer with type AC, I get this:

And this does show up as a fan in homebridge/homekit.
Left is the Dimmer of type AC, right Dimmer of type Switch

From what I've read here https://www.sigmdel.ca/michel/ha/x10/pole_04_en.html that last method is not the correct way to set up a virtual dimmer.

I would like to know if anyone managed to create a proper virtual dimmer switch of some sort that shows up as a fan in homebridge/homekit.