Change schedules/rules with REST

Support questions for server and client (Windows, iPhone, Android, Linux)
Post Reply
cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Change schedules/rules with REST

Post by cyberde » Wed 25 Sep 2013, 12:02

Hi,

I was wondering if there is a way to change rules in a schedule using the rest service.
The reason I'm asking is that I am building an interface to control the whole home and this also includes the central heating. Which has a couple of rules (outside temp < 16 degrees + inside temp < 20 degrees). What I would like to do is to be able to change the 20 degrees to something else through my own gui (using the rest client).

Aslo, in a future release will it also be possible to have combined rules so you can use OR and AND instead just OR or AND?
Are there any noticable changes coming to a new release? If so, when is this planned?

Cheers!

Martin
Administrator
Administrator
Posts: 2655
Joined: Tue 09 Nov 2010, 20:25

Re: Change schedules/rules with REST

Post by Martin » Wed 25 Sep 2013, 13:32

First of all - a disclaimer :)
Switch King is not intended to be used for critical functions, such as water, heating etc. The protocols supported by TellStick Classic/Duo/Net are one way protocols, meaning that you will not get an acknowledge that the receiving device has got your message. If - for example - one was to connect device supported by Classic/Duo/Net to a heating unit to make sure that your pipies do not freeze, your status in Switch King could show "On" for the heater even though the heater is actually off since there is no way to know that the heater got the request to turn itself "On" or "Off". Therefore, we strongly recommend using Switch King and TellStick Classic/Duo/Net to non-critical devices.
Now, on to Q&A.

It is not possible to change rules in a schedule using the REST service. The intented use of the REST service as it is today is only to be able to check the status of your installation/home, to send commands to your devices, to start/stop scenarios and to get information about your data sources and their values.
If Switch King were to move to a cloud based service, the REST service (propably being switched to JSON) would possibliy be extended to add support for configuring the system, which is really what you are after. This is, however, nothing we have planned for in the near future.

However, you could actually make a call to the WCF service instead of the REST service. Since the Windows client is using the WCF service to configure the system, all operations are available through WCF. If you work in, for example PHP, you would need to do some explorations in order to see exactly how this call would look like since PHP does not support resolving WCF contracts and calls directly. The WCF contract is also a candidate for change in a future version - we consider the WCF contracts our own domain, while plugins are using REST, hence we are restricted in the type of changes we can make to the service without pulling away the carpet for existing plugins.

The logical operations AND/OR are actually both supported by the server, and you can build a chain of logical operators:

Code: Select all

(X = 1 AND Y = 2) OR (X = 1 AND (Y > 20 AND Y < 100))
We have chosen not to support configuring these kind of logical chains in the client due to that it is quite hard to visualise this in an understandable way.
We have not yet discussed whether to improve this in Switch King v4.

About changes in Switch King v4 - yes there are changes. The server is basically rewritten to be better future-proof, the noticable changes in added functionality will be few in the first version with the new code under the hood, but the changes also makes it easier to add functionality under the hood in the future. The focus is on performance, handling of Telldus Service failures, support for hardware other than Telldus hardware and also removing some of the obstacles that exists and causes problems when running Switch King in Linux environment.
Martin | Switch King

cyberde
3 stars
3 stars
Posts: 61
Joined: Thu 11 Apr 2013, 08:00
Location: The Netherlands
Contact:

Re: Change schedules/rules with REST

Post by cyberde » Wed 25 Sep 2013, 14:06

Thanks for the heads up with the disclaimer :) I'm using it for turning on and off the heater, using a relay as an oltime temperature "switch". I chose to sync this device every 15 minutes to ensure it gets on, and if not. I'll be cold and know it didn't work haha.

Also thanks for the really elaborate explanation on the REST and WCF service, I'll have a look to see if I can mess around with that one (knowing it will probably be changed with the new version). Keeps me busy ;-)

You say these logical (AND/OR) operations are available on the server, how do I enter those outside the GUI? I know it's very difficult visualizing those in any kind of software but I think it's a very common wish of the community, especially those like me who like to automate there whole house. *crosses fingers*

I'm looking forward to v4, changes sound very good! Any idea on when it's ready? If you need any beta testers, just let me know, I'm happy to test it thoroughly.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests