Can you control the fan directly by sending the appropriate payload to the appropriate topic using an MQTT client (either HA or something like MQTTFx)?
using your example code if you use HA to publish a payload of “1” to the topic “bedroom/fan/1/action” does the speed of the fan change to “low”?
And I’m not sure why your speed state topic uses the payload of “2” to tell you the fan is in the “on” state when the payload for the “medium” speed is also a “2” to the exact same topic.
Lastly, does the fan work and report its correct state/speed back to HA correctly when you change the fan setting thru the normal built-in fan control and not using my fan control row?
finity,
I’m still in the development stage.
The wemos code I have, does in fact work. I set it up in a function loop for each fan speed.
When the payload hits the wemos, it runs the function of sending 1’s and 0’s to the RF transmitter. (in honesty, this is for my gf’s house). I can’t actually test everything live, but from serial monitor, I see the payload is hitting the wemos, it publishes back the status it received.
When I call the light on/off function, HA responds as expected.
The payload on: 2, is copied from a thread, I guess a few months/years back.
It does look like I need to fix that.
Do you think that is all that needs to be changed in my fan.yaml file?
Lastly, I intend on adding also to the Wemos D1 Mini, an RF receiver. Once the remote sends a fan speed/light off on signal, the RF receiver will also receive and publish the fan state. Without getting too heavy in it, in order to multi-task arduino or wemos, you have to run some more complex code than I’m comfortable with (right now).
How it runs now and how I plan it to run:
MQTT publishes topic >> Wemos Receives topic >> runs the signal out the RF transmitter and also, after runing the RF signal, publishes the state so HA/MQTT knows what state the fan is in.
If the end-user uses the fan’s RF remote:
Signal sent to fan >> also intercepted by Wemos >> Wemos interprets signal and publishes to HA/MQTT.
I could have the Wemos send payload and simultaneously publish to its own receiver, but that requires multi-tasking/computing that I’m not yet comfortable with. Maybe someone will intercept my code and help out, but for now, that’s how it will run.
I hope this makes sense.
When I hit fan high button, I do receive the payload and in turn, the same payload is published to HA/MQTT. I can do this for medium speed and low.
Off does nothing.
Turning off/on the light also is successful.
I have not gone in to the fan’s microcontroller to flash with TASMOTA or anything. I’m essentially communicating with the fan through radio signals.
The wemos however, receives the payload, and pushes the signal to the fan. In this way, the fan is stock so that once she/we move, anyone else can still control the fan.
RF Transmitter:
For now, I’m perplexed at the javascript and custom card.
Let me know your thoughts?
I would say to not worry about the card until you get everything working in HA using the built-in control. Once that works the card should just work. (I think…)
The fan yaml code you are using is the code for a tasmota flashed fan controller (notice the “value_json.FanSpeed” lines? that’s the sub-topic tasmota uses for the speed.) so I’m pretty sure it won’t work for your use. You’ll have to come up with the correct topics and payloads to pick up the state and speed from your MQTT messages.
I guess as a start I would comment out both the “state_value_template” and “speed_value_template” and change the payload_on to “on”.
TBH, I haven’t dug thru your arduino code to see what all of the different topics/payloads are so “on”, “off”, “1”, “2”, “3” may not be the correct payloads. But I assume at least some of them are correct since you are saying the Wemos is responding to some of them correctly.
One Other thing I just saw is that you are using all upper case letters for “OFF”. are you sure that is correct? MQTT topics & payloads are case sensisitive.
I’ll go back through my coding and convert everything to lowercase.
If you go into the developer tools >> services tab in HA and go to mqtt.publish service, it is in fact possible to push payloads using uppercase, nonetheless, I’ll change everything to lower case.
I know in the past, uppercase characters weren’t accepted so what you’re saying, I hear you, I’ll change it up and report back.
I’m not saying that everything has to be in lower case. I’m saying to be sure that whatever case you’re using you need to make sure it all matches the topics and payloads exactly when you are publishing and subscribing.
so “OFF” is perfectly fine. So is “Off” or “oFF”. Just make you use the same case in your fan yaml as the expected case coded into your MQTT messages in your arduino code. If you use “OFF” in the yaml config and “off” in your arduino sketch it won’t work.
The low, med, hi speeds look OK but in your skecth you are using “4” for off but in your fan yaml you have “OFF” for the off payload. So those have to match.
Also there is no state for “on” for the fan in your sketch that I can see. But you are using “2” for the “on” payload (as I’ve already mentioned) which is the speed command for the medium speed.
Also I’m confused about your status topic. I only see where the status is switched in one spot at the end of any light action. But I don’t see the same status topic get updated when the fan is commanded to do something. Where does the status topic get updated for the fan state.
If it were me I would split the fan command/state topics and the light command/state topics out from each other so you can control those completely separately and minimize confusion over “is the status of ‘ON/OFF’ for the light or fort the fan?” type of stuff.
But that was all just from a cursory skim of the code. So I could be completely wrong.
I think you should eliminate the code in your sketch for the #2 fan while you are developing to minimize the confusion that the massive wall of text creates until you get all of your MQTT stuff sorted for fan #1.
Okay, I’ve done as you’ve suggested.
I’ve changed up the wemos code to eliminate one of the fans to minimize confusion. I reformatted some of it as well to try and make it more legible (I’m still a novice).
I know you’re going to point out that my status topci doesn’t quite align with conventional coding too, I changed this to “…/RESULT” as well in my testing. I’m open to any suggestions, I just wanted to point out I am aware the status topic matches the action topic.
The ‘off’ button does not seem to send any command to the wemos; no payload is sent over MQTT.
Also the buttons still don’t seem to change upon changing fan speed.
Seen here in this image, I’ve selected “M” or payload 2:
And the serial output from hitting button “M” (payload 2):
Payloads are all being received, and I can confirm that the publish is working, as you can see that the light status changes.
In the following image, I have clicked on all buttons, changing the status (including the off button).
I guess one of my questions also is "what is the necessity for payload 4?
EDIT: I found your thread trying to work out your jinja:
How does this implement into the TASMOTA fans? My fan’s remote only has 5 buttons:
Low
Medium
High
Off
Light (off/on)
I changed the speed state topic to match the javascript “FanSpeed” also to try to narrow down the issue/solution.
I’m not real strong in javascript but I imagine the js in the fan.yaml, says that any FanSpeed payload higher than 0 should change the icon color status.
I imagine in your fan-control-entity-row.js it says that if the button is pressed, the color of the button changes too, but that doesn’t seem to work for me.
Should I be publishing payload 4 in addition to any of my fan speeds 1,2,3?
Would that tell the card that the fan is on?
EDIT: I tried publishing payload 4 as well at the same time, this was a novice experimet, but I now believe I understand what you were achieving in your jinja code (I found an old link you were working on in 2018)
oops, I forgot to mention that I do have an ‘else’ statement that should serial print if it receives a payload it is not familiar with.
Any help or instruction greatly appreciated! I’m just trying to get this to work like you have and I think there may be some things still I don’t quite fully understand that are influencing my unexpected results.
something seems to be aloof. Maybe it is because I’m on the latest “greatest” version of HA.
I just tried to change your fan-control-entity-row.js file to a random color purple… nothing has changed.
Cleared my cache, full restart of HA installation, incognito mode, and I can’t see the color change…
Has anyone else been successful with this card at the latest HA version? Seems weird since the buttons work…but the customization is off.
Do I need anything in my configuration.yaml file other than the below:
What is the difference in these two addresses?
/hacsfiles/fan-control-entity-row/fan-control-entity-row.js
/config/www/community/fan-control-entity-row/fan-control-entity-row.js
I used HACS to install the fan-control-entity-row.js card, and it made for me the www/community/… address.
When I go into Configuration >> Lovelace Dashboard I am presented with an address that is different.
also, if I go to my url, for example, https://my_HA_address.duckdns.org/hacsfiles/fan-control-entity-row/fan-control-entity-row.js I see the original javascript document, unchanged. All of the color changes I made are default…
I’m perplexed at how this is running.
I went to the thread from 2018 and was reading through your conversation.
I realized Graham (gpbenton) was able to publish to the RESULT topic the ‘{“FanSpeed”:4}’ payload which turned on the fan icon. I tried this too, and it worked for me which made me realize that specific payload is needed to be received.
I went back to my Wemos Code and added the following listed below.
It took me a little bit to learn how to send quotes as a variable, but once done, it works as designed (mostly).
else if (requestedRoom == mqtt_room2_fan_action_topic && requestedAction == "3") {
Serial.print("Setting ");
Serial.print(bedroom2_alias);
Serial.println("'s fan speed to high!");
client.publish(mqtt_room2_fan_status_topic, "3");
------------------> client.publish(mqtt_room2_fan_status_topic, FanResult3);
{
for (a = 0; a < 8; a++) {
for (int i = 0; i < sizeof(recordedSignal_fanhigh2) - 1; i++) {
digitalWrite(transmitter_pin, recordedSignal_fanhigh2[i]);
delayMicroseconds(393.9);
}
delayMicroseconds(9000);
}
delay(800);
}
}
I don’t really care too much about changing the colors of the buttons as I kinda like the default view, but it does make me wonder where really I need to edit, in order for the changes to take place.
The funny thing is I was working on a (long-ish) post that was going to point out to you that your code only provides a simple payload but the templates require a valid json object to decode (which is where the “value_json” comes into play). But I got called away for my real job and now that I’m back again I see you figured it out on your own.
If you want to try to get the colors working for future use then could you please post your latest card/row config in which you tried to change the colors?
I’m assuming he quoted my template post from earlier because he’s using the same product, the Inovelli LZW36 is a Z-Wave combo switch that is intended to control a fan and a light (single physical device, multiple endpoints). After it’s included to OZW both physical switch controls appear as lights. There’s no way to have OZW include it as a fan (I can’t remember if OZW 1.4 even includes fan support), so template out the light as a fan with certain brightness settings being equivalent to speed settings. You could control it as as a light entity but makes way more sense to interact with it as a fan entity.
Hello everybody! I am new to HA and feel like Alice in Wonderland. I use a new PI4, and am still much confused. Have some rusted experience with programming in C, and this is all very complicated to me, severe lack of knowledge…
My plan is to add my ceiling fan to HA. It is a simple fan with an IR remote. 4 buttons, for ‘off’, and speed 1,2 or 3. Installed a broadlink RM4 infrared transmitter. Learned the 4 buttons of the remote.
Installed the javascript, and I made a card that shows the 4 buttons. So far, so good. Now I have to connect the buttons to the fan - and I am totally stuck now.
My card looks like this now:
type: entities
show_header_toggle: false
entities:
- entity: fan.sunroom_fan
type: 'custom:fan-control-entity-row'
name: MBR Fan Not Custom
customTheme: true
customOffText: UIT
In configuration.yaml I tried to paste the entire fan code, but when checking it for validity, I get complaints of all sorts. So I started with a small portion of it, that looks like this:
When I click on the text MBR Fan not Custom, I get a panel with a switch, which in fact turns on my fan. The switch moves back to off, by itself, and when I click it again, the fan turns off. Wow!
Now I try to expand the code, adding the next bit:
Do you have all of the fan configuration stuff directly in your configuration.yaml file or is it split into different files?
I see in your input select code that you have a dash (-) in front of the “input_select:” that shouldn’t be there and the indentation is way off for the second line. Is that a copy/paste error? Fix those first.