//#!/bin/bash #Moodo script response=$(curl -X PUT "https://rest.moodo.co/api/boxes" -H "accept: application/json" -H "token: 6HWXfEdu8G723KlvSR4hcpzsFPjkQgxNa5T9UCBr1630875535" -H "Content-Type: application/json" -d "{ \"device_key\": 24024, \"box_status\": $1, \"settings_slot0\": { \"fan_speed\": $2, \"fan_active\": $3 }, \"settings_slot1\": { \"fan_speed\": $4, \"fan_active\": $5 }, \"settings_slot2\": { \"fan_speed\": $6, \"fan_active\": $7 }, \"settings_slot3\": { \"fan_speed\": $8, \"fan_active\": $9 }, \"restful_request_id\": \"string\"}") echo "$response" moodomode=$(echo "$response" | grep -o -P '(?<="box_mode":").*?(?=")') echo $moodomode moodo1=$(echo "$response" | grep -o -P '(?<="slot_id":0).*?(?=is_digital)') moodo2=$(echo "$response" | grep -o -P '(?<="slot_id":1).*?(?=is_digital)') moodo3=$(echo "$response" | grep -o -P '(?<="slot_id":2).*?(?=is_digital)') moodo4=$(echo "$response" | grep -o -P '(?<="slot_id":3).*?(?=is_digital)') moodo1scent=$(echo "$moodo1" | grep -o -P '(?<="title":").*?(?=")') moodo2scent=$(echo "$moodo2" | grep -o -P '(?<="title":").*?(?=")') moodo3scent=$(echo "$moodo3" | grep -o -P '(?<="title":").*?(?=")') moodo4scent=$(echo "$moodo4" | grep -o -P '(?<="title":").*?(?=")') curl -X "POST" --header "Content-Type: text/plain" --header "Accept: application/json" -d "$moodo1scent" "http://192.168.32.2:8080/rest/items/Moodo_1_Scent" curl -X "POST" --header "Content-Type: text/plain" --header "Accept: application/json" -d "$moodo2scent" "http://192.168.32.2:8080/rest/items/Moodo_2_Scent" curl -X "POST" --header "Content-Type: text/plain" --header "Accept: application/json" -d "$moodo3scent" "http://192.168.32.2:8080/rest/items/Moodo_3_Scent" curl -X "POST" --header "Content-Type: text/plain" --header "Accept: application/json" -d "$moodo4scent" "http://192.168.32.2:8080/rest/items/Moodo_4_Scent" if [[ $moodomode == "diffuser" ]] then curl -X "POST" --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://192.168.32.2:8080/rest/items/Moodo_Mode" fi if [[ $moodomode == "purifier" ]] then curl -X "POST" --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://192.168.32.2:8080/rest/items/Moodo_Mode" fi