Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reasonable preset of MQTT topics #6

Open
Phi2k opened this issue Feb 10, 2024 · 5 comments
Open

Reasonable preset of MQTT topics #6

Phi2k opened this issue Feb 10, 2024 · 5 comments

Comments

@Phi2k
Copy link

Phi2k commented Feb 10, 2024

After I moved my installation to docker containers I almost gave up because I did not get it working. Reason for the system not working was wrong strings in the MQTT. After installation lots of settings like e.g. speed come with "(null)". If you do not change these to the expected values the server will not accept any changes from MQTT at all.

Is it possible to directly set all MQTT topics to a working preset?

@Phi2k
Copy link
Author

Phi2k commented Feb 10, 2024

This is a setting which works for me. Make sure you setup every fan. Even if not installed.
You have to stop the server in order to make the changes if you have a malign setting.
The MQTT Broker must be setup in a way that all states are updated after the server is connecting.
Bildschirmfoto 2024-02-10 um 17 33 51

The JSON-File at "state" must also be set accordingly and must not be contradicting the other settings.
Bildschirmfoto 2024-02-10 um 17 36 45

rubenbe added a commit that referenced this issue May 7, 2024
Support starting from an empty, existing file.
@RosaEinhorn
Copy link

Thanks for providing this info as a hint on how the json data looks like. Unfortunately, Home Assistant auto discovery is not working for me (even as I see the server sending data to the homeassistant/# topic).
As this is not working I am not sure on how to setup the mqtt configuration manually. I managed to turn of one fan group (I have 3, each consisting of 2 fans) by sending an {"state": "false"} to comfospot40_zone1_fan/on/set. But now I cannot turn on the fan group anymore.
I appreciate any hint on what data is expected by the server or, alternatively, how to make auto discovery work with it. :) Thanks a lot!

@rubenbe
Copy link
Owner

rubenbe commented Feb 3, 2025

The autodiscovery works for me (tm).
I'd first enable the debug logging in the home assistant MQTT component. That generally provides a lot of insight.
If not you can also have a look with mosquitto_sub on the topics and see what is sent back and forth.

@RosaEinhorn
Copy link

RosaEinhorn commented Feb 3, 2025

Thank you for checking this one as well. :)
MQTT Discovery does not look that bad actually:

2025-02-03 09:48:17.612 DEBUG (MainThread) [paho.mqtt.client] Received PUBLISH (d0, q0, r1, m0), 'homeassistant/fan/comfospot40_zone1_fan/config', ...  (1137 bytes)
2025-02-03 09:48:17.612 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received retained message on homeassistant/fan/comfospot40_zone1_fan/config (qos=0): b'{"name": "Comfospot40 Zone 1 Fan", "state_topic": "comfospot40_zone1_fan/state", "command_topic": "comfospot40_zone1_fan/on/set", "state_value_template": "{{ value_json.state }}", "direction_state_topic": "comfospot40_zone1_fan/state", "direction_command_topic": "comfospot40_zone1_fan/direction/set", "direction_value_template": "{{ value_json.direction }}", "oscillation_state_topic": "comfospot40_zone1_fan/state", "oscillation_command_topic": "comfospot40_zone1_fan/oscillation/set", "oscillation_value_template": "{{ value_json.oscillation }}", "percentage_state_topic": "comfospot40_zone1_fan/state", "percentage_command_topic": "comfospot40_zone1_fan/speed/percentage", "percentage_value_template": "{{ value_json.percentage }}", "preset_mode_state_topic": "comfospot40_zone1_fan/state", "preset_mode_command_topic": "comfospot40_zone1_fan/preset/set", "preset_mode_value_template": "{{ value_json.preset }}", "preset_modes": ["low", "mid", "high", "max", "custom"], "qos": 0, "payload_on": "true", "payload_off": "false", "payload_oscillation_on": "true", "payload_oscillation_off": "false", "unique_id": "comfospot40_zone1_fan"}'
2025-02-03 09:48:17.613 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Process component discovery payload {'state_topic': 'comfospot40_zone1_fan/state', 'command_topic': 'comfospot40_zone1_fan/on/set', 'state_value_template': '{{ value_json.state }}', 'direction_state_topic': 'comfospot40_zone1_fan/state', 'direction_command_topic': 'comfospot40_zone1_fan/direction/set', 'direction_value_template': '{{ value_json.direction }}', 'oscillation_state_topic': 'comfospot40_zone1_fan/state', 'oscillation_command_topic': 'comfospot40_zone1_fan/oscillation/set', 'oscillation_value_template': '{{ value_json.oscillation }}', 'percentage_state_topic': 'comfospot40_zone1_fan/state', 'percentage_command_topic': 'comfospot40_zone1_fan/speed/percentage', 'percentage_value_template': '{{ value_json.percentage }}', 'preset_mode_state_topic': 'comfospot40_zone1_fan/state', 'preset_mode_command_topic': 'comfospot40_zone1_fan/preset/set', 'preset_mode_value_template': '{{ value_json.preset }}', 'preset_modes': ['low', 'mid', 'high', 'max', 'custom'], 'qos': 0, 'payload_on': 'true', 'payload_off': 'false', 'payload_oscillation_on': 'true', 'payload_oscillation_off': 'false', 'unique_id': 'comfospot40_zone1_fan', 'name': 'Comfospot40 Zone 1 Fan'}
2025-02-03 09:48:17.613 INFO (MainThread) [homeassistant.components.mqtt.discovery] Found new component: fan comfospot40_zone1_fan
2025-02-03 09:48:17.617 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=fan.comfospot40_zone_1_fan, old_state=None, new_state=<state fan.comfospot40_zone_1_fan=unknown; preset_modes=['low', 'mid', 'high', 'max', 'custom'], direction=None, oscillating=False, percentage=None, percentage_step=1.0, preset_mode=None, friendly_name=Comfospot40 Zone 1 Fan, supported_features=63 @ 2025-02-03T09:48:17.617097+01:00>>
2025-02-03 09:48:17.621 DEBUG (MainThread) [homeassistant.components.mqtt.discovery] Pending discovery for ('fan', 'comfospot40_zone1_fan'): deque([])

However, I saw in another issue that this last line is holding homeassistant back from publishing the discovered device: [homeassistant.components.mqtt.discovery] Pending discovery for ('fan', 'comfospot40_zone1_fan'): deque([])

Edit: Nevermind. The fans are not shown as MQTT devices, but the entities are published correctly in the entity view. Looks like all features are working! 🎉 Thank you so much for creating this. The fans were literally the last dumb (non-homeassistant-controllable) parts of our home.

@Phi2k
Copy link
Author

Phi2k commented Feb 11, 2025

Nice to know that there is another running installation :-). I feedback for others: the current version of the code is now running for more than 6 months without any issues. Issues with the MQTT server sometimes require a restart of the server. This never happened without a reason like playing around with the MQTT config if IOBroker.
For me it was also the last "dump" system which got smart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants