Withings Scales

What do you mean by no special characters? I have my email, I shouldn’t use @?

This is what I’m getting:

 bash /home/homeassistant/.homeassistant/scripts/withings_firmware.sh: Permission denied/.homeassistant/scripts/withings_firmware.sh: line 3: /dev/null
: Permission denied/.homeassistant/scripts/withings_firmware.sh: line 5: /dev/null
/secrets.txt: No such file or directory
/secrets.txt: No such file or directory
/secrets.txt: No such file or directory
/secrets.txt: No such file or directory
: Permission denied/.homeassistant/scripts/withings_firmware.sh: line 11: /dev/null
/cookies.txt: No such file or directory
parse error: Invalid numeric literal at line 1, column 20

I’m having similar issues (hassbian, home-assistant 0.45.1 on a Raspberry Pi3):

pi@hassbian:/home/homeassistant/.homeassistant/scripts $ sudo bash withings_firmware.sh
/secrets.txt: No such file or directory/scripts
/secrets.txt: No such file or directory/scripts
/secrets.txt: No such file or directory/scripts
/secrets.txt: No such file or directory/scripts
/cookies.txt: No such file or directory/scripts
sed: -e expression #2, char 7: unknown option to `s’
parse error: Invalid numeric literal at line 1, column 20

My secrets.txt file is located in /home/homeassistant/.homeassistant/scripts and contains email,password,userid,deviceid:

pi@hassbian:/home/homeassistant/.homeassistant/scripts $ ls -l
total 20
-rw-r–r-- 1 homeassistant homeassistant 0 Jun 4 14:37 cookies.txt
-rw-r–r-- 1 homeassistant homeassistant 47 Jun 4 13:05 secrets.txt
-rwxr-xr-x 1 homeassistant homeassistant 1389 Jun 4 14:57 withings_battery.sh
-rwxr-xr-x 1 homeassistant homeassistant 1418 Jun 4 13:40 withings_co2.sh
-rwxr-xr-x 1 homeassistant homeassistant 1412 Jun 4 13:40 withings_firmware.sh
-rwxr-xr-x 1 homeassistant homeassistant 1426 Jun 4 13:44 withings_temp.sh

My jq is built and installed from code according to the instructions on this page:

pi@hassbian:/home/homeassistant/.homeassistant/scripts $ jq --version
jq-1.5
pi@hassbian:/home/homeassistant/.homeassistant/scripts $ which jq
/usr/local/bin/jq

To me, this seems to be an jq issue (all other scripts return similar results)? Can anyone shed some light on this?

Is this still working with the latest changes of the aquisition by Nokia? Can you post a confuguration example? Tks!

Hi,

I open again the topic, because I’ve got the same problem you had :
[homeassistant.components.sensor.command_line] Command failed: bash /home/homeassistant/.homeassistant/withings/withings_battery_balance.sh

But I don’t understand when you write : “the withings-login shouldn’t have any special characters”

Are you telling about email, password ?
And in the case of email, what we should write ?

thank you !

the csv file will be parsed using following shell statement, check ur password could be passed correctly or not

USERNAME=$(cat $SCRIPTPATH/secrets.txt | cut -d , -f1)
PASSWORD=$(cat $SCRIPTPATH/secrets.txt | cut -d , -f2)
CURUSER=$(cat $SCRIPTPATH/secrets.txt | cut -d , -f3)
DEVICEID=$(cat $SCRIPTPATH/secrets.txt | cut -d , -f4)

Then in the curl statement , they will be quoted like

email=‘“$USERNAME”’&password='“$PASSWORD”

in an URL, so avoid using ’ , " $ symbols in ur password.

just be simple: email is ok to using characters , @ , point
passwd just keep it simple as characters(upper/ lower case ), underbar, digits

I think this has been slightly changed nowadays. (curdate , 2017-09-04), and @jscolp’s code for CO2 is no longer valid.

the measure type of 12 , which be set by @jscolp in his codes, will get

{"status":2555,"body":{},"error":"An unknown error occurred"}

and I assumed that ,Nokia has been updated this index into measuretype :35, and the curl to get ur CO2 data
rely on this :wink:

curl ‘https://scalews.withings.net/cgi-bin/v2/measure’ -H ‘Origin: https://dashboard.health.nokia.com’ -H ‘Accept-Encoding: gzip, deflate, br’ -H ‘Accept-Language: zh-CN,zh;q=0.8,en;q=0.6,ja;q=0.4,zh-TW;q=0.2’ -H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36’ -H ‘Content-Type: text/plain;charset=UTF-8’ -H ‘Accept: /’ -H ‘Referer: https://dashboard.health.nokia.com/[yourUserID]/environment/[yourDeviceID]’ -H ‘Connection: keep-alive’ -H ‘DNT: 1’ --data-binary ‘meastype=35%2C12&deviceid=[yourDeviceID]&userid=[yourUserID]&startdate=1502726400&enddate=1504540799&sessionid=[yourSessionID]&action=getmeashf&appname=hmw&apppfm=web&appliver= [yourappliverID]’ --compressed

NOTE: [yourUserID] [yourDeviceID] [yourappliverID] [yourSessionID] should BE REPLACED with ur information

Hi Everyone,

I have updated my scripts here to hopefully resolve the nokia changes.

Hope that helps!

2 Likes

thnks for sharing

hello i am using the updated script for jscolp, but i am still getting the error, i am really new on HA so i might not have understand one of the steps.

2017-10-13 17:05:45 ERROR (SyncWorker_10) [homeassistant.components.sensor.command_line] Command failed: bash /config/withings/withings_co2.sh
2017-10-13 17:05:45 ERROR (SyncWorker_12) [homeassistant.components.sensor.command_line] Command failed: bash /config/withings/withings_temp.sh

i found the userid and the device id and created the secrets.txt file (csv).
the secrets.txt file is (email address,password,userid,deviceid)

thanks in advance

EDIT: i am on Hassio 0.55

@pi3rr3hassio – In my case I had to correct the path to the script, e.g.:

- platform: command_line
  name: Scale firmware
  command: "~/.homeassistant/scripts/withings_firmware.sh"

@Radushka thank you, i will try to change the path and let you know :slight_smile:

i actually tried several paths but the one jscolp gave is the write one. However, when i check the file in the terminal i got this:

core-ssh:~# bash /config/withings/withings_temp.sh
date: invalid date '28 day ago'
null

I have the same issue. Secrets-file should be correct, with user and device id.
Scripts starts,but freezes and dies out for timeout.

I am using Home Assistane with hass.io and there date command did not allow -d ‘28 day ago’ so I subtructed number of seconds in 28 days from ENDDATE.
Also took pushd and popd away. Now it works

Hi @jukkamatila thank you very much for your answer, i am pretty new on this. can you give me the line for subtracted number of seconds in 28 days from ENDDATE ? thank you

UPDATE: is this good ? $(date -r $(( $(date +%s) - 2419200 )))

and did you change it in ENDDATE or STARTDATE ?

thank you for you help

I just made a quick fix like

ENDDATE=$(date +%s)
STARTDATE=$ENDDATE - 60 * 60 * 24 * 28

thank you, im going to try this out :slight_smile:

im actually still getting this error:
2017-10-21 16:42:32 ERROR (SyncWorker_0) [homeassistant.components.sensor.command_line] Command failed: bash /config/withings/withings_co2.sh

im just wondering if the issue comes from my secrets.txt file

if you think it’s related to accessing secrets file, just type in the username, password, curuser and deviceid directly into the script, enclosed in quotes:

e.g.

USERNAME=‘YOUR EMAIL HERE’
PASSWORD=‘YOUR PASSWORD HERE’
CURUSER=‘1234567’
DEVICEID=‘1234567’

for startdate and enddate I have working:

STARTDATE=$(date +%s -d “28 day ago”)
ENDDATE=$(date +%s)

Did you guys found a solution? When I run ‘bash /config/withings/withings_battery.sh’ with Putty, it is working fine, email,password,userid,deviceid are all fine, but I still got error in the log file:

2018-01-06 21:45:31 ERROR (SyncWorker_12) [homeassistant.components.sensor.command_line] Command failed: /config/withings/withings_temp.sh

Command line cannot run the bash command.