Closed spfmoby closed 4 years ago
The Swicago code has nothing to do with MQTT. It's strictly a library for interfacing with the Mitsubishi head unit using the serial bus. It did include examples of reading and setting options to and from MQTT topics, but all the various MQTT interfaces (HASS, OpenHAB, Domoticz) occur on a layer above the Swicago code.
It's not trivial to just change the MQTT topics. It looks like the Masurov plugin only uses a single MQTT topic to set options. This project has a setting topic as well as a state topic. The HASS autodiscovery topic maps these so HASS can use them. In other words, the state and status topics aren't specific to HASS.
A better fix for this, IMO, is modifying the Masurov plugin to use the generic state and setting topics provided by this project.
@spfmoby Do you try to contact Masurov to see if he can adapt his plugin to our mqtt topics?
Yes... and he almost said what you said (but opposite): a better fix for this is that gysmo38 sticks to the original Swicago MQTT topics/states from the examples as he can't develop a version of his domoticz plugin for every project based on the Swicago library.
He forked your project https://github.com/Masurov/mitsubishi2MQTT to remove your MQTT implementations and put back the "original" ones. But that' not a very clever solution as he forked it for me so I can try, but he won't maintain it.
Maybe from what he has done in his fork you can take his code, and integrate a radio button in the parameters so we can switch between the two MQTT implementation?
I think it is not a good idea because he break homeassistant integration. We also start from the example but we made modification to work with homeassistant. I am agree with, a configuration option could be a solution. The problem, I am not using Domoticz anymore, so I can not implement it. If he can do it and send a PR, that could be great. I will check the fork if I can do something. Have you ever try Homeassistant? I used Domoticz for years but Homeassistant is more user friendly :) Just for HVAC you have on device to control everything not differents devices...
I looked at his fork, and yeah, it absolutely breaks HA integration.
It ignores the Fahrenheit/Celsius handling code I added, and only in his internal changes, so e.g. you can set the unit to Fahrenheit in the web interface, but his code ignores it when setting temperature. That means that if you manually set the unit to F and set the temperature to 68 degrees in the web interface, 68 degrees Celsius will be sent to the Swicago library, which obviously won't work. So his fork has broken temperature support.
It removes the status, so you can't tell if the unit is idle or doing something else.
I also really have to repeat that the Swicago example code for MQTT isn't a standard and isn't a feature of his library, and I don't think Swicago even uses MQTT with his units.
I'm fine if he or someone else wants to add an option to enable HA/Domoticz/whatever support, with conditionals for the MQTT topic handling. But HA autodiscovery requires separate set and state topics for the mode, fan, temperature, power, step, and min/max temperature, so HA can't just use the single set and state topics like the Swicago MQTT example code.
@shampeon I am agree with you. @spfmoby I try the plugin. I found two problems:
@gysmo38, @spfmoby with your permission I have forked the domoticz implementation and removed the has implementation. It works by following the guidelines of the swicago mqtt example, in addition http control is enabled without the need to configure mqttt. It works perfect with the domoticz plugin made in python for mitsubishi. Throughout the day I will upload the files to my fork, domoticz branch. I would also like to add the possibility of setting timers for the heat pump that the esp8266 itself will control, both to turn it on and to turn it off
Regards
So I took a look at the Masurov Domoticz-MitsubishiHpMQTT-Plugin code again, and as far as I can tell, it would work with our mitsubishi2MQTT code with just 2 or 3 tiny code changes.
https://github.com/Masurov/Domoticz-MitsubishiHpMQTT-Plugin/blob/master/plugin.py#L13
Set Mode5 parameter to "mitsubishi2mqtt".
<param field="Mode5" label="Heatpump MQTT topic" width="300px" required="true" default="mitsubishi2mqtt"/>
I imagine this parameter can be set within Domoticz, though I don't use it so I don't know for certain.
https://github.com/Masurov/Domoticz-MitsubishiHpMQTT-Plugin/blob/master/plugin.py#L171
Set self.HeatpumpSetTopic to "settings":
self.HeatpumpSetTopic = self.HeatpumpTopic + "/settings"
https://github.com/Masurov/Domoticz-MitsubishiHpMQTT-Plugin/blob/master/plugin.py#L172
Set RoomTempTopic to "state":
self.RoomTempTopic = self.HeatpumpTopic + "/state"
@ ianjevans the first parameter is freely customizable in Domoticz, so it is not a real problem. I set the topic name both to "mitsubishi2mqtt" in the Mitsubishi2MQTT plugin and in the domoticz plugin.
For the 2 others parameters, I tried to edit the plugin on my domoticz instance and it does not seem enough to make it work.
#self.HeatpumpSetTopic = self.HeatpumpTopic + "/set"
self.HeatpumpSetTopic = "settings"
#self.RoomTempTopic = self.HeatpumpTopic + "/status"
self.RoomTempTopic = "state"
Is it what you mean by Set self.HeatpumpSetTopic to "settings" ? or should we just replace "set" by "settings" and "status" by "state" on the whole line ? I tried both and it does not seem to work :(
debug log of domoticz when sending a "power on" command:
2020-04-16 13:28:21.778 (mitsubishi) Sending 2 bytes of data
2020-04-16 13:28:21.778 (mitsubishi) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-04-16 13:28:21.828 (mitsubishi) Received 2 bytes of data
2020-04-16 13:28:21.828 (mitsubishi) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-04-16 13:28:31.801 (mitsubishi) Sending 2 bytes of data
2020-04-16 13:28:31.801 (mitsubishi) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-04-16 13:28:31.852 (mitsubishi) Received 2 bytes of data
2020-04-16 13:28:31.852 (mitsubishi) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-04-16 13:28:41.774 (mitsubishi) Sending 2 bytes of data
2020-04-16 13:28:41.775 (mitsubishi) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-04-16 13:28:41.825 (mitsubishi) Received 2 bytes of data
2020-04-16 13:28:41.825 (mitsubishi) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-04-16 13:28:51.805 (mitsubishi) Sending 2 bytes of data
2020-04-16 13:28:51.805 (mitsubishi) c0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. �
2020-04-16 13:28:51.856 (mitsubishi) Received 2 bytes of data
2020-04-16 13:28:51.856 (mitsubishi) d0 00 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. Ю
2020-04-16 13:28:53.159 (mitsubishi) Command: On (0) Color:
2020-04-16 13:28:53.159 (mitsubishi) getting device for unit 1
2020-04-16 13:28:53.159 (mitsubishi) found
2020-04-16 13:28:53.159 (mitsubishi) key : power
2020-04-16 13:28:53.160 (mitsubishi) value : ON
2020-04-16 13:28:53.160 (mitsubishi) {'power': 'ON'}
2020-04-16 13:28:53.160 (mitsubishi) publishing on mitsubishi2mqtt/settings : {"power": "ON"}
2020-04-16 13:28:53.160 (mitsubishi) MqttClient::Publish mitsubishi2mqtt/settings ({"power": "ON"})
2020-04-16 13:28:53.161 (mitsubishi) Sending 43 bytes of data
2020-04-16 13:28:53.161 (mitsubishi) 30 29 00 18 6d 69 74 73 75 62 69 73 68 69 32 6d 71 74 74 2f 0)..mitsubishi2mqtt/
2020-04-16 13:28:53.161 (mitsubishi) 73 65 74 74 69 6e 67 73 7b 22 70 6f 77 65 72 22 3a 20 22 4f settings{"power":."O
2020-04-16 13:28:53.161 (mitsubishi) 4e 22 7d .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. N"}
2020-04-16 13:28:53.119 Status: User: johndoe initiated a switch command (273/mitsubishi - Power/On)
The temperature also stays at zero.
I meant that lines 171 and 172 should be:
self.HeatpumpSetTopic = self.HeatpumpTopic + "/settings"
self.RoomTempTopic = self.HeatpumpTopic + "/state"
This is to match the settings and state topics in mitsubishi2MQTT. E.g.
ian@diablo:~ $ mosquitto_sub -h x.x.x.x -v -t "mitsubishi2mqtt/playroom/#"
mitsubishi2mqtt/playroom/settings {"temperature":70,"fan":"AUTO","vane":"AUTO","mode":"off"}
mitsubishi2mqtt/playroom/state {"roomTemperature":67,"temperature":70,"fan":"AUTO","vane":"AUTO","action":"off","mode":"off"}
Swicago's MQTT example uses "set" and "status".
And I just noticed another limitation of Swicago's MQTT example: the MQTT topic only works with a single heatpump.
So for each Domoticz heatpump, you'll need to set Mode5 to the unit name you set in mitsubishi2MQTT. E.g. if the "Friendly Name" you set on setup is "foo", set Mode5 to "mitsubishi2mqtt/foo"
OK, thanks for the details. In Mitsubishi2MQTT I've set: topic : "mitsubishi2mqtt" friendly name : "playroom" (to stick to your example)
In the Domoticz plugin I modified the lines 171 and 172 to: self.HeatpumpSetTopic = self.HeatpumpTopic + "/settings" self.RoomTempTopic = self.HeatpumpTopic + "/state"
In the parameters of the plugin: mqtt topic: mitsubishi2mqtt/playroom
And... it works... halfway for now. I mean that the "state" functions seems to work properly. I now have the temperature in domoticz, and if I change a parameter in Mitsubishi2MQTT like the fan speed or on the AC remote, it is passed on to domoticz. But:
Ok, thanks for checking. I think the modes aren't quite the same between mitsubishi2mqtt and the Domoticz plugin, so even though the mode is being reported in the state/settings topic it's not being picked up by the Domoticz plugin.
There's 3 ways we can fix this, I think, in ascending order of complexity:
No news. I close this issue. Re open or open new one if needed.
I thought that your esp8266 plugin was based enough on the Swicago MQTT code so this domoticz plugin would work: https://github.com/Masurov/Domoticz-MitsubishiHpMQTT-Plugin
But it seems that they use different "words" to exchange through MQTT. For example the domoticz plugin sends commands like: pac/pac/set {"vane": "SWING"} pac/pac/set {"mode": "FAN"}
But your code sends commands/status like: pac/pac/state {"roomTemperature":19,"temperature":19,"fan":"AUTO","vane":"1","action":"off","mode":"off"} pac/pac/settings {"temperature":19,"fan":"AUTO","vane":"1","mode":"dry"}
Is there a way to make the two communicate? Have you developed a plugin for domoticz for your version of the code? Another way to see the problem (maybe simpler for you) is : can you provide a parameter in the interface to switch between a "HASS friendly" style and the original Swicago MQTT commands ?