Raspberry Pi Codesys Project

Hi Patrick,

So I have tested using the live log info from my smart things IDE:

I’m sure all info I have is correct. See below: Live Logging Data from open dash which includes the uuid and token.

Corresponding info is entered into the HTTP Client. Here using Hurl it.

Finally the response giving me a bad token error. Could the test token generated in the smart app be invalid?.

I’m so close and eager to start this project but without device data I’m nowhere.

Thanks again.

your headers look wrong…

should be two lines, autherization (sp?) and then value of Bearer
and second line should be “access_token” (or however it is in the logging url with a value of the token.

I think…

Finally got it working with a response from lots of end points. I didn’t use the header at all and just used the full test URL adding the end points before the token.

Brought this is to my PLC HTTP client and no response however. Looks like it doesn’t support JSON. I’ve found an additional json library for this platform but it costs €90 to buy!.

http://store.codesys.com/json-http-client-library.html

Shame the standard HTTP client doesn’t work when I get responses from the multiple free clients online.

You could modify the API to return whatever you want. Beauty of open source.

Ok. This would be perfect. My client on the PLC side is expecting a string to be returned.

This is my first time having to modify any groovy code so I’m trying to give myself a crash course.

Just looking at the API code itself it seems I need to make the modification to the data conversion and change it from prettystring?.

Also in the content type remove the /json and only leave text?.

Does this make sense or am I way off?. I’m endevaouring to keep researching so any help is much appreciated.

Frankly don’t know. But it’s probably application/text. And converting the JSON to string is pretty easy.

So I think you are on the right track. Just look up the mime type you want to be sent.

So ive messed with the content type and returned application/json and html/text to no avail.

Digging a little deeper it looks like my client wont even begin to send the request. It doesn’t return anything
Seems that the port portion of the URL is causing the issue. My test URL contains :443: Below.

If I remove this and make the request for the first time I get a response as below:

I’m trying to figure out why this would be. If I remove the :443 and send the request through the hurl it HTTP client I do get a correct response however. Confused.

Whats the real significance of that port number :443?. I’m not giving up until I solve this! :slight_smile:

A couple of web client libraries later and I now have the data passing to my plc application:) Extracting the status values from the responses and transferring to variables is my next task.

With regard to the API, I’m trying to determine the most efficient way to update the data. Obviously I want the quickest response to a change in any device. Is there a limit or recomendations on the rate of polling for this smart app?

Project is going very well but I’m running into a rate limit issue every minute or so.

I’m polling a lot and need to look into a more efficient way of doing it.

Any tips on polling rates? Real time data is my goal here but the more devices I add the more I will run into this rate limit issue.

Hi All.

Its been just over a year since I’ve started this project and I’m finally at the stage where I have a fully working home HMI fully integrated with Smarthings and more.

Huge thanks to pstuart and Open-Dash for providing the foundation on which I have built the project. Making an API work in a PLC environment was a challenge for me, interrogating a 25,000 + string for device data but its now working perfectly.

Some Screens:
Main Screen & Codesys Environment

Heating Screen

Diagnostics Screen

Automations Screen

I’m also talking to LANnouncer over direct TCP and can announce any alarms, strings or any string I write on the PLC all over the house.

Ive mainly focused on the heating and diagnostics screens and everything else is a work in progress.
Next Stage is a 3D model of the house to show status of lights, motion etc… Full Smappee energy monitoring is also in the works. I’m using the Smappee API separately for this.

My main screen is a firetab HD 8. Its perfect and I’m using 2. Below image of the main hall panel.

Both of these are also LANnouncer TCP servers along with another server on a sideloaded Firestick.

All in all I’m really happy with the way this is moving and look forward to developing the rest of the screens and functionality.

Thanks again to Open Dash API for making this possible.

1 Like

Hi all,

Been a while since ive updated on this thread. I’ve been using Open Dash since the start of my project to great success. Even though the open Dash API smart app has not been updated in a long time it still provides everything that I need up to now.

As my project is evolving I am adding more and more devices. The more devices add the slower the Open Dash API responds from the “allDevices” endpoint. The poll time now can be 5 to 6 seconds or longer.

This is becoming a problem because I use my application for all automations (i dont use webcore or handle any automations in Smart things). Therefore I rely on the ability for the Open Dash Api to update the status of all my devices as quickly as possible.

Im thinking now that my only possibility is to go to a new web services api smart app using a webhook based approach. This is very new territory for me as I have not yet written any smart app and have used Open dash to provide me with everything that I need.

I know Patrick Stuart is not active on these forums any more so Im wondering is there anyone that can put me in the right direction for a transition into a new web services smart app that ultimately will provide everything that open dash has with either a web hook approach or faster return from an “allDevices” type of endpoint.

Any help would be much appreciated on this.

Thanks all.

1 Like

Patrick now works for Hubitat, a competing HA platform

You may want to look at HousePanel as it’s based on OpenDash as well. I personally don’t use it, but thought I would point you there in case it may help solve your issue:

1 Like

Thanks for the reply.

I have already reached out to Ken in House Panel regarding polling but this also wont solve my problem.

I’m continuing to look at the new ST API docs regardless to see if I can make sense of developing this myself.

Sorry I couldn’t help. I didn’t follow what you were trying to do. Any polling makes a web query to the SmartThings cloud so there is a limit to how fast this can go. HousePanel provides a query to all devices on a frequency that you specify. In my experience this can’t be more frequent than once every 30 seconds or so.

Hi Araforn. Sorry I don’t have an answer for you but I am also a Codesys Developer though I think less skilled than you.

I was wondering if you would be willing to share your codesys files?

Also, honestly if you had a project for sale on the Codesys Store that sold integration with SmartThings I would consider paying for it depending on how easy it was to use and how powerful it was. If it gave me access to control things like smart lights through SmartThings I would definitely be able to convince my bosses to pay for it. I do custom automation for agriculture in particular the Dairy industry. But also some HVAC systems.

Hello Morberis.

Welcome to the community. At last another codesys developer on a Smart things forum! :).

I’m currently redeveloping my entire interface with Smart things. Going down the new ST API route with my own Smart App. I’ve made some really great progress since I’ve last posted in this thread although I’ve come across a major stumbling block at the moment with subscriptions. See my posts here: Smart App Multiple Device Subscriptions.

I’m also working on a library that I hope to bring to the codesys store at some stage but I need a lot of development to make this modular for users other than just me. I will let you know when this will be ready.

My project now has become very specific to my use case over the last 2 years but regardless the key requirement is a hosted Smart App running on a server. Mine runs on a raspberry pi. This then “streams event information” using a webhook via an OPC server to my codesys/PLC application. Therefore any integration would need a connection from an internet connected server to your application. Mostly very different to the automation I work with in industry with Codesys.

To me though, codesys is the perfect environment for an automation engineer/developer to bridge the gap to home automation using the Smart things API. Below is some more functionality I’ve added over the past couple of months.

Example of Downstairs Control

Some Heating Analysis

Integrated SHM Alarm Delay/CountDown Handler

Separate Integration to Smappee Power (Polls Power/Current Every 3 minutes, Consumption every hour)

2 Likes

Very interesting. It definitely looks like a codesys visualization lol. The data tracking is really intriguing especially with the amount of devices that seem to have temp sensors in them. It would really let you observe trends when running your houses HVAC and allow you to customize and tweak the operation of things. Plus I would trust Codesys to run my HVAC system for a decade, but I wouldn’t trust Samsung Smart things.

It would also be great to setup info from various communication bus’s like RS485 to trigger automation. For instance if my automated plant watering system runs low on something flash some of my RGB dining room lights.

Have you done alot of Codesys with the Pi before? I’ve done very little but I’ve been doing alot of research but I don’t want to bother you if you already know some of the pitfalls.

Have you tried using anything PID yet in your house? Definitely something you couldn’t do with just Smart Things. If you have analogue control somewhere that is. I recently did a building that was heated by a large radiator with an analogue water mixing valve. PID worked real great for that to optimize energy usage. You might be able to use the self-tuning PID system off of the Codesys forums just since the cycle times for heating and cooling a building can be so large.

I’ll definitely be watching this space to see what you end up doing.

Things have moved along with Codesys and projects like this.

Have you thought about making a project page for this at the Codesys Forge?

https://forge.codesys.com/

I’ve since rewrote all the development of this using MQTT which entirely allows all feedback now in real time.

I’ve never used Codesys forge.

1 Like

Nice, congrats.

The forge is nice. There are a lot of projects there that you might find helpful. Though maybe not on this project. I feel like this iteration of the forum also has more activity. Though I might be bias’d because I’m spending time there -trying- to help people with questions.

Which MQTT library did you end up using?