The following installation instructions represent (what I believe to be) the easiest way to implement this custom component, in version 0.89, without affecting any of the existing MQTT components. Please be aware that if there are changes made to the MQTT component in 0.90, or later versions, this custom component may fail to work (and require additional modifications).
Create a new directory under custom_components called my_mqtt.
config/custom_components/my_mqtt
Copy the contents of this pastebin linkthispastebin link into a new file called climate.py.
config/custom_components/my_mqtt/climate.py
In configuration.yaml, find your existing MQTT climate entity and replace:
platform: mqtt
with:
platform: my_mqtt
The next step is needed ONLY if your climate entity is configured with a unique_id. If it doesn’t then skip the next two bullet-points and go directly to the Config Check step.
Use a text editor to modify the following file: config/.storage/core.entity_registry
Find your climate entity and replace: "platform": "mqtt" with "platform": "my_mqtt"
Run Config Check and, if no errors are reported, restart Home Assistant.
Revised the pastebin link to the corrected version of the code.
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
connection.context(msg))
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1133, in async_call
self._execute_service(handler, service_call))
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py", line 1155, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_component.py", line 188, in handle_service
self._platforms.values(), func, call, service_name
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 278, in entity_service_call
future.result() # pop exception if have
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/service.py", line 292, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/home/homeassistant/.homeassistant/custom_components/my_mqtt/climate.py", line 687, in async_set_operation_mode
_LOGGER.info("Operation_mode_command: %s", operation_mode_command)
UnboundLocalError: local variable 'operation_mode_command' referenced before assignment```
Could it be that there is an issue with the custom climate.py in version 0.90.1?
Got the following error: Platform not found: climate.mqtt_custom
Check here:
I’m using it with 0.90.1 and it works without any issues.
The Platform not found message suggests to me that the custom component was not installed in the correct directory.
Here are the installation instructions I posted earlier in this thread:
Create a new directory under custom_components called my_mqtt.
config/custom_components/my_mqtt
Copy the contents of this pastebin link into a new file called climate.py.
config/custom_components/my_mqtt/climate.py
In configuration.yaml, find your existing MQTT climate entity and replace:
platform: mqtt
with:
platform: my_mqtt
The next step is needed ONLY if your climate entity is configured with a unique_id. If it doesn’t then skip the next two bullet-points and go directly to the Config Check step.
Use a text editor to modify the following file: config/.storage/core.entity_registry
Find your climate entity and replace: "platform": "mqtt" with "platform": "my_mqtt"
Run Config Check and, if no errors are reported, restart Home Assistant.
A bit unsure about changing mqtt to my_mqtt in core.entity_registry
Nothing in there related to my HAI thermostats but I have several entries like this of sonoff devices:
Each HAI theromstat has a MQTT id starting with climate., ie climate.garage_heat or climate.masterbdrmht or climate.guestbdrmht etc.
But none are in the core.entity_registry file with any device_id or anything else. I only see sonoff/tasmota devices and iPhone devices listed there.
Doesn’t look like it is installing correctly. Sure I missed something.
from log file at boot:
2019-04-02 16:08:36 INFO (MainThread) [homeassistant.components.switch] Setting up switch.mqtt
2019-04-02 16:08:42 INFO (MainThread) [homeassistant.loader] Loaded my_mqtt.climate from custom_components.my_mqtt.climate
2019-04-02 16:08:42 WARNING (MainThread) [homeassistant.loader] You are using a custom component for my_mqtt.climate which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2019-04-02 16:08:42 INFO (MainThread) [homeassistant.setup] Setting up climate
2019-04-02 16:08:43 INFO (MainThread) [homeassistant.components.climate] Setting up climate.my_mqtt
2019-04-02 16:08:43 INFO (MainThread) [homeassistant.setup] Setup of domain climate took 0.3 seconds.
2019-04-02 16:08:43 INFO (MainThread) [homeassistant.loader] Loaded mqtt.climate from homeassistant.components.mqtt.climate
2019-04-02 16:08:43 INFO (MainThread) [homeassistant.components.climate] Setting up climate.mqtt
2019-04-02 16:08:43 WARNING (MainThread) [homeassistant.helpers.config_validation] Your configuration contains extra keys that the platform does not support.
Please remove [temperature_low_state_topic], [temperature_low_command_topic], [temperature_high_state_topic], [temperature_high_command_topic].
2019-04-02 16:08:43 WARNING (MainThread) [homeassistant.helpers.config_validation] Your configuration contains extra keys that the platform does not support.
Please remove [temperature_low_state_topic], [temperature_low_command_topic], [temperature_high_state_topic], [temperature_high_command_topic].
2019-04-02 16:08:43 WARNING (MainThread) [homeassistant.helpers.config_validation] Your configuration contains extra keys that the platform does not support.
Please remove [temperature_low_state_topic], [temperature_low_command_topic], [temperature_high_state_topic], [temperature_high_command_topic].
2019-04-02 16:08:43 WARNING (MainThread) [homeassistant.helpers.config_validation] Your configuration contains extra keys that the platform does not support.
Please remove [temperature_low_state_topic], [temperature_low_command_topic], [temperature_high_state_topic], [temperature_high_command_topic].
ys that the platform does not support.
Please remove [temperature_low_state_topic], [temperature_low_command_topic], [temperature_high_state_topic], [temperature_high_command_topic].
2019-04-02 16:10:28 INFO (MainThread) [homeassistant.setup] Setting up axis
The following messages are normal and indicate the my_mqtt custom component was loaded:
2019-04-02 16:08:42 INFO (MainThread) [homeassistant.loader] Loaded my_mqtt.climate from custom_components.my_mqtt.climate
2019-04-02 16:08:42 WARNING (MainThread) [homeassistant.loader] You are using a custom component for my_mqtt.climate which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
This set of messages (there are several) indicates a genuine problem:
2019-04-02 16:08:43 INFO (MainThread) [homeassistant.components.climate] Setting up climate.mqtt
2019-04-02 16:08:43 WARNING (MainThread) [homeassistant.helpers.config_validation] Your configuration contains extra keys that the platform does not support.
Please remove [temperature_low_state_topic], [temperature_low_command_topic], [temperature_high_state_topic], [temperature_high_command_topic].
You are getting that message because my custom MQTT climate component does not support the following keys you have entered in the configuration file:
temperature_low_state_topic
temperature_low_command_topic
temperature_high_state_topic
temperature_high_command_topic
I don’t know why you’ve specified those options but they won’t work with my custom component. Perhaps these are for someone else’s custom climate component.
I just went through every .yaml file I have and nothing related to these temp topics is there.
I thought these started and were related to the install of omnilink-bridge. That they are being reported from the Omni-Pro-II and HA can handle them because of some MQTT protocol issues. Will do more checking tomorrow. I have had this error notice before trying your my.climate change.
Thanks for looking at this. Will let you know what I find.
Because someone else submitted a PR (several months ago), that would use a new dedicated topic (like activity_state_topic ) to help differentiate between the thermostat’s operating state (i.e. its current activity) and its operating mode. The PR was rejected on the grounds it didn’t conform with the ongoing architectural discussion for climate components (I don’t use the word ‘ongoing’ lightly; the discussion started over a year ago and there doesn’t appear to be any consensus yet).
My custom component uses the same technique as in the rejected PR (so there’s a good reason why I wouldn’t bother submitting it as a PR). I’ve been using it since version 0.80 without any problems. Although I enjoy debating the merits of various technical approaches, this is one situation where I needed a working MQTT climate component sooner (6 months ago) than later.
To everyone who is using my custom component, please be advised that I’ll be making additional changes to it in the near future because of internal changes made in Home Assistant 0.90. Version 0.91 continues to tolerate my custom component (it reports the component is using a deprecated way of calling certain functions) but I know future versions will stop working with it unless I update it.
These are the modes Home Assistant understands (and they’re used for Lovelace’s climate card).
Your value_template has to convert the modes reported by your Eurotronic thermostat into modes understood by Home Assistant.
For example, my thermostat reports its modes using a number. Here is each number mapped to one of Home Assistant’s modes.
0 = auto
1 = heat
2 = cool
4 = off
My thermostat’s configuration is like this:
modes:
- auto
- heat
- cool
- 'off'
mode_state_topic: "premise/thermostat/temperaturemode"
mode_state_template: >-
{% set values = { '0':'auto', '1':'heat', '2':'cool', '4':'off'} %}
{{ values[value] if value in values.keys() else 'off' }}
mode_command_topic: "premise/command/thermostat/temperaturemode"
mode_command_template: >-
{% set values = { 'auto':'0', 'heat':'1', 'cool':'2', 'off':'4'} %}
{{ values[value] if value in values.keys() else '4' }}
You said your thermostat also reports its modes as numbers. However, the problem I see is that the modes you mentioned (normal operation, boost, child protection) don’t have direct equivalents in Home Assistant. Perhaps ‘normal’ can be handled as ‘auto’?