SUPLA Scripts

User avatar
fracz
Posts: 2342
Joined: Fri Oct 28, 2016 10:56 pm
Location: Kraków
Has thanked: 4 times
Been thanked: 6 times

Post

Możecie czekać aktywnie, polecam :-D http://php.net/manual/pl/index.php
tgaweda
Posts: 101
Joined: Mon Nov 13, 2017 9:21 pm

Post

Cześć. Mój pierwszy post na tym forum choć śledzę go już od jakiegoś czasu budując po woli swoją infrastrukturę domu inteligentnego wokół supla.org.

Ostatnio wpadłem na pomysł wyświetlania na nodemcu (esp8266 z wyświetlaczem) danych (np. temperatury) z innych urządzeń we/wy pozyskanych za pomocą adresu publicznego ze sceny zdefiniowanej na supla.fracz.com. Stworzyłem takie IDE

Code: Select all

#include <ESP8266WiFi.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

const char* ssid     = "siec";
const char* password = "haslo";
const char* host = "supla.fracz.com";

void setup() {
  Serial.begin(115200);
  delay(10);

  lcd.begin();
  lcd.backlight(); 
  lcd.setCursor(0, 0);

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");  
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

int value = 0;

void loop() {
  delay(5000);
  ++value;

  Serial.print("connecting to ");
  Serial.println(host);

  WiFiClient client;
  const int httpPort = 80;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }

  String url = "/api/scenes/public/reszta-adresu-publicznego-sceny";
 
  Serial.print("Requesting URL: ");
  Serial.println(url);

  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");
  
  delay(10);

  Serial.println("Respond:");
  while(client.available()){
  String line = client.readStringUntil('\r');
  Serial.print(line);
  lcd.clear();
  lcd.setCursor(0,0);  
  lcd.print("");
  lcd.print(line);
    }

  Serial.println();
  Serial.println("closing connection");
Jako wynik otrzymuję niestety:

Code: Select all

Respond:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.13.5
Date: Mon, 13 Nov 2017 21:32:36 GMT
Content-Type: text/html
Content-Length: 185
Connection: close
Location: https://supla.fracz.com/api/scenes/public/reszta-adresu-publicznego-sceny

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.13.5</center>
</body>
</html>
Co robię źle?
Last edited by tgaweda on Mon Nov 13, 2017 9:52 pm, edited 1 time in total.
User avatar
fracz
Posts: 2342
Joined: Fri Oct 28, 2016 10:56 pm
Location: Kraków
Has thanked: 4 times
Been thanked: 6 times

Post

Z supla.fracz.com należy komunikować się po https. Co więcej, jest tam włączone HSTS, dlatego wsyzstkie żądania http są przekierowywane na https - o czym informuje Cię odpowiedź.

Musisz użyć protokołu https i komunikować się po porcie 443 a nie 80.
tgaweda
Posts: 101
Joined: Mon Nov 13, 2017 9:21 pm

Post

Poszło! Dziękuję za wskazówki.
Neavvy
Posts: 64
Joined: Thu May 11, 2017 8:19 pm

Post

Mam wgrany na esp soft EgyIot, przez który kontroluję taśmę RGB i zauważyłem że skrypty nie potrafią sterować tym urządzeniem, mogę tylko odczytać stan taśmy. W skryptach urządzenie figuruje jako "undefined". Załączam screena jak to wygląda:
You do not have the required permissions to view the files attached to this post.
User avatar
fracz
Posts: 2342
Joined: Fri Oct 28, 2016 10:56 pm
Location: Kraków
Has thanked: 4 times
Been thanked: 6 times

Post

Wrzuć screen z Clouda, ze strony urządzenia. Chodzi mi o kwadracik z kanałem który odpowiada za tą taśmę z którą jest problem.
Neavvy
Posts: 64
Joined: Thu May 11, 2017 8:19 pm

Post

Proszę:
You do not have the required permissions to view the files attached to this post.
Last edited by Neavvy on Wed Nov 15, 2017 5:40 pm, edited 1 time in total.
User avatar
pzygmunt
Posts: 20302
Joined: Tue Jan 19, 2016 9:26 am
Location: Paczków
Been thanked: 59 times

Post

Neavvy wrote: Wed Nov 15, 2017 5:26 pmProszę:
Rozdajesz hasła
SUPLA.... Nareszcie w domu.
Neavvy
Posts: 64
Joined: Thu May 11, 2017 8:19 pm

Post

Fakt, w ferworze zapomniałem, że znajdują się tam hasła, dzięki za uwagę
Neavvy
Posts: 64
Joined: Thu May 11, 2017 8:19 pm

Post

Podbijam temat, próbowałem z innymi softami I na nich wszystko dziala, jednak najbardziej pasuje mi EgyIOT, więc byłbym bardzo wdzięczny za jakąś poradę :D

Return to “SUPLA Scripts”