SebastianOsinski / HomebridgePluginSamsungAirConditioner

Homebridge plugin for controlling Samsung Air Conditioners working on port 2878
MIT License
29 stars 18 forks source link

Home app shows heating mode as cooling #5

Closed jadomski closed 5 years ago

jadomski commented 6 years ago

I have found that when I enable heat mode, the tile on the Home app reports 'Cooling to Xº'. Cool mode correctly shows as 'Cooling to Xº'.

It appears to report the same incorrect information in the Home app even when using the remote to turn on the heating mode.

SebastianOsinski commented 6 years ago

@iJaffa Thanks for reaching out! I'm aware of this bug, it's on my TODO list :). I plan to do some rewrite of this plugin which will improve it's response time and also should help to fix this issue

jadomski commented 6 years ago

Sounds good, @SebastianOsinski. I'm very grateful for the work you're doing on this plugin. I just wish I had the time to contribute more to it!

peros550 commented 6 years ago

Hi Sebastian,

Does your updated code published today include optimizations for quicker response times ?

SebastianOsinski commented 6 years ago

@peros550 Not yet, I'm working on it right now :) Should take couple more days to test it and cover some edge cases.

SebastianOsinski commented 6 years ago

@iJaffa @peros550 Would you like to be beta testers for new version? It's available as PR now #11. You can install it by running sudo npm install -g --unsafe-perm github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#feature/v2 as root user (at least that's why I had to do on my Raspberry Pi). For some reason installing from GitHub branches needs elevated permissions.

peros550 commented 6 years ago

I ‘ll try and let you know :)

peros550 commented 6 years ago

Quick update: The plugin became very responsive! You did some very good optimizations there! The whole Homebridge became more responsive for me as well.

Tried unplugging the A/C from the mains, plugged in back: all good.

I tested the bug where messages (between heating/cooling) got messed so you may have set a heating mode and the home app was saying "cooling to X degrees", all good here.

In all my tests I was messing around with Home app, changing values, modes etc and was looking at Samsung app to see what was the outcome and if the both apps were in sync.

Here is a small issue I found.

It seems that the A/C tends to remember what was the last used target temperature on every mode and selects it automatically the moment you switch modes. This makes an out of sync situation between Home and A/C.

Here is what you can do to reproduce the issue: Let's say that we use the A/C and set a target temperature for Cooling mode at 20C. Then we switch back to Heating mode and set a target temperature at 27C. All the previous actions could be handled by the remote or the Samsung App, it doesn't matter.

Now we switch to the Home App. Let's say we set a heating mode and then select a new target temperature at i.e. 25C. Here is the thing. If you now switch the mode to Cooling, the home app will continue showing the previous temp set within Home for heating (25C as per this example) , however if you go back at the Samsung app and check , it will show you a different temp which is the one it remembers for the Cooling mode.

Of course, the moment you try to set a new temperature, the A/C and the Home app will get synced again!

Overall a very good update though! Thank you!

SebastianOsinski commented 6 years ago

@peros550 I checked the problem you described and I was able to reproduce it, but it seems like a bug of Samsung's app. AC has only one setting for setting target temperature - AC_FUN_TEMPSET. It doesn't have separate temperature settings for different modes. When mode is changed in Samsung's app, it sends command to change mode and command to change temperature to be appropriate for given mode (lower than current for cool, higher than current for heat). When we change mode in Home app, Samsung's app receives update about mode change, but no update about temperature (as it wasn't changed, I didn't want to implement changing temp. along with mode. Might do in the future, bu it isn't crucial for me right now), so it for some reason thinks that target temp. is the one it set. You can check that Samsung app shows incorrect state by restarting it (or just going back to ACs list in the app and entering AC again). It will fetch full AC state again and you'll see it's the same as Home app shows.

peros550 commented 6 years ago

Yes you are right. This is a bug at Samsung's side. Have a nice day!

jadomski commented 6 years ago

@SebastianOsinski I’ll install the beta and will let you know how it goes

jadomski commented 6 years ago

@SebastianOsinski The beta is indeed much faster. One thing I have noticed is that it is not reading the current in-room temperature from the AC unit. Is this expected with this version?

SebastianOsinski commented 6 years ago

@iJaffa It should work as before (It works on my device). Does it display any in-room temperature, even invalid one or is there -- instead of temp in Home app?

This version is much faster because once it fetches data from AC, it stores it locally and each time Home app asks for data, the data is immediately returned, without asking AC for it. Each time something on AC changes, e.g. when remote is used or in-door temp has changed, AC sends update to plugin which stores it and sends it to Home app.

One more question to both of you @iJaffa @peros550. Have you noticed in Homebridge logs constant disconnections from AC? In my case, plugin disconnects every 1-2h with either ETIMEDOUT or EHOSTUNREACH errors. It's either something with the plugin itself or with my setup (I suspect my RPi has faulty WiFi). I made some changes in the plugin, which makes it react to disconnections much faster (by default, socket created with Node JS notices disconnections after several minutes instead of seconds). This might also be the reason for that.

jadomski commented 6 years ago

@SebastianOsinski After some observation, it appears to show the measured temperature from the last time which the Air Conditioner was running. I think that the A/C unit itself is caching the temperature value, since it appears to be consistent with the Samsung app as well.

I must say, the response time from the updated plugin is much faster, and it appears to be much more stable than the release build as well (always reports back, release build stops reporting back after a day or two).

I don't see any disconnections in my logs, but I don't have debug logging enabled. How can I check whether there are any disconnections or timeouts?

peros550 commented 6 years ago

Hi Sebastian, I don't have a Putty connected to my RPi constantly. Is it possible to search logs instead? Usually I run the following command: "sudo journalctl -u homebridge.service -f" and get logs in real time. If there is any way to search logs created in the past while my PC was not connected to the RPi then let me know.

Thanks

SebastianOsinski commented 6 years ago

@iJaffa If you don't see any disconnections in logs, then it's OK. They show by default, which means you don't experience any.

@peros550 You can check previous logs by running "sudo journalctl -u homebridge.service -n 100". This will print last 100 lines of log.

I migrated my whole homebridge setup to RPi 3 connected with ethernet cable and I still experience disconnections, sometimes they are permanent and only turning on the AC with remote fixes it. I have some idea what might be the culprit and will investigate more

peros550 commented 6 years ago

I just checked my logs. Thanks for the Tip! It looks that I got the following lines a few times:

Nov 04 08:44:16 raspberrypi homebridge[279]: [2018-11-4 08:44:16] [Air Conditioner] Error occured: connect EHOSTUNREACH 192.168.177.60:2878
Nov 04 08:44:16 raspberrypi homebridge[279]: [2018-11-4 08:44:16] [Air Conditioner] Connection closed because error occured
Nov 04 08:44:16 raspberrypi homebridge[279]: [2018-11-4 08:44:16] [Air Conditioner] Trying to reconnect in 5s...

but that was intentional because I had reset my router. I did not have any other disconnections found on the Logs similar to the above.

By the way here is a nice command which searched my log since the beginning for a given text:

sudo journalctl -u homebridge.service | grep -i 'Air C'

peros550 commented 6 years ago

Sorry, somehow I messed the order of the messages. My response to you Sebastian after searching the los is a few messages above

stalkerj commented 6 years ago

How can i install beta?

SebastianOsinski commented 6 years ago

@stalkerj This post explains it: https://github.com/SebastianOsinski/HomebridgePluginSamsungAirConditioner/issues/5#issuecomment-433532032. To run commands as root user on Raspberry Pi you need to type sudo su. Then you can use command mentioned in that post

stalkerj commented 6 years ago

@stalkerj This post explains it: #5 (comment). To run commands as root user on Raspberry Pi you need to type sudo su. Then you can use command mentioned in that post

npm ERR! fatal: could not create leading directories of '/root/.npm/_cacache/tmp/git-clone-515d1480': Permission denied

SebastianOsinski commented 6 years ago

This error shouldn't occur if you run sudo su and then sudo npm install -g --unsafe-perm github:SebastianOsinski/HomebridgePluginSamsungAirConditioner#feature/v2. This combo gives you basically all permissions available.

SebastianOsinski commented 5 years ago

Fixed in #11