Hi, i created a simple homeyscript for get data from a B-hyve account.
You can use it for reading value from your sprinker timer and populate a virtual device created with Device Capabilities app.
I have tested it with an Orbit B-hyve 94990 Timer and Wifi Hub .
Actually it only read some info.
Prerequisites:
- Install “Device Capabilities ” app from the Homey App Store.
- Install HomeyScript app from the Homey App Store
Step 1: Create a homeyscript for get the sprinkler data (example b-hyve_bridge.js)
const email = 'YOUR_MAIL';
const password = 'YOUR_PASSWORD';
const endpoint = 'https://api.orbitbhyve.com';
let devices = [];
const config = {
method: "POST",
headers: {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json; charset=utf-8;"
},
body: JSON.stringify({ "session": { "email": email, "password": password } })
};
const res = await fetch(endpoint + '/v1/session', config);
if (!res.ok) {
throw new Error(res.statusText);
}
const body = await res.json();
const token = body.orbit_session_token;
if (token) {
const config2 = {
method: 'GET',
headers: {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json; charset=utf-8;",
'Orbit-Session-Token': token,
'Host': 'api.orbitbhyve.com',
'Referer': endpoint
}
};
const res2 = await fetch(endpoint + "/v1/devices", config2);
if (!res2.ok) {
throw new Error(res.statusText);
}
const data = await res2.json();
if (data != null) {
for(const device of data) {
let d = { 'id': device['id'], 'name': device['name'], 'type': device['type'], 'connected': device['is_connected'], 'updated': device['updated_at'], 'status': { 'mode': device['status']['run_mode'] }, 'zones': [] };
if (device['network_interface']) d['interface'] = device['network_interface'];
if (device['battery']) {
d['battery'] = device['battery']['percent'];
await tag('b_hyve_'+ d.id + '_battery', d.battery);
}
await tag('b_hyve_'+ d.id + '_type', d.type);
if (device['zones']) {
for(const zone of device['zones']) {
d['zones'].push({ station: zone['station'], 'sprinklers': zone['num_sprinklers'] });
}
}
devices.push(d);
await tag('b_hyve_'+ d.id + '_zone', d.zones.length);
await tag('b_hyve_'+ d.id + '_connected', d.connected);
await tag('b_hyve_'+ d.id + '_status', d.status.mode);
}
}
}
return true;
Step 2: Create a Virtual Device for your Sprinkler timer
- With app or my.homey.com create a new “Device capabilities” device.
Step 3: Configuring Device Settings
- Define the capabilities your virtual device will have (battery, status, zones, connected, type), you could also import this sample [TEF] String
[tef:AVD:"H4sIAAAAAAACA41X1w6kSJb9lVVK+0S18K6keQASm4knIWG1KuG994z630flumqqe3qXlxD3hM65cbiXiPjnLUm3Mk7luO9uH28SNsvM14djEOR1IkRlsqxAn4ZmnHfPTb3VImlxKd9GObs1gbloJZ6CLfm2buZddlFcx+YXH8rWAoEJQnuQ98ThinqTRFZRSzlGS4fSi1vEzyIlHk8klo6s7ISVSny6mUMwEgdwghDBBccavK8pdxIKqTcHsJHnZjcplg/Q5ElHQOvARiLvQ3XI9wmGg2GRXosaJE28AHJfEdx7vJqRhpHDId2sNlW45QmuGKLY5HbgTnC4R/WOsyJ7a8p7JDeSc3f0oJCYmDF7ZtYcdX/jrvqsGexVKbvJd+wVxhW7VQb3qit1ME7eNJAwmh3mzOzF4Hcz349aGDOCq0VRDgpmTrHnwWnIQzMr/a7cwaQ32cuqgc4675z9YPPAYp8RKhtK7acv23PQnh+V3NEa1LZkGMLqnLFPttIO0HarfLFwf1qUmmNdvgybnhDRs9KCbuCsek4YYdhM7i36ADsKfigCPbVfFGFfJr8naCvc0wTYUWK08LXlVPcF1MDArwR0f2QP73UaPATbksT1LjfQOgZmixUaL9XzQB30WMSlDsaqd7LInJLTcbvVF9fyh6EZWIOi0lDL3uhpmRDvD9Ro2eYztE8vfJ3ydailyPt5KIiU+DLUcp9hquTq3IUaKObmEZvBFH5I962aelgmQCdrmEmiitbwsOW6PyQIFTMggIP83K9wO6GaCixxwJBpLKIysBp2aVU/AgJO4e1Zvx7HewpAovMMFKQYIhXoXXJYhmFuH27xOi99+7ne59vHf357/QRDv1Y/hbioh4WqxYpv6h2+Z2rHQMlH8xELRdIRqCJZBE5emMbq+TndSAWFcVOQG3cc+HLH5gwTUUBiQI1eLimBwAnzwRQY1dKc08Zrs6yjWw8cn6G0AxuKpAdm6IoVGynSunXZrgjpRF68XVi6tCE8SniYcLYovt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565qTHIpRpk8y3j8iPsPZl/AuA7fsmDbvvCPwTsi5L/wcA/QC4sE2n8C+AZzkvP4XjZr59vM1pN/fT7cMt+qoEa2Gb3j7euL7r0nnuf0K4KQ2XVGj6nQunzyRZ2MzpD9xOh3AKl5QLhzAqm3Ip07+YVPQ785fC365MP9r0e+bfU2LDZUmnMvwB/K3i9znfBds0nNcp/RR9oTl/sFhp1qTxcvt4+xH701qXaU1/QZ0w/1Xs1ZXLZ63//pVJ7uYyL5Zfie5pXLZh8/XLLumxfF+rUw6frf8S+k++fwH/1oKvM/7k+JfwL3ZDf2SMfEsh6Lv0R/D/YTXyZ6VvwL9rIcgPRC27n6oaUcPj9hGGfjAu6fCHN98Ts5dw+W4O8nfmIP+nOX9K+fcP3y7w32vuN+nc0v+Sp6nMw6WfPjsS3j7+z//+/i/i3kTC6g8AAA==":/tef]
Step 4: Populate the virtual device with a flow
Customize the tags with your tag (They have in the name the b-hyve device_id)
This is a implementation sample, you can suggest optimization or fix