Eikkargh / Candy-API-to-JSON

Communicates with Candy/Hoover washer dryers to produce a JSON readable by Home Assistant
7 stars 2 forks source link
home-assistant python3 yaml

Candy-API-to-JSON

This python script is designed to communicate with Candy/Hoover washer dryers to produce a JSON readable by Home Assistant.

Tested and working on:

Getting the API Key

To obtain the key for the machine I used: xorknown.py from: @Alamot. For most reliable responses, getting the key should be done while the machine is running a program.

  1. In a terminal run the command:
    curl -s http://CANDY_IP/http-read.json?encrypted=1 | xxd -r -p > ./coded.txt
    This gets the raw hex data from the machines API and converts to plaintext.

  2. Feed the coded.txt into xorknown.py using:
    ./xorknown.py ./coded.txt '{"statusLavatric' 16

  3. the output should now contain a key of length 16 and a JSON. An example decoded JSON:
    Plaintext: {
            "statusLavatrice":{
                    "WiFiStatus":"0",
                    "Err":"255",
                    "MachMd":"1",
                    "Pr":"4",
                    "PrPh":"0",
                    "SLevel":"255",
                    "Temp":"60",
                    "SpinSp":"10",
                    "Opt1":"0",
                    "Opt2":"0",
                    "Opt3":"0",
                    "Opt4":"0",
                    "Opt5":"0",
                    "Opt6":"0",
                    "Opt7":"0",
                    "Opt8":"0",
                    "Steam":"0",
                    "DryT":"0",
                    "DelVal":"255",
                    "RemTime":"59",
                    "RecipeId":"0",
                    "CheckUpState":"0"
            }
      }

  4. If you do not have a full key at this stage repeat step 3 using another JSON key value like 'WiFiStatus' until each character of the key is known.

  5. Add your KEY and DEVICE_IP to candy.py and place in your Home Assistant config/pyscripts.


Configuring Home Assistant

candy.py gets the data, decodes it and strips down the JSON to meet Home Assistants 255 character limit on sensors.
To set up in Home Assistant you can use the sensor:


command_line:
  - sensor:
      name: 'Candy Washer Dryer'
      scan_interval: 60
      command_timeout: 30
      command: python3 ./pyscript/candy.py
      value_template: '{{ value_json }}'
      json_attributes:
        - WiFiStatus
        - Err
        - MachMd
        - Pr
        - PrPh
        - Temp
        - SpinSp
        - RemTime
        - DryT
        - DelVal
        - TotalTime
This may be different on some machines. Yaml exmaples for test machines are above. If your machine is not listed please raise an issue with a copy of your decoded output.
candy-card