My very quick and dirty integration with myacurite / smart hub / ST / Webcore

temperature
webcore

(Boris Tsipenyuk) #1

Hello all, so it seems like for years people have looked to figure out a way to integrate the myacurite smarthub + smarthings - I decided to poke around and realized that their web portal spits back all the info I needed
I figure I would post this and I am sure there is enough tech savvy around to make this into either a native smartapp or in concert with webcore

I run this on a linux VM/Pi in house and send the results to a webcore piston

I think it should be clear that this is no way “hacking” or circumventing the security of myacurite, I am simply scraping their dashboard where they already have the relevent data in JSON

you will have to monitor your web traffic via a https parser of your choice to get your Hub’s URL for the sensor data below:

first you need your authentication token:

token=$(curl -s -H ‘Host: marapi.myacurite.com’ -H ‘Content-Type: application/json;charset=UTF-8’ -H ‘Origin: https://www.myacurite.com’ -H ‘Accept-Language: en-us’ -H ‘Accept: application/json’ -H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8’ -H ‘Referer: https://www.myacurite.com/’ -H ‘DNT: 1’ --data-binary ‘{“remember”:true,“email”:“XXXX Email Login for MY Acurite XXXX”,“password”:“xxxx your password xxxx”}’ --compressed ‘https://marapi.myacurite.com/users/login’ | jq . | grep token_id | awk -F":" ‘{print $2}’ | sed ‘s/"//g’ | sed ‘s/ //g’ | sed ‘s/,//g’)

the following dumps the current reading of all your sensors into as json into a variable called $sensors (be sure to find your accountID/HubID first):

sensors=$(curl -s -H ‘Host: marapi.myacurite.com’ -H ‘Accept: application/json’ -H “x-one-vue-token: $token” -H ‘Origin: https://www.myacurite.com’ -H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8’ -H ‘Referer: https://www.myacurite.com/’ -H ‘DNT: 1’ -H ‘Accept-Language: en-us’ --compressed ‘https://marapi.myacurite.com/accounts/XXXXXX/dashboard/hubs/XXXXXXX’)

the data looks like so:

“devices”: [
{
“id”: XXXXX,
“name”: “Small Bath”,
“model_code”: “2in1T”,
“placement_code”: “IN”,
“status_code”: “green”,
“battery_level”: “Normal”,
“signal_strength”: 3,
“last_check_in_at”: “2017-09-03T18:05:29.794+00:00”,
“timezone”: “America/New_York”,
“summary_files”: [
https://xxxxxx
],
“temp_high_value”: “71.5”,
“temp_high_at”: “12:25 AM”,
“temp_low_value”: “64.4”,
“temp_low_at”: “10:00 AM”,
“sensors”: [
{
“id”: XXXXX,
“sensor_code”: “Temperature”,
“sensor_name”: “Temperature”,
“last_reading_value”: “66.3”,
“channel”: 1,
“chart_unit”: “F”,
“show_tenths”: true
},
{
“id”: XXXXX,
“sensor_code”: “Humidity”,
“sensor_name”: “Humidity”,
“last_reading_value”: “70”,
“display_unit”: “%”,
“channel”: 2,
“chart_unit”: “%RH”
},
{
“id”: XXXXX,
“sensor_code”: “Dew Point”,
“sensor_name”: “Dew Point”,
“last_reading_value”: “56”,
“channel”: 3,
“chart_unit”: “F”
},
{
“id”: XXXXXX,
“sensor_code”: “Barometric Pressure”,
“sensor_name”: “Pressure”,
“last_reading_value”: “29.44”,
“channel”: 9,
“chart_unit”: “inHg”
}
],

each sensor comes back via json like so, the sensors are unique so you just need to find the room and value you are intersted in:
so for my various rooms:

dadBR=$(echo $sensors | jq . | grep -A 3 XXXXXX | grep last | awk -F":" ‘{print $2}’ | sed ‘s/"//g’ | sed ‘s/ //g’ | sed ‘s/,//g’)
LR=$(echo $sensors | jq . | grep -A 3 XXXXX | grep last | awk -F":" ‘{print $2}’ | sed ‘s/"//g’ | sed ‘s/ //g’ | sed ‘s/,//g’)
kitchen=$(echo $sensors | jq . | grep -A 3 XXXX | grep last | awk -F":" ‘{print $2}’ | sed ‘s/"//g’ | sed ‘s/ //g’ | sed ‘s/,//g’)
masterBR=$(echo $sensors | jq . | grep -A 3 XXXXX | grep last | awk -F":" ‘{print $2}’ | sed ‘s/"//g’ | sed ‘s/ //g’ | sed ‘s/,//g’)

send the results to a webcore piston:

curl -s “https://graph-na02-useast1.api.smartthings.com/api/token/XXXXXXXXXsmartapps/installations/XXXXXXXXX7/execute/:XXXXXXXXX:?dadBR=$dadBR&LR=$LR&kitchen=$kitchen&masterBR=$masterBR

with the piston below (dimmer should really be simulated temprature sensors)