Local Files in Rule 4.0

Apps have always been able to serve whatever content they want via local or cloud OAuth endpoints, including complete HTML pages. For a Dashboard, you'd quite likely need the dynamic capabilities and closer interaction with the platform (e.g., ability to see selected device states) that an app would provide, compared to just hosting an HTML file on the hub itself. If you're thinking of things like HousePanel, this feature really won't help there (unless there's more to this file storage that we aren't being told about) because it relies on PHP for some of the dynamic capabilities like talking to Hubitat--not just a "static" HTML file or HTML with JavaScript and whatnot. HP could be re-done as a Hubitat app, with the app doing the "talking to Hubitat" part and local files (from Hubitat or elsewhere) serving JS/CSS/images/etc, as needed, but that would be quite a design change.

But for something with more hope: consider Hubigraphs. Nothing like this is possible here as-is because it uses Google Charts, which Google requires you to use their cloud option for and does not provide any local capability, but let's pretend we're in an alternate world where it uses an alternate library like Charts.js instead. This library could be hosted by the hub instead of needing the cloud library (and without going through the excessive work of trying to format the JS code to some sort of Groovy string that could be embedded in your app's output...something that I guess has always been theoretically possible, just nearly impossible from a practical perspective since you'd have to embed the library in every page served).

4 Likes

Like use it logging almost infinite hub log, not just couple last hundreds of records

Up to 1GB

Take a look at this:

It may be of some use in this regard.

Marco

I think you're crossing the point where writing an app is the better tool. RM is great, but it's not designed to be a general purpose programming language. If you haven't already, it's probably time to start looking into groovy apps if you feel the need to parse JSON for your rules.

1 Like

"Now all I need is some way to send email via my SMTP provider from the HE, and I'll have zero dependencies."

If you happen to have a RPI online, you can do this with this approach:

I have to dig, there is a Linux command line tool that sends email. I wonder if it would work.

I need to look it up again.

Yeah I saw that approach. I don't have a RPi (not that it would be difficult to set one up), but I do have a NAS that I can send commands to with Telnet. That's what I do now, and my emails go via curl on my NAS to my SMTP server. I could do something similar on a RPi, too, or set up Node/sendmail on my NAS.

What I want to do is get rid of the Telnet, and send SMTP (over SSL/TLS) from the HE.

curl

Kind like:

echo 'To: ${emlTo}\nSubject: ${emlSubject}\nFrom: ${emlFrom}\nContent-Type: text/plain;\n${state.EmailBody}' | curl --url 'smtps://${emlServer}:${emlPort}' --ssl-reqd --mail-from '${emlFrom}' ${mailRcpts}--upload-file '-' --user '${emlUsername}:${emlPassword}'

Here's a really ugly hack of some things that use Telnet to run curl, which sends the email:

I'd like this too. Heck, my printer can send email using SMTP via my google.com account, so it shouldn't be too high a workload for the hub to send email.

Yes, you can cobble together a solution with a raspberry pi, but it's easy to make security mistakes. And black hats just love open mail relays.

So can we use local files to store cookies from an http get/post and then send that cookie with a subsequent http get post?

There are tons of small thing I could do with RM provided I can logon and get a cookie first.

I don't think so. I don't believe RM is going to let you grab a header value like that. You also don't need a file for this, I think a variable is probably the better storage mechanism. Either way, I think an App is probably what you want here which can definitely do what you're saying (and store it in a variable, apps don't support files)

Im just trying to avoid learning groovy

Understood. Unfortunately though, while RM is powerful, it's not a replacement for a full featured programming language. So while you can make a call to an HTTP endpoint, you can't really parse the results out to pull out a specific cookie out of a header like that.

Is there anyway to call a binary if I upload it to the hub ?

What do you mean by a binary? An exe file? An image? If you just go to the URL of the file it will open/download

Binary/Executable

Yes it will let you upload an exe. You could then download it by clicking the link to the /local/ folder, Is that what you're asking?

No, I'm wondering if you can execute it from groovy or rule machine?

No. The Hubitat isn't even a Windows machine, there is no way for it to run an EXE. Further that would be a very bad thing. It would be a HUGE security hole.

1 Like