removed archaic info related to JSON bugs and translations in versions pre 5.something

jziolkowski 2019-09-24 16:05:55 +02:00
parent 63f7220062
commit 958ec90b53
1 changed files with 1 additions and 191 deletions

@ -13,8 +13,6 @@
- [SHT3X (and DHT11, multiple Sensor example)](#sht3x-and-dht11-multiple-sensor-example) - [SHT3X (and DHT11, multiple Sensor example)](#sht3x-and-dht11-multiple-sensor-example)
- [Sonoff SC](#sonoff-sc) - [Sonoff SC](#sonoff-sc)
- [PMS5003 and HTU21](#pms5003-and-htu21) - [PMS5003 and HTU21](#pms5003-and-htu21)
- [Bugged JSON in <= 5.10.0 (invalid JSON)](#bugged-json-in--5100-invalid-json)
- [PHP Fix for invalid JSON <= 5.10.0](#php-fix-for-invalid-json--5100)
## JSON Changes ## JSON Changes
temp note: for now (6.0.0a) the statetext overwrites the json power result (e.g. "ON" => "AN" or any other statetext the users enter) temp note: for now (6.0.0a) the statetext overwrites the json power result (e.g. "ON" => "AN" or any other statetext the users enter)
@ -275,191 +273,3 @@ After StatusTIM
}, },
[Back to Top](#table-of-contents) [Back to Top](#table-of-contents)
## Bugged JSON in <= 5.10.0 (invalid JSON)
Also, before 5.10.0j JSON was translated! (< 5.10.0j)
STATUS = {
"Status": {
"Module": 4,
"FriendlyName": "XXX",
"Topic": "sonoff",
"ButtonTopic": "0",
"Power": 0,
"PowerOnState": 0,
"LedState": 0,
"SaveData": 1,
"SaveState": 1,
"ButtonRetain": 0,
"PowerRetain": 0
}
}
STATUS1 = {
"StatusPRM": {
"Baudrate": 115200,
"GroupTopic": "sonoffs",
"OtaUrl": "X",
"Laufzeit": 8,
"Sleep": 0,
"BootZähler": 50,
"SaveCount": 121,
"SaveAddress": "F8000"
}
}
STATUS2 = {
"StatusFWR": {
"Version": "5.10.0",
"BuildDatumUhrzeit": "2018.01.12 17:48:45",
"Boot": 6,
"Core": "2_4_0",
"SDK": "2.1.0(deb1901)"
}
}
STATUS3 = {
"StatusLOG": {
"SerialLog": 2,
"WebLog": 2,
"SysLog": 0,
"LogHost": "XXX",
"LogPort": 514,
"SSId1": "YYYY",
"SSId2": "XXX",
"TelePeriod": 300,
"SetOption": "00000009"
}
}
STATUS4 = {
"StatusMEM": {
"ProgramSize": 508,
"frei": 492,
"Heap-Größe": 19,
"ProgramFlashSize": 1024,
"FlashSize": 1024,
"FlashMode": 3
}
}
STATUS5 = {
"StatusNET": {
"Hostname": "XXX",
"IPAddress": "192.168.178.111",
"Gateway": "192.168.178.1",
"Subnetmaske": "255.255.255.0",
"DNSServer": "192.168.178.1",
"MAC": "XX:XX:XX:XX:XX:XX",
"Webserver": 2,
"WifiConfig": 0
}
}
STATUS6 = {
"StatusMQT": {
"MqttHost": "192.168.178.111",
"MqttPort": 1883,
"MqttClientMaske": "XXXX",
"MqttClient": "XXXX",
"MqttUser": "XXXX",
"MAX_PACKET_SIZE": 512,
"KEEPALIVE": 15
}
}
STATUS7 = {
"StatusTIM": {
"UTC": "Mon Jan 22 19:05:14 2018",
"lokale Zeit": "Mon Jan 22 20:05:14 2018",
"StartDST": "Sun Mar 25 02:00:00 2018",
"EndDST": "Sun Oct 28 03:00:00 2018",
"Timezone": 1
}
}
in = {
"idx": 13,
"nvalue": 0,
"svalue": "1.5;99.9;3"
}
STATUS10 = {
"StatusSNS": {
"Zeit": "2018.01.22 20:05:14",
"AM2301": {
"Temperatur": 1.5,
"Feuchtigkeit": 99.9
},
"TempUnit": "C"
}
}
STATUS11 = {
"StatusSTS": {
"Zeit": "2018.01.22 20:05:14",
"Laufzeit": 8,
"VCC": 3.476,
"POWER": "OFF",
"WLAN": {
"AP": 1,
"SSID": "XXXX",
"RSSI": 18,
"APMac": "XX:XX:XX:XX:XX:XX"
}
}
}
### PHP Fix for invalid JSON <= 5.10.0
private function fixJsonFormatV5100( $string ) {
$string = substr( $string, strpos( $string, "STATUS = " ) );
if ( strpos( $string, "POWER = " ) !== FALSE ) {
$string = substr( $string, strpos( $string, "{" ) );
$string = substr( $string, 0, strrpos( $string, "}" ) + 1 );
}
if ( strpos( $string, "ERGEBNIS = " ) !== FALSE ) {
$string = substr( $string, strpos( $string, "{" ) );
$string = substr( $string, 0, strrpos( $string, "}" ) + 1 );
}
if ( strpos( $string, "RESULT = " ) !== FALSE ) {
$string = substr( $string, strpos( $string, "{" ) );
$string = substr( $string, 0, strrpos( $string, "}" ) + 1 );
}
$remove = [
PHP_EOL,
"\n",
"STATUS = ",
"}STATUS1 = {",
"}STATUS2 = {",
"}STATUS3 = {",
"}STATUS4 = {",
"}STATUS5 = {",
"}STATUS6 = {",
"}STATUS7 = {",
"}in = {",
"}STATUS8 = {",
"}STATUS9 = {",
"}STATUS10 = {",
"}STATUS11 = {",
"STATUS2 = ",
];
$replace = [
"",
"",
"",
",",
",",
",",
",",
",",
",",
",",
",",
",",
",",
",",
",",
"",
];
$string = str_replace( $remove, $replace, $string );
return $string;
}
[Back to Top](#table-of-contents)