[mh] MQTT Fan to HomeAssistant
Spencer Ryan <[email protected]> Mon, 11 Aug 2025 13:15:15 -0400
| Newsgroups | gmane.comp.misc.misterhouse.user |
|---|---|
| Message-ID | <CALWY-Yro9NJXSQo8ET+khNd_We8BqL+3eSn8JgB9S0D0X26j3Q@mail.gmail.com> |
--===============5269787732847918415==
Content-Type: multipart/alternative; boundary="000000000000de9614063c1a110a"
--000000000000de9614063c1a110a
Content-Type: text/plain; charset="UTF-8"
We bought a new house a few years ago right as Insteon was collapsing and I
kind of put a pause on what to load the new place with. I had misguided
high hopes for Matter device and still don't have anything that looks as
good as Insteon.
I've finally added more Insteon gear and after giving HA and OpenHAB a run,
nothing deals with Insteon as well as Misterhouse.
So I've started down the rabbit hole of making MH do everything insteon and
HA for modern creature comforts like HomeKit, etc.
HA has it's own quirks with Fans, specifically if you want a
off/low/med/high slider to show up you need to tell it the fan only has 4
states, but then the 0-100 range needs to be mapped to 0-3.
As I keep going down the hole it turns out the MQTT code in MH doesn't
support "FAN" as a type. I intend to build this in, eventually. For now
though I exposed the fan as a dimmable light, and deal with the unfun on
the HA side.
If this helps anyone at this point, I created the fan as a normal light,
with discoverable disabled, and then used MQTT Explorer to add the
autodiscover record by hand. Here's all the magic
{
"unique_id": "insteon_51D36002",
"name": "Master Bed Fan",
"state_topic": "insteon/mbr_fan/state",
"percentage_state_topic": "insteon/mbr_fan/state",
"schema": "json",
"command_topic": "insteon/mbr_fan/level",
"percentage_command_topic": "insteon/mbr_fan/level",
"platform": "fan",
"state_value_template": "{{ value_json.state }}",
"percentage_value_template": "{% if value_json.brightness == 100 %}3{%
elif value_json.brightness >= 50 and value_json.brightness <= 99 %}2{% elif
value_json.brightness >= 1 and value_json.brightness <= 49 %}1{% elif
value_json.brightness == 0 %}0{% endif %}",
"command_template": "{ \"state\": \"{{ value }}\"}",
"percentage_command_template": "{ \"state\":\"{% if value > 0 %}ON{% else
%}OFF{% endif %}\",\"brightness\":{% if value == 3 %}100{% elif value == 2
%}75{% elif value == 1 %}25{% elif value == 0 %}0{% endif %}}",
"speed_range_max": "3"
}
I'm hoping to genericise most of that into the MH config where you'd be
able to define if you want a fan to act like a 4 speed fan or variable
(0-100%)
--000000000000de9614063c1a110a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>We bought a new house a few years ago right as Insteo=
n was collapsing and I kind of put a pause on what to load the new place wi=
th. I had misguided high hopes for Matter device and=C2=A0still don't h=
ave anything that looks as good as Insteon.</div><div><br></div><div>I'=
ve finally added more Insteon gear and after giving HA and OpenHAB a run, n=
othing deals with Insteon as well as Misterhouse.</div><div><br></div><div>=
<br></div><div>So I've started down the rabbit hole of making MH do eve=
rything insteon and HA for modern creature comforts like HomeKit, etc.=C2=
=A0</div><div><br></div><div>HA has it's own quirks with Fans, specific=
ally if you want a off/low/med/high slider to show up you need to tell it t=
he fan only has 4 states, but then the 0-100 range needs to be mapped to 0-=
3.</div><div><br></div><div>As I keep going=C2=A0down the hole it turns out=
the MQTT code in MH doesn't support "FAN" as a type. I inten=
d to build this in, eventually. For now though I exposed the fan as a dimma=
ble light, and deal with the unfun on the HA side.=C2=A0</div><div><br></di=
v><div>If this helps anyone at this point, I created the fan as a normal li=
ght, with discoverable disabled, and then used MQTT Explorer to add the aut=
odiscover record by hand. Here's all the magic</div><div><br></div><div=
><span>{<br>
=C2=A0 "unique_id": "insteon_51D36002",<br>
=C2=A0 "name": "Master Bed Fan",<br>
=C2=A0 "state_topic": "insteon/mbr_fan/state",<br>
=C2=A0 "percentage_state_topic": "insteon/mbr_fan/state"=
;,<br>
=C2=A0 "schema": "json",<br>
=C2=A0 "command_topic": "insteon/mbr_fan/level",<br>
=C2=A0 "percentage_command_topic": "insteon/mbr_fan/level&qu=
ot;,<br>
=C2=A0 "platform": "fan",<br>
=C2=A0 "state_value_template": "{{ value_json.state }}"=
,<br>
=C2=A0 "percentage_value_template": "{% if value_json.bright=
ness =3D=3D 100 %}3{% elif value_json.brightness >=3D 50 and value_json.=
brightness <=3D 99 %}2{% elif value_json.brightness >=3D 1 and value_=
json.brightness <=3D 49 %}1{% elif value_json.brightness =3D=3D 0 %}0{% =
endif %}",<br>
=C2=A0 "command_template": "{ \"state\": \"{{=
value }}\"}",<br>
=C2=A0 "percentage_command_template": "{ \"state\"=
:\"{% if value > 0 %}ON{% else %}OFF{% endif %}\",\"brigh=
tness\":{% if value =3D=3D 3 %}100{% elif value =3D=3D 2 %}75{% elif v=
alue =3D=3D 1 %}25{% elif value =3D=3D 0 %}0{% endif %}}",<br>
=C2=A0 "speed_range_max": "3"<br>
}</span></div><div><br></div><div><br></div><div>I'm hoping to generici=
se=C2=A0most of that into the MH config where you'd be able to define i=
f you want a fan to act like a 4 speed fan or variable (0-100%)</div><div><=
br></div></div>
--000000000000de9614063c1a110a--
--===============5269787732847918415==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============5269787732847918415==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users
--===============5269787732847918415==--