cocoro-sdk
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -140,3 +140,3 @@ "use strict"; | ||
Device.prototype.queueTemperatureUpdate = function (temp) { | ||
var s8 = this.getState8(); | ||
var s8 = new state_1.State8(); | ||
s8.temperature = temp; | ||
@@ -143,0 +143,0 @@ this.queuePropertyStatusUpdate({ |
@@ -23,5 +23,5 @@ /** | ||
state: string; | ||
constructor(state: string); | ||
constructor(state?: string); | ||
get temperature(): number; | ||
set temperature(t: number); | ||
} |
@@ -26,2 +26,3 @@ "use strict"; | ||
function State8(state) { | ||
if (state === void 0) { state = '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; } | ||
this.state = state; | ||
@@ -36,2 +37,3 @@ } | ||
set: function (t) { | ||
// on setting temp, encode temp as hex into position 52,53 | ||
var s = this.state.split(''); | ||
@@ -41,2 +43,8 @@ var hextemp = (t * 2).toString(16); | ||
s[53] = hextemp[1]; | ||
// set position 6 to hex 2 | ||
s[6] = '2'; | ||
// set 0,1 to temperature + 16, don't fully understand why it's 16 higher though | ||
var hextemp2 = ((t + 16) * 2).toString(16); | ||
s[0] = hextemp2[0]; | ||
s[1] = hextemp2[1]; | ||
this.state = s.join(''); | ||
@@ -43,0 +51,0 @@ }, |
{ | ||
"name": "cocoro-sdk", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -7,6 +7,4 @@ # Cocoro Air SDK | ||
Currently to retrieve an API key, you'll have to use a reverse proxy like charles, mitmproxy or Proxyman to capture traffic sent from your device to the Cocoro air server | ||
Currently to retrieve an API key, you'll have to use a reverse proxy like charles, mitmproxy or Proxyman to capture traffic sent from your device to the Cocoro air server. Set the proxy on your device, open the app an lookout for the login API call. Extract the `appSecret` from the URL, and the `terminalAppId` from the body: | ||
Lookout for the login call and extract the `appSecret` (url) and `terminalAppId` (body): | ||
``` | ||
@@ -16,2 +14,4 @@ https://hms.cloudlabs.sharp.co.jp/hems/pfApi/ta/setting/login/?appSecret=xxxx&serviceName=iClub | ||
For the `terminalAppId`, you only need the part after `/key/` | ||
The app is using SSL pinning so I wasn't able to figure out how the authentication works (yet). | ||
@@ -58,4 +58,31 @@ | ||
### Annoyances & caveats | ||
Sometimes the API is very specific about what you have to submit for stuff to work, for example to change the temperature it isn't enough to just change the temperature, you have to queue a power state as well: | ||
``` | ||
this.device.queueTemperatureUpdate(26.5); | ||
this.device.queuePowerOn(); | ||
``` | ||
If something doesn't work, check how the app is doing it and replicate that | ||
### Decoding the state object | ||
A lot of things are changeable just by their own properties, but some things aren't. There are a few big state objects like `FA` that look like this: | ||
``` | ||
55000020000000000000000000000000010000000000010000003500000000000000010000010042010000000000000000FF000000000000000038000000000000000000000000000000000000000000 | ||
``` | ||
Position 52,53 contain the hex-encoded temperature multiplied by 2 (since the app allows 0.5 degree steps). I started decoding this in `state.ts`, but temperature is the only thing that's being available in this SDK yet. | ||
Swing is also encoded in this state object. | ||
`F4` towards `FF` are labeled `運転状態詳細1` ~ `1運転状態詳細13` by the API (`FA` is `8`), most of them aren't used for the aircon I own but for yours they might :D | ||
(When changing things, we can't change the state object as is but have to create a new one altogether.) | ||
## License | ||
AGPL |
@@ -214,3 +214,3 @@ import { default as fetchCookie } from 'fetch-cookie'; | ||
queueTemperatureUpdate(temp: number): void { | ||
const s8 = this.getState8(); | ||
const s8 = new State8(); | ||
s8.temperature = temp; | ||
@@ -217,0 +217,0 @@ |
@@ -24,3 +24,5 @@ /** | ||
constructor(state: string) { | ||
constructor( | ||
state = '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', | ||
) { | ||
this.state = state; | ||
@@ -36,2 +38,3 @@ } | ||
set temperature(t: number) { | ||
// on setting temp, encode temp as hex into position 52,53 | ||
const s = this.state.split(''); | ||
@@ -42,4 +45,12 @@ const hextemp = (t * 2).toString(16); | ||
// set position 6 to hex 2 | ||
s[6] = '2'; | ||
// set 0,1 to temperature + 16, don't fully understand why it's 16 higher though | ||
const hextemp2 = ((t + 16) * 2).toString(16); | ||
s[0] = hextemp2[0]; | ||
s[1] = hextemp2[1]; | ||
this.state = s.join(''); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65749
1680
86