BobRak / OpenHAB-Smartthings

53 stars 54 forks source link

Valve not being handled correctly by OpenHAB #59

Closed bjhiltbrand closed 5 years ago

bjhiltbrand commented 5 years ago

Hello, I have a couple water shut-off valves that I have setup in OpenHAB, but when I go to open or close them in OpenHAB, I get a 400 error as a bad request. The error in the logs is:

2018-12-22` 21:56:02.361 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/WaterShutoffValve' with an invalid status value 'closed'.

The relevant line in my .things file is:

Thing valve waterShutoffValve [ smartthingsName="LeakSmart Valve" ]

And the relevant line in my .items file is:

Switch WaterShutoffValve "Water Shutoff Valve" {channel="smartthings:valve:HiltbrandHome:waterShutoffValve:valve"}

I realize that the items file has this valve listed as a switch, but I think that is my only option, as OpenHAB doesn't have a valve item type. I think the issue here is that OpenHAB requires that a switch only pass values of 'ON' or 'OFF'. I'm pretty sure that is where the error in the logs is coming from.

On the flip side, however, SmartThings will still require a value of 'open' or 'closed', as that is what the SmartThings capabilities spec state for a valve capability. I'm not very well-versed in git, so that's why I'm posting the issue here.

BobRak commented 5 years ago

Hi @bjhiltbrand Thanks for your feedback. This is very helpful as I try to get this finished and ready to submit to openHAB to be included as a standard binding.

I have been looking into this today and will work on some changes that I think will make it work better. Give me a couple of days.

Three questions:

  1. It looks like you are configuring with files, is that correct.?
  2. Do you want openHAB to be able to control the valve or only return it's status?
  3. What is the actual valve you are controlling?

    Thanks,

Bob

bjhiltbrand commented 5 years ago

@BobRak, Awesome! Thanks. To answer your questions:

  1. Yes, I prefer files, as the UI is no where near as configurable as files.
  2. I would like to do both. I have a couple water sensors through Roost, that I can run through IFTTT to talk to OpenHAB when they sense water. Then OpenHAB can relay the shutoff trigger to SmartThings.
  3. I have a number of valves that I am testing for work right now. They all behave the same way. I have tested the EcoNet EB105, the EcoNet Bulldog (EVC200), the Dome Water Shutoff, and the LeakSmart/Waxman Water Shutoff. The logs and configuration files I shared were for the LeakSmart.

Side note: I am developing a new automation for work (Insurance company that will be using sensors and shutoff valves to help mitigate water losses). We are developing it using the new SmartThings developer workspace, which is a little different that the old IDE. Do you have any plans to migrate this app to the new workspace, or is it more of a "cross that bridge when the time comes" sort of thing?

Thank you for all your help.

BobRak commented 5 years ago

Hi @bjhiltbrand I just uploaded a new jar file. I made some changes to the valve definition. It is now only defined as a string. The trick to being able to turn it on and off is making the item look like:

String WaterShutoffValve "Water Shutoff Valve [%s]" {channel="smartthings:valve:HiltbrandHome:waterShutoffValve:valve"}

And then make the .sitemap entry look like:

Switch item=WaterShutoffValve mappings=[open="Open", closed="Close"]

The mapping tells the UI to send a response of open or closed and buttons are displayed instead of the switch. Also, the [%s] in the item definition causes the UI to display the current status.

Let me know if this solves things or not. I'll do whatever is necessary to make it work for you.

There were no changes to the Smartthings files so no need to reinstall them.

I haven't tried to do anything with the new Smartthing developers tools although I have done some reading about them. I'll look at that in more depth when time permits. I started with the old IDE.

I've started thinking about getting this included as part of OpenHAB and have come to realize that I'll have to make the Smartthings files available some how. I suspect the best way to do this is to get Smartthings to publish them. So, I'll start looking at that soon.

Please let me know how it goes.

Bob

bjhiltbrand commented 5 years ago

@BobRak, Worked like a charm! Thank you. I was unaware of the mappings option in OpenHAB sitemaps. That's pretty slick!

Correct me if I'm wrong, but I think the way the new SmartThings stuff works is that you have to run your own node js servlet to send json payloads back and forth to the Samsung Connect cloud. I don't know if OpenHAB could host the servlet to work with the new Samsung stuff, so that you don't have to play middle man for the rest of your life. That's the assumption I'm working under at work, and we've developed our app to run this way, where we just push around json payloads all day long, but I don't know if that's something you want to do for this binding.

Anyway, Thank you so much for your help on this. Let me know if you have any other scenarios you want me to test. I have a fairly robust SmartThings ecosystem.

BobRak commented 5 years ago

@bjhiltbrand Glad the valve now works correctly.

I haven't looked at the new Smartthings environment close enough to know what is needed to work with it. I'll have to look at it down the road, when time permits.

Right now I think all of the things I've tested or have gotten feedback on work as they should. If you come across any devices that you don't think work the way they should please let me know.

Thanks,

Bob