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

error code 500 #27

Open
Patricen1 opened this issue Feb 1, 2022 · 20 comments
Open

error code 500 #27

Patricen1 opened this issue Feb 1, 2022 · 20 comments

Comments

@Patricen1
Copy link

Hello,

Since a couple of days, there is an issue when controlling air conditioner.
Status is correctly uploaded to Domoticz, but when trying to control air conditioner from Domoticz, the following message appears in the log and there is no effect on the aircon system : "MELCloud receive unknonw message with error code 500".

Has anybody got a clue regarding this issue?
Thanks

@Xavier74
Copy link

Xavier74 commented Feb 1, 2022

same problem here.. :(

@mitkodotcom
Copy link

mitkodotcom commented Feb 1, 2022

It looks like MELcloud does not accept urlencoded forms. I have created a quick-and-dirty (very dirty) fix by replacing the urlencoded form with a json one. I don't have a time for patch or pull request now, so you have to edit plugin.py manually

I also don't have time to check the whole code now so I don't want to patch the original melcloud_send_data function as it is used elsewhere. So copy the function melcloud_send_data as melcloud_send_data_json and change the content-type from application/x-www-form-urlencoded; to application/json;

def melcloud_send_data_json(self, url, values, state):
        self.melcloud_state = state
        if self.melcloud_key is not None:
            headers = {'Content-Type': 'application/json;',
                       'Host': self.melcloud_baseurl,
                       'User-Agent': 'Domoticz/1.0',
                       'X-MitsContextKey': self.melcloud_key}
            if state == "SET":
                self.melcloud_conn.Send({'Verb': 'POST', 'URL': url, 'Headers': headers, 'Data': values})
            else:
                self.melcloud_conn.Send({'Verb': 'GET', 'URL': url, 'Headers': headers, 'Data': values})
        else:
            headers = {'Content-Type': 'application/x-www-form-urlencoded;',
                       'Host': self.melcloud_baseurl,
                       'User-Agent': 'Domoticz/1.0'}
            self.melcloud_conn.Send({'Verb': 'POST', 'URL': url, 'Headers': headers, 'Data': values})
        return True

Then change melcloud_set as follows (you may keep the old code as melcloud_set_urlencoded just in case):

    def melcloud_set(self, unit, flag):
        post_fields = "'Power':{0},'DeviceID':{1},'OperationMode':{2},'SetTemperature':{3},'SetFanSpeed':{4},'VaneHorizontal':{5},'VaneVertical':{6},'EffectiveFlags':{7},'HasPendingCommand':true"
        post_fields = post_fields.format(str(unit['power']).lower(), unit['id'], unit['op_mode'], unit['set_temp'], unit['set_fan'], unit['vaneH'], unit['vaneV'], flag)
        Domoticz.Debug("SET COMMAND SEND {0}".format(post_fields))
        self.melcloud_send_data_json(self.melcloud_urls["set_unit"], "{"+post_fields+"}", "SET")

EDIT: it seems MELcloud is validating the json syntax so I had to make some changes (lowcase for power, single quotes)

@Patricen1
Copy link
Author

Hello,

I have tried but it does unfortunately not operate properly (maybe due to a bad paste from my side), see log below.

By the way, it looks like there is some knowledgeable people there, would it be possible improving the plugin using a setpoint type device for temp setpoint instead of a multi level switch?

Patrice

2022-02-01 16:02:27.805 Status: MELCloud: Initialized version 0.7.8, author 'gysmo'
2022-02-01 16:02:27.435 Error: (FindModule) Domoticz/DomoticzEx modules not found in interpreter.
2022-02-01 16:02:28.018 Error: MELCloud: 'onConnect' failed 'AttributeError':''BasePlugin' object has no attribute 'melcloud_send_data''.
2022-02-01 16:02:28.018 Error: MELCloud: Exception traceback:
2022-02-01 16:02:28.018 Error: MELCloud: ----> Line 538 in '/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py', function onConnect
2022-02-01 16:02:28.018 Error: MELCloud: ----> Line 149 in '/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py', function onConnect
2022-02-01 16:02:28.018 Error: MELCloud: ----> Line 437 in '/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py', function melcloud_login
2022-02-01 16:02:34.155 Status: User: Xxx (IP: xxx.xxx.xxx.xxx) initiated a switch command (621/MELCloud - Couloir - Mode/Set Level)
2022-02-01 16:02:34.198 Error: MELCloud: 'onCommand' failed 'TypeError':''bool' object does not support item assignment'.
2022-02-01 16:02:34.198 Error: MELCloud: Exception traceback:
2022-02-01 16:02:34.198 Error: MELCloud: ----> Line 550 in '/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py', function onCommand
2022-02-01 16:02:34.198 Error: MELCloud: ----> Line 299 in '/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py', function onCommand

@mitkodotcom
Copy link

Did you left the original melcloud_send_data function intact? You are supposed to copy it and then change the name and content type, leaving the original function as it is, because it is used elsewhere (during login process, for example).

You can probably make a script to synchronize the selector values with a setpoint.

@Patricen1
Copy link
Author

It looks like I did not catch something. Could you please share your plugin.py file? Thanks!

@mitkodotcom
Copy link

Here it is

plugin.zip

@stefstef2000
Copy link

Here it is

plugin.zip

Thanks !

@Xavier74
Copy link

Xavier74 commented Feb 2, 2022

When using the latest plugin version, I get others errors, like described in #24 and #22
I'm using latest stable domoticz version, v2021.1 build 14119).
Using plugin version 0.7.6 the problem is not present, the device I have is found but I continue getting the 500 error.
Using latest 0.7.7 with your proposed change on plugin.py or uploaded one, problem goes away but no device found in the building and error mentionned appires.
If anyone can explain it...

@mitkodotcom
Copy link

It's hard to say. Unfortunately the debug setting does not work so you have to uncomment Domoticz.Debugging(62) or Domoticz.Debugging(-1) in my file and restart.

Try not to use areas, only floors. Do not use any non-ascii characters in names.

@Xavier74
Copy link

Xavier74 commented Feb 3, 2022

  Many thanks, updating to floor instead of area and applying the new plugin.py worked :)

@herbod-nl
Copy link

Thanks for this fix. It made me able to controle the airco's with Domoticz again. I do get the errors below. Any idea how to solve these?

2022-02-05 21:00:58.239 Error: Airco: (Airco) 'onMessage' failed 'UnboundLocalError':'local variable 'setPicID' referenced before assignment'.
2022-02-05 21:00:58.239 Error: Airco: (Airco) ----> Line 570 in '/home/pi/domoticz/plugins/Melcloud/plugin.py', function onMessage
2022-02-05 21:00:58.239 Error: Airco: (Airco) ----> Line 255 in '/home/pi/domoticz/plugins/Melcloud/plugin.py', function onMessage
2022-02-05 21:00:58.239 Error: Airco: (Airco) ----> Line 520 in '/home/pi/domoticz/plugins/Melcloud/plugin.py', function domoticz_sync_switchs

@Paul-AUB
Copy link

The given file works for me (only tested on a standard use case start/stop) ! Thx a lot :)

Note the given file also includes the changes relative to #25, and I'm waiting to see if it crashed after some time or not (ongoing test, I'll let you know).

@nonolk
Copy link

nonolk commented Feb 20, 2022

As I was facing the same issue as several, I dig a bit in the plugin, and rewrote a bit the login function, to use json instead url-encoded logic. I also adapted the device discovery process to be able to discover my devices.

Here is the modified file:
plugin.py.zip

@Patricen1
Copy link
Author

As I was facing the same issue as several, I dig a bit in the plugin, and rewrote a bit the login function, to use json instead url-encoded logic. I also adapted the device discovery process to be able to discover my devices.

Here is the modified file: plugin.py.zip

I'll try this!
There are some things that looks strange to me regarding Melcloud.

  • it looks to me that the official Melcloud webapp is not reliable for holiday mode, did you experience this? The issue is that holiday mode does not deactivate scheduled on/off events).
  • since a couple of weeks, it looks to me that there is a temperature offset between setpoint and the real temperature of the room (Melcloud temp setpoint and readback are ok but temp measured in the room thanks to an independent thermometer is much higher).
  • finally, temperature setpoint is really not convenient using a multi level switch, but I'm not skilled with Python to be able modifying the switch with a setpoint device. Can somebody help with this?

Thanks!

@LOYK31
Copy link

LOYK31 commented Mar 12, 2022

Hello,

Thanks to @mitkodotcom for the quick fix, it worked well for me.
I was previously on version 0.7.6

Hope the plugin will be updated properly :)

@manolo75
Copy link

Hi,

I am facing the same issue :

2022-08-18 23:31:25.180 MelCloud clim: Set to Vent the unit Haut
2022-08-18 23:31:25.322 MelCloud clim: MELCloud receive unknonw message with error code 500
2022-08-18 23:31:25.373 MelCloud clim: MELCloud receive unknonw message with error code 500
2022-08-18 23:31:27.755 Status: User: Admin (IP: 192.168.1.4) initiated a switch command (1835/MelCloud clim - Haut - Mode/Set Level)
2022-08-18 23:31:27.787 MelCloud clim: onCommand called for Unit 8: Parameter 'Off', Level: 0
2022-08-18 23:31:27.787 MelCloud clim: Switch Off the unit Hautwith ID offset 7
2022-08-18 23:31:27.929 MelCloud clim: MELCloud receive unknonw message with error code 500

I tried several plugin.py, but still the same :(

@zajc3w
Copy link

zajc3w commented Sep 8, 2022

Thanks for this fix. It made me able to controle the airco's with Domoticz again. I do get the errors below. Any idea how to solve these?

2022-02-05 21:00:58.239 Error: Airco: (Airco) 'onMessage' failed 'UnboundLocalError':'local variable 'setPicID' referenced before assignment'. 2022-02-05 21:00:58.239 Error: Airco: (Airco) ----> Line 570 in '/home/pi/domoticz/plugins/Melcloud/plugin.py', function onMessage 2022-02-05 21:00:58.239 Error: Airco: (Airco) ----> Line 255 in '/home/pi/domoticz/plugins/Melcloud/plugin.py', function onMessage 2022-02-05 21:00:58.239 Error: Airco: (Airco) ----> Line 520 in '/home/pi/domoticz/plugins/Melcloud/plugin.py', function domoticz_sync_switchs

did you fix it? mine starting doing the same thing after 2 days of running...

@Jcasval
Copy link

Jcasval commented Jan 14, 2023

Gracias Patricen1, gracias a tu archivo todo funciona a la perfección.

@dalonsic
Copy link

dalonsic commented Nov 5, 2023

Hello,

Today, I tried to solve a hearbeat problem with a rewrite of the heartbeat management.
I implemented a parameter to choose the interval.
I also implemented multilingual support with the MELCloud app.

Thanks for correcting error code 500 ;)

Have fun ;)

EDIT : after few fixes... v0.8.2 based on Nonolk version :
plugin.py.0.8.2.zip

EDIT : and v0.8.3 based on Mitkodotcom version :
plugin.py.0.8.3.zip

Dalonsic.

@manjh
Copy link

manjh commented Nov 5, 2024

I'm afraid none of the solutions work for me. When I try the latest plugin.py in the post above, it gives me a lot of syntax errors:
2024-11-05 17:22:24.074 Error: Airco: ValueError: invalid literal for int() with base 10: ''
2024-11-05 17:22:26.170 R-Pi sensors: Temp (Internal Temperature)
2024-11-05 17:22:26.178 R-Pi sensors: General/Percentage (CPU_Usage)
2024-11-05 17:22:34.090 Error: Airco: Call to function 'onHeartbeat' failed, exception details:
2024-11-05 17:22:34.092 Error: Airco: Traceback (most recent call last):
2024-11-05 17:22:34.092 Error: Airco: File "/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py", line 656, in onHeartbeat
2024-11-05 17:22:34.092 Error: Airco: _plugin.onHeartbeat()
2024-11-05 17:22:34.092 Error: Airco: File "/home/pi/domoticz/plugins/domoticz-python-melcloud/plugin.py", line 440, in onHeartbeat
2024-11-05 17:22:34.092 Error: Airco: self.runCounter = int(Parameters['Mode2'])

Any chance of a proper cleanup on the plugin?

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