Code Monkey home page Code Monkey logo

Comments (5)

Youaresmarter avatar Youaresmarter commented on July 25, 2024

@guinmoon Подскажи, что нужно поправить для режима поддержания температуры.

from r4s-bluetooth.

ChrisGSXR avatar ChrisGSXR commented on July 25, 2024

Скрипты (auth on off status)https://github.com/Andrey-m/homebridge-redmond-sh работают с обогревателем REDMOND SkyHeat 7001S
С чайником SkyKettle RK-M171S работает скрипт connect

Скрипт connect корректно забирает текущий режим мощности обогревателя:
ON 0C Will keep: 25C REPLY:55 00 06 00 00 19 00 00 00 00 00 02 00 00 00 00 00 00 00 aa
Но установить режим работы не выходит =(

from r4s-bluetooth.

Andrey-m avatar Andrey-m commented on July 25, 2024

Скрипты (auth on off status)https://github.com/Andrey-m/homebridge-redmond-sh работают с обогревателем REDMOND SkyHeat 7001S
С чайником SkyKettle RK-M171S работает скрипт connect

Скрипт connect корректно забирает текущий режим мощности обогревателя:
ON 0C Will keep: 25C REPLY:55 00 06 00 00 19 00 00 00 00 00 02 00 00 00 00 00 00 00 aa
Но установить режим работы не выходит =(

А вы какой командой пытаетесь установить режим работы?

должно быть что-то вроде "connect.sh MAC keeptemp 19" для поддержания на уровне 25 градусов

from r4s-bluetooth.

guinmoon avatar guinmoon commented on July 25, 2024

Блин только заметил что тут какое то движение есть. Там я помоему в keeptemp основные изменения делал. В общем для M170S вот рабочий скрипт:

#!/bin/bash

#C8:54:A9:29:1B:7F
devicemac="$1"
command="$2"


function tracemen()
{ 
  echo -e -n $1 >>kettellog.txt
}

function traceme()
{ 
  echo -e $1 >>kettellog.txt
}

if [[ $devicemac == "_" ]]; then
    $devicemac=`cat kettle.mac`
fi;

if [[ $devicemac =~ ^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$ ]]; then
   traceme "Will Control: $devicemac";
else
   traceme "Usage <mac> <command>"
   exit;
fi



traceme "Reading primary info"
#gatttool -b $devicemac -t random --primary

traceme "Reading characteristics info"
#gatttool -b $devicemac -t random --characteristics

traceme "Reading characteristics desc"
#gatttool -b $devicemac -t random --char-desc


traceme "Attempt to write something -> 0x000c"
#gatttool -b $devicemac -t random --char-write-req --handle=0x000c --value=0100


# 55:00:ff:b5:4c:75:b1:b4:0c:88:ef:aa
# 55:01:ff:b5:4c:75:b1:b4:0c:88:ef:aa
# 55:02:ff:b5:4c:75:b1:b4:0c:88:ef:aa
# 55:03:ff:b5:4c:75:b1:b4:0c:88:ef:aa
#sdf


(( i=0 ))

if true; then  # Auth sequence.
  while [ $i -lt 2 ]; do
    #echo "Restarting hci0"
    #repll=`/home/ubuntu/r4s_webserver/restart_ble.sh`
    #sleep 0.5;
    #echo "trying:$i"
    traceme "Attempt to write something -> 0x000c"
    gatttool -b $devicemac -t random --char-write-req --handle=0x000c --value=0100 > /dev/null
    sleep 0.5;
    
    #gatttool -b $devicemac -t random --listen &
    magic=`printf "55%02xffb54c75b1b40c88efaa" $i`
  
    
    traceme "Attempt to write something -> 0x000e ($magic)"
    sleep 0.5;
    gatttool -b $devicemac -t random --char-write-req --handle=0x000e --value=$magic --listen >response  &
    gettpid=$!
    #echo "Forked to pid $gettpid"
    sleep 0.5;
    #echo "Killing to pid $gettpid"
    kill $gettpid  >/dev/null 2>/dev/null
    wait $gettpid 2>/dev/null
    response=`cat response`;
    reply=`echo $response | grep "value:" | sed "s/.*value: \(.*\)/\\1/g"`
    #echo -n "REPLY:$reply"
    
    is_authorized=`echo $reply | awk '{print $4}'`
    traceme " <$is_authorized> "
    if [[ $is_authorized == "01" ]]; then 
      traceme  "Authorized"
      break;
    fi;
    
    if [[ $is_authorized == "00" ]]; then
      traceme  "HOLD '+' button"
    fi;
    
    if [[ $reply == "" ]]; then
      traceme "No reply"
      (( i = (i + 1) % 256 ));
    else    
      (( i = (i + 1) % 256 ));
    fi
  done;
fi;
  
traceme "Ok";


# Requesting status

if [[ $command == "query" || $command == "queryone" ]]; then
  while [ $i -lt 2 ]; do
    echo "trying:$i"
    #echo "Attempt to write something -> 0x000c"
    gatttool -b $devicemac -t random --char-write-req --handle=0x000c --value=0100 >/dev/null 2>/dev/null
    sleep 0.5;
    
    #gatttool -b $devicemac -t random --listen &
    magic=`printf "55%02x06aa" $i`
  
    
    #echo "Attempt to write something -> 0x000e ($magic)"
    sleep 0.5;
    gatttool -b $devicemac -t random --char-write-req --handle=0x000e --value=$magic --listen >response 2>/dev/null &
    gettpid=$!
    #echo "Forked to pid $gettpid"
    sleep 0.5;
    #echo "Killing to pid $gettpid"
    kill $gettpid  >/dev/null 2>/dev/null
    wait $gettpid 2>/dev/null
    response=`cat response`;
    #echo $response
    reply=`echo $response | grep "value:" | sed "s/.*value: \(.*\)/\\1/g"`
         
    
    if [[ $reply == "" ]]; then
      echo "No reply"
      (( i = (i + 1) % 256 ));
    else    
      #kettle_keeptemp=`echo $reply | awk '{print $6}'`    
      #kettle_temp=`echo $reply | awk '{print $14}'`
      kettle_temp=`echo $reply | awk '{print $6}'`
      #kettle_keeptemp=`echo $reply | awk '{print $14}'`    
      kettle_keeptemp_mode=`echo $reply | awk '{print $5}'`    
      kettle_on=`echo $reply | awk '{print $12}'`
    
      if [[ $kettle_on == "00" ]]; then
        #echo -n "OFF"
        echo "state:OFF"
      else
        #echo -n "ON"
        echo "state:ON"
      fi


      kettle_keeptemp="0"

      if [[ $kettle_keeptemp_mode == "01" ]]; then
        kettle_keeptemp="40"
      elif [[ $kettle_keeptemp_mode == "02" ]]; then
        kettle_keeptemp="55"
      elif [[ $kettle_keeptemp_mode == "03" ]]; then
        kettle_keeptemp="70"
      elif [[ $kettle_keeptemp_mode == "04" ]]; then
        kettle_keeptemp="85"
      elif [[ $kettle_keeptemp_mode == "05" ]]; then
        kettle_keeptemp="95"
      fi
    
      #echo -n " "  
      #echo -n "$((16#$kettle_temp))C "
      #echo -n "Will keep: $((16#$kettle_keeptemp))C "
      #echo -n "Will keep: $(($kettle_keeptemp))C "
      #echo "REPLY:$reply"

      echo "temp:$((16#$kettle_temp))"
      echo "heating:$(($kettle_keeptemp))"
      
      if [[ $command == "queryone" ]]; then
         break;
      fi;    
      (( i = (i + 1) % 256 ));
    fi
    
  done;
fi;

if [[ $command == "on" ]]; then
    while [ $i -lt 2 ]; do
      echo "trying:$i"
      #echo "Attempt to write something -> 0x000c"
      gatttool -b $devicemac -t random --char-write-req --handle=0x000c --value=0100 >/dev/null
      sleep 0.5;
      magic=`printf "55%02x0500000000aa" $i`
      
      #echo "Attempt to write something -> 0x000e ($magic)"
      sleep 0.5;
      gatttool -b $devicemac -t random --char-write-req --handle=0x000e --value=$magic --listen >response  &
      gettpid=$!
      #echo "Forked to pid $gettpid"
      sleep 0.5;
      #echo "Killing to pid $gettpid"
      kill $gettpid  >/dev/null 2>/dev/null
      wait $gettpid 2>/dev/null
      response=`cat response`;
      reply=`echo $response | grep "value:" | sed "s/.*value: \(.*\)/\\1/g"`
      
      is_on=`echo $reply | awk '{print $4}'`
      #echo " <$is_on> "
      if [[ $is_on == "01" ]]; then 
	echo  "Success"
	break;
      else
	echo  "Trying again..."
      fi;
      
      if [[ $reply == "" ]]; then
	echo "No reply"
	(( i = (i + 1) % 256 ));
      else    
	(( i = (i + 1) % 256 ));
      fi        
   done;
    
fi;

if [[ $command == "keeptemp" ]]; then
    keep_temp="$3"

    while [ $i -lt 2 ]; do
      echo "trying:$i"
      #echo "Attempt to write something -> 0x000c"
      gatttool -b $devicemac -t random --char-write-req --handle=0x000c --value=0100 >/dev/null
      sleep 0.5;

      kettle_keeptemp_mode="01"
      if [[ $keep_temp == "40" ]]; then
        kettle_keeptemp_mode="01"
      elif [[ $keep_temp == "55" ]]; then
        kettle_keeptemp_mode="02"
      elif [[ $keep_temp == "70" ]]; then
        kettle_keeptemp_mode="03"
      elif [[ $keep_temp == "85" ]]; then
        kettle_keeptemp_mode="04"
      elif [[ $keep_temp == "95" ]]; then
        kettle_keeptemp_mode="05"
      fi

      magic=`printf "55%02x0501%02x0000aa" $i $kettle_keeptemp_mode`
      #magic=`printf "55%02x050000%02x00aa" $i $keep_temp`
      #magic=`printf "55%02x0501040000aa" $i`
      #echo $magic
      #echo "Attempt to write something -> 0x000e ($magic)"
      sleep 0.5;
      gatttool -b $devicemac -t random --char-write-req --handle=0x000e --value=$magic --listen >response  &
      gettpid=$!
      #echo "Forked to pid $gettpid"
      sleep 0.5;
      #echo "Killing to pid $gettpid"
      kill $gettpid  >/dev/null 2>/dev/null
      wait $gettpid 2>/dev/null
      response=`cat response`;
      reply=`echo $response | grep "value:" | sed "s/.*value: \(.*\)/\\1/g"`
      
      is_on=`echo $reply | awk '{print $4}'`
      #echo " <$is_on> "
      if [[ $is_on == "01" ]]; then 
	echo  "Success"
	break;
      else
	echo  "Trying again..."
      fi;
      
      if [[ $reply == "" ]]; then
	echo "No reply"
	(( i = (i + 1) % 256 ));
      else    
	(( i = (i + 1) % 256 ));
      fi        
   done;
    
fi;

if [[ $command == "off" ]]; then
   while [ $i -lt 2 ]; do
      echo "trying:$i"
      #echo "Attempt to write something -> 0x000c"
      gatttool -b $devicemac -t random --char-write-req --handle=0x000c --value=0100  >/dev/null
      sleep 0.5;
      magic=`printf "55%02x04aa" $i`
      
      #echo "Attempt to write something -> 0x000e ($magic)"
      sleep 0.5;
      gatttool -b $devicemac -t random --char-write-req --handle=0x000e --value=$magic --listen >response  &
      gettpid=$!
      #echo "Forked to pid $gettpid"
      sleep 0.5;
      #echo "Killing to pid $gettpid"
      kill $gettpid  >/dev/null 2>/dev/null
      wait $gettpid 2>/dev/null
      response=`cat response`;
      reply=`echo $response | grep "value:" | sed "s/.*value: \(.*\)/\\1/g"`
      
      is_on=`echo $reply | awk '{print $4}'`
      #echo " <$is_on> "
      if [[ $is_on == "01" ]]; then 
	echo  "Success"
	break;
      else
	echo  "Trying again..."
      fi;
      
      if [[ $reply == "" ]]; then
	echo "No reply"
	(( i = (i + 1) % 256 ));
      else    
	(( i = (i + 1) % 256 ));
      fi        
   done;
fi;

from r4s-bluetooth.

sir90ha avatar sir90ha commented on July 25, 2024

A для хом ассистента как применить этот скрипт??

from r4s-bluetooth.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.