Connecting the Medisana BS440 Bluetooth scale (part 5)

Triggered by a comment on episode 1 of this blog i decided to use Domoticz to visualize the measurements in a graph. I use Domoticz to control my home since july 2013 and it has proven to be very reliable.

To graph the weight first a “virtual sensor” must be created. First find a unique index and paste the url below in your browser:

http://domoticzip:8080/json.htm?type=command&param=udevice&hid=2&did=60&dunit=4&
dtype=93&dsubtype=1&nvalue=0&svalue=75.0
* did=60 represents the device ID number for this device 
  (could be any unique number). Make a note of it. 
  Upon creation the device will be given an unique index.
* dtype=93 refers to the BWR102 device, a Oregon Scientific connected scale we mimic.
* svalue=75.0 refers to the weight. Every call to this URL will update the value.

After creation of the virtual sensor, push the green button to have the sensor showing up on the “Other devices” tab:

Domoticz1

Other Devices tab:

Domoticz2

Now the sensors are ready the BS440 program can call the sensor URL with the appropriate Device number and weight (see BS440domoticz.py). In the .ini file the Domoticz connection parameters (IP-adres and username/password) can be entered.

Now every time a user steps on the scale the weight will be logged and graphed.

Domoticz3

To have consistent results it is advised to do your weighings at the same time of day. In my case this will be between 07:00 and 08:00 in the morning (8:00 – 11:00 in the weekends). I use an IP controlled switch based on a Sonoff ESP8266 based 220V switch flashed with ESP Easy firmware. Now Domoticz can switch on/off the Raspberry through WiFi by calling the ip address of the Sonoff like

http://ip-address/control?cmd=gpio,12,1 (=on) 
http://ip-address/control?cmd=gpio,12,0 (=off)

Domoticz4

Before switching off at 8:15 (11:15 in the weekeinds) be sure that a cron job did a shutdown earlier to not corrupt the flash card. Also when powering up, the “python BS440.py” needs to be started automatically through BS440.sh and a @reboot cron. These are the cron definitions to accomplish this:

@reboot sh /home/pi/BS440.sh > /home/pi/cronlog 2&1
0 8 * * 1,2,3,4,5 sudo shutdown -h +0
0 11 * * 0,6 sudo shutdown -h +0 

A 1 minute sleep is inserted in BS440.sh to have a stable booted Raspberry before starting the bluetooth communications in background.


#!/bin/sh
cd /
cd home/pi
sleep 1m
sudo python BS440.py &
cd /
Advertisements
This entry was posted in FF32 and tagged , , , , , , , . Bookmark the permalink.

49 Responses to Connecting the Medisana BS440 Bluetooth scale (part 5)

  1. Elkin says:

    Thanks! got it to work with my BS444 and a Raspberry Pi.

    Liked by 1 person

  2. keptenkurk says:

    Nor am i:-)
    I merged the code and tried to get it running. Could you respond to the new issues i logged on Github? I’m not sure i know what i’m doing…

    Like

  3. To be honest, the documentation on how to install and run your code sucks. The documentation lacks some very important info. What file\script to run after installation? Where to install the code?

    If I run a .py script, the only thing I get is errors. If I run the BS440.py script, I get the following output:
    from: can’t read /var/mail/__future__
    ./BS440.py: line 2: import: command not found
    ./BS440.py: line 3: import: command not found
    from: can’t read /var/mail/ConfigParser
    ./BS440.py: line 5: import: command not found
    ./BS440.py: line 6: import: command not found
    from: can’t read /var/mail/struct
    from: can’t read /var/mail/binascii
    from: can’t read /var/mail/BS440decode
    from: can’t read /var/mail/BS440mail
    from: can’t read /var/mail/BS440domoticz
    from: can’t read /var/mail/BS440google
    ./BS440.py: line 16: syntax error near unexpected token `(‘
    ./BS440.py: line 16: `def processIndication(handle, values):’

    Installed the files on a Raspberry Pi 2 in /opt/BS440

    Like

  4. MD says:

    Got this working with a Medisana BS430 scale, which seems to be a white version of the BS440. Thanks for your building and sharing this!

    Liked by 1 person

  5. DjZU says:

    Many thanks for your work! It works for me with the BS444.
    I use Domoticz for another project but I don’t find it handy in this application. So I’ve been working on two “modules”:
    – the first one is writing the results to a csv file for each person;
    – the second one read the results from the csv file and plot them using python offline plotly to draw beautiful charts and display them inside the local browser.
    I can share the code if someone is interested in.

    Liked by 2 people

    • keptenkurk says:

      That’s a nice addition and glad you can use it with your BS444 also. It would be nice to share a link here. I’ve thought about uploading the data to Google docs but never got to it.

      Like

  6. genlinut says:

    Yahh, many thanks! Here it also works with the BS444.
    For my training stats i use https://github.com/Runalyze/Runalyze. I modified your code and added some new to automatically update self hosted installations with fresh body data. I created a fork on GitHub and started a pull request so you can merge the patch.

    Liked by 1 person

  7. giovanne says:

    Thanks for the great work.
    I also try to get it running with BS444, but currently I got a “pygatt.exceptions.BLEError: No characteristic found matching 00008a22-0000-1000-8000-00805f9b34fb”

    Is there something to customize for the BS444?

    Here ist the output from BS440.py and the log:
    root@Pi:/home/pi/BS440# sudo python BS440.py
    Traceback (most recent call last):
    File “BS440.py”, line 131, in
    indication=True)
    File “/usr/local/lib/python2.7/dist-packages/pygatt/device.py”, line 131, in subscribe
    self._notification_handles(uuid)
    File “/usr/local/lib/python2.7/dist-packages/pygatt/device.py”, line 107, in _notification_handles
    value_handle = self.get_handle(uuid)
    File “/usr/local/lib/python2.7/dist-packages/pygatt/device.py”, line 195, in get_handle
    raise exceptions.BLEError(message)
    pygatt.exceptions.BLEError: No characteristic found matching 00008a22-0000-1000-8000-00805f9b34fb

    Log:
    Thu, 02 Mar 2017 21:24:29 INFO BS440 Started
    Thu, 02 Mar 2017 21:24:30 INFO init_ble_mode hci0 Set Low Energy complete, settings: powered bondable ssp br/edr le

    Thu, 02 Mar 2017 21:24:33 DEBUG start gatttool_cmd=gatttool -i hci0 -I
    Thu, 02 Mar 2017 21:24:35 INFO scan Starting BLE scan
    Thu, 02 Mar 2017 21:24:35 INFO run Running…
    Thu, 02 Mar 2017 21:24:46 INFO scan Discovered F1:9D:81:0A:39:93 (01319793390A819DF1)
    Thu, 02 Mar 2017 21:24:46 INFO scan Found 1 BLE devices
    Thu, 02 Mar 2017 21:24:46 INFO connect Connecting to F1:9D:81:0A:39:93 with timeout=5
    Thu, 02 Mar 2017 21:24:47 DEBUG get_handle Looking up handle for characteristic 00008a22-0000-1000-8000-00805f9b34fb
    Thu, 02 Mar 2017 21:24:48 DEBUG _save_charecteristic_callback Found characteristic 00002a00-0000-1000-8000-00805f9b34fb, value handle: 0x3
    Thu, 02 Mar 2017 21:24:48 DEBUG _save_charecteristic_callback Found characteristic 00002a01-0000-1000-8000-00805f9b34fb, value handle: 0x5
    Thu, 02 Mar 2017 21:24:49 DEBUG _save_charecteristic_callback Found characteristic 00002a04-0000-1000-8000-00805f9b34fb, value handle: 0x7
    Thu, 02 Mar 2017 21:24:49 DEBUG _save_charecteristic_callback Found characteristic 00002a25-0000-1000-8000-00805f9b34fb, value handle: 0xb
    Thu, 02 Mar 2017 21:24:50 DEBUG _save_charecteristic_callback Found characteristic 00002a27-0000-1000-8000-00805f9b34fb, value handle: 0xe
    Thu, 02 Mar 2017 21:24:50 DEBUG _save_charecteristic_callback Found characteristic 00002a26-0000-1000-8000-00805f9b34fb, value handle: 0x11
    Thu, 02 Mar 2017 21:24:50 DEBUG _save_charecteristic_callback Found characteristic 00002a29-0000-1000-8000-00805f9b34fb, value handle: 0x14
    Thu, 02 Mar 2017 21:24:50 WARNING get_handle No characteristic found matching 00008a22-0000-1000-8000-00805f9b34fb
    Thu, 02 Mar 2017 21:24:50 DEBUG _save_charecteristic_callback Found characteristic 00002a28-0000-1000-8000-00805f9b34fb, value handle: 0x17
    Thu, 02 Mar 2017 21:24:50 DEBUG _save_charecteristic_callback Found characteristic 00008a21-0000-1000-8000-00805f9b34fb, value handle: 0x1b

    Like

    • keptenkurk says:

      You’re welcome! Funny, i just saw exact the same error yesterday morning. We are renovating the bathroom so the scale got a temporary place. As it seems, the distance from BLE adapter to scale shouldn’t be to far. Only 1 meter works best. I’m seeing these errors when the scale is further away. Could you give that a try?

      Like

      • giovanne says:

        Thanks, I will give it a try and let you know.
        But currently I have a different problem. The updated pi from wheezy to jessie was more and more struggling.
        So I have to go back to my backup wheezy image.
        But there I get always a connection time out when the BS400.py is trying to connect 😦
        And manually with ‘gatttool -i hci0 -b -I’ and trying to ‘ connect ‘ I get “Host is down (112)”

        Not so simple like I was hoping 😦

        Like

      • keptenkurk says:

        Ouch! Know what you’re going through. These BLE mysteries took me 3 months of frustration. The references to the “Host is down” error basically reinstall the whole thing. I did a complete reinstall from scratch lately and logged all the individual steps. Will do a write up as part 6.

        Like

  8. giovanne says:

    Thanks, for the info.
    I’m very interresting in part 6 – cant wait so long 😉
    Do you think it should also work under wheezy (no systemctl), because normally I only want to add the function only to my running pi in the bathroom. Update to jessie results in problems with my other functions on the pi 😦
    Im waiting for part 6 and will see…
    Thanks

    Liked by 1 person

    • keptenkurk says:

      Part 6 (Epilogue) is there 🙂 However, based on Jessie, sorry!

      Like

      • giovanne says:

        Thank you!!!!
        I have set up one of my Pi B+ and used your Part 6 instructions.
        It is working directly 🙂
        And BS440 in version v2.0.0
        – with plugins 😉
        – with web server 🙂 🙂
        Great work.

        Now my next step is to deside, move over all my bathroom functions to the Pi B+/Jessie or go on trying to get the Pi B/Wheezy working with your scripts.
        On wheezy on problem already solved:
        – in ‘gatttool.py’ -> changed to ‘subprocess.Popen([“sudo”, “invoke-rc.d”, “bluetooth”, “restart”]).wait()’
        The problem I have is that, manually trying to connect with:
        – sudo gatttool -b F1:9D:81:0A:39:93 -I => connect: No route to host (113)
        – sudo gatttool -t random -b F1:9D:81:0A:39:93 -I => Unknown option -t
        Hm, gatttool to old ???
        Will go on trying…

        Liked by 1 person

  9. giovanne says:


    The problem I have is that, manually trying to connect with:
    – sudo gatttool -b F1:9D:81:0A:39:93 -I => connect: No route to host (113)

    hci was down -> sudo hciconfig hci0 up
    Now back to error:
    –> Connecting… connect error: Host is down (112)
    😦 – will go on trying …

    Liked by 1 person

    • giovanne says:

      … oh no, the copiled bluez version 5.44 wasn’t used. Version 4.99 from previous installation via apt-get/dpkg was used.

      But after make install of version 5.44 and reboot,
      ‘hciconfig’ isn’t found 😦

      Liked by 1 person

      • keptenkurk says:

        At my RPi hciconfig is in the /bin folder. Is /bin in the search path?
        Great to read that you were at least successfull in getting it run in Jessie. What other bathroom functionality is having trouble with Jessie?
        The Domoticz plugin needs some rework/testing as well as the googleFit thing…
        All credits for the CSV and webserver part go to DjZU !!

        Like

      • giovanne says:

        Compiled 5.43 the same way: hciconfig is ok. In 5.44 it wasn’t installed (or compiled?)
        Have to copy gatttool manually from attrib/gatttool to /usr/bin

        Now I am back at with wheezy:
        pygatt.exceptions.BLEError: No characteristic found matching 00008a22-0000-1000-8000-00805f9b34fb

        Will try the distance tomorrow. It is ~1,5m at the moment.

        Liked by 1 person

  10. giovanne says:

    Yes 😉
    You were right, my last problem was the distance from the bt-dongle to the scale.
    I have attached an extension usb cable between the pi/hub and the bt-dongle. Now the dongle is ~20-30cm from the scale and working excellent also on wheezy. So I can stay with my bathroom pi 😉

    Last problem I have, currently there wasn’t an initscript (/etc/init.d/bluetooth) installed with bluez. Will have a look how to solve this. (in Jessie you are using systemd/systemctl)
    Question: what was the reason for every reset? Because currently it is working without for me.

    I have started to write a modified plugin for inserting the data to my mysql db (db, table, cols customizable). (modification from the runalyzer plugin)

    First test with the webserver/plot-plugin was starting the webserver, displaying the persons, but when selecting a person there wasn’t a plot/graph
    -> will go on trying, I think I have done something wrong 😦

    Questions:
    – I think a filter would be nice, because if you haven’t done 30 measures, then you get datas with timestamp like 226428524 from 05.03.1977 or is there a mistake?
    – Is there a posibility to also get information from the scale about the power status (time to change batteries)? Or is every information from the scale known?
    – Do you know if it is possible to reset/delete all data for one/all users on the scale?

    So now I will start checking if everything is working well, filling my db and visualize the data.

    Thanks you very much 😉

    Liked by 1 person

    • DjZU says:

      Hi giovanne,

      The web server is plotting from a CSV file meaning you need the CSV plugin activated and the CSV file populated with data. If you’re redirected to the “Persons” welcome page, that’s probably the case, otherwise check /path/to/BS440/plugins/BS440webapp/BS440plot.log
      Once you get it working, you’ll see that it is already implementing a filter. See that you’ll land on a page at IP:5440/1/31 for person 1 and showing data from last 31 days. You can change 31 to any value of your choice. As soon as you don’t enter something like 18000 you won’t see the 70’s timestamped measurements.

      Regarding the battery level, according to this page (https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.service.battery_service.xml) there should be something in handle 0x180F but that should be checked playing with gatttool (don’t remember what ‘primary’ returns)

      Liked by 1 person

    • keptenkurk says:

      “Question: what was the reason for every reset?” This is explained in https://github.com/keptenkurk/BS440/issues/33. Thanks to DjZU this was solved when hcitool is used without superuser rights. I don’t know how to reset data from the scale… Investigating reading battery level would be a nice addition. Will create a request on Github. In my experience these batteries last very long.

      Like

  11. giovanne says:

    First it is running well 😉

    But two questions:
    1. I can wait until I have 30 measures, but were is the mistake when I get some of the 226182221 timestamp in the csv output?:
    1488864943,…
    226128774,…
    226182221,…
    226395562,…
    1488951287,…
    1489037949,…
    1489123630,…
    1489216160,…
    1489304069,…
    1489383260,…
    1489469933,…
    1489555988,….
    1489642547,…

    Maybe they are some wrong measurements? I don’t know how I have created them.
    Currently it is working well and the timestamps are correct.

    Were in BS440.py … can I prevent these?

    2. Is the BMI on the scale calculated right for you? I got everytime something around 3049 !?!?

    Like

    • giovanne says:

      Workaround for 1: I am doing a check in my msqldb plugin:

      if (weightdata[i][‘timestamp’] > 1400000000 ):
      log.info(sql_cmd)
      a = cur.execute(sql_cmd)

      Like

  12. keptenkurk says:

    @Giovanne, with a BMI of 3049 you’re in serious trouble 😉
    The BMI formula is BMI = weight / (size*size) where weight in kg and size in meter. The ini file should have your size in cm.
    Or is the problem in the way your BMI field is defined in the sql table?

    Like

    • giovanne says:

      Oh shit, I mean ‘Verbruik (kCal)’ is 3049
      Online calculators calculate only 1881 for my size, weight, age…
      But the scale is displaying it itself wrong.

      Another question, today I got first time the following error. Want does it mean?
      Fri, 17 Mar 2017 06:38:02 INFO char_write_handle Sent cmd=char-write-req 0x23 023976cb58
      Fri, 17 Mar 2017 06:38:02 INFO Waiting for notifications for another 30 seconds
      Fri, 17 Mar 2017 06:38:32 INFO Done receiving data from scale Fri, 17 Mar 2017 06:38:32 ERROR Unreliable data received. Unable
      to process Fri, 17 Mar 2017 06:38:32 INFO scan Starting BLE scan
      Fri, 17 Mar 2017 06:38:42 INFO scan Found 0 BLE devices Fri, 17 Mar 2017 06:38:42 INFO scan Starting BLE scan

      Like

      • giovanne says:

        – today it was ok, no error like yesterday:
        Fri, 17 Mar 2017 06:38:32 ERROR Unreliable data received. Unable
        to process

        – what is your value for “Verbruik (kCal)” on the scale itself, realistic?

        Like

      • keptenkurk says:

        @Giovanne, The error you saw typically comes from a bad BT connection. It happens once in a while. But luckily the values are saved on the scale and will be transferred the next weiging.
        Also i would not rely too much on the values shown. In my case i’m on 2550 kCal (1m82, 74kg, 53 years). The only measurements are weight and resistance between left and right foot. The last one is very unreliable. I’ve seen the calculations somewhere (don’t remember where) and it appeared that most of the results are based on weight, height, age, sex. Haven’t monitored others values than weight over a longer time but i suspect they will vary along with the weight.

        Like

  13. DjZU says:

    It would need some data analysis with solvers to find out how the scale actually calculate the caloric needs, considering possible limitations with floating numbers.
    According to this page (https://www.freedieting.com/calorie_needs.html) with Mifflin – St Jeor formula (10 x weight (kg) + 6.25 x height (cm) – 5 x age (y) + 5 ), in my case I found that the scale would apply a coefficient of about 1.57 which is quite big since I did not set activity as high on the scale (2552kcal, 63.7kg, 1m78, 27y).

    While designing the webapp that plot charts, in a first attempt I drew every data as a curve (weight, fat, muscle, water, kcal, bone) and then found that they were not very relevant. As far as I remember the fat, muscle and water curves were the same shape, any muscle gain would be reflected as fat loss for instance, they are percentages. So I finally chose to draw a curve only for the weight, and display the other data as gauge or variation.

    I believe the resistance measurement is not that bad, but it is the only input together with weight to generate all data so it makes sense that the values are inherently linked.

    Liked by 1 person

  14. DjZU says:

    It would be interesting to actually find out the formulas used by the scale so we can guess the measured resistance, store it together with the weight and timestamp only, and then recalculate tbw, fat%, muscle% on the fly when needed and the way wanted. That would allow features such as taking in account one’s attributes:
    “From the TBW figure Fat and Lean masses can similarly be estimated using a variety of formula that ideally ALSO incorporate known health attributes (eg. Diabetes, Renal disease, Pregnancy, breastfeeding …), activity level and race.”
    https://www.quora.com/How-do-bathroom-scales-that-calculate-body-fat-water-muscle-bone-kcal-actually-work-And-are-they-accurate

    Liked by 1 person

  15. DjZU says:

    @giovanne I suspect you got the Basal Metabolic Rate (BMR) from the online calculator while the scale gives the Total Daily Energy Expenditure (TDEE). The BMR represents the calorie needs for surviving bound at bed basically while TDDE integers activity (which can be set as normal or high on the scale).

    Liked by 1 person

  16. Meier says:

    Hi Keptenkurk,

    so far: sudo journalctl -l -f -u bs440 shows me, that the scale’s data is being transmitted. What I am having trouble with is domoticz and email.
    I have added a virtual device just as explained here:
    https://www.domoticz.com/wiki/Virtual_meter

    Create dummy hardware and device
    Go to Setup -> Hardware
    Name: anything, e.g. “Medisana” (this name is only used internally)
    Type: “Dummy (does nothing, use for virtual switches only)”
    Click on ‘Add’
    Click on ‘Create Virtual Sensors’ from the table of hardware above
    Name: anything, e.g. “Medisana” (this name is displayed on the dashboard etc.)
    Sensor type: “Scale(Weight)”
    Click ‘Ok’

    Idx: 1
    Hardware: Medisana
    ID: 82001
    Unit: 1
    Name: Medisana
    Type: Weight
    SubType: BWR102
    Data 0kg
    [RF Signal Level]
    [Battery Level]
    Last Seen2018-07-24 18:08:10

    with:
    https://192.168.178.20/json.htm?type=devices&rid=82001
    I get:
    “ActTime” : 1532449050,
    “AstrTwilightEnd” : “00:00”,
    “AstrTwilightStart” : “00:00”,
    “CivTwilightEnd” : “22:17”,
    “CivTwilightStart” : “04:37”,
    “DayLength” : “16:08”,
    “NautTwilightEnd” : “23:24”,
    “NautTwilightStart” : “03:29”,
    “ServerTime” : “2018-07-24 18:17:30”,
    “SunAtSouth” : “13:05”,
    “Sunrise” : “05:23”,
    “Sunset” : “21:31”,
    “app_version” : “4.9700”,
    “status” : “OK”,
    “title” : “Devices”
    }

    with:
    http://192.168.xxx.xxx:8080/json.htm?type=command&param=udevice&hid=2&did=82001&dunit=4&dtype=93&dsubtype=1&nvalue=0&svalue=75.0
    I get
    {
    “status” : “ERR”
    }
    Any idea what I don’t see/didn’t read/overlooked?
    I hope you have time to reply. Thank you in advance. Great Project!
    All the best
    Hans

    Liked by 1 person

    • keptenkurk says:

      @Meier, indeed on the last URL you should receive

      {
      “status” : “OK”,
      “title” : “Update Device”
      }

      I notice however that when i issue this URL

      http://domoticz_ip:8080/json.htm?type=devices&rid=29 (where 29 is the device number in Idx column in Domoticz devices)

      the response is quite different:

      {
      “ActTime” : 1532456047,
      “ServerTime” : “2018-07-24 20:14:07”,
      “Sunrise” : “05:52”,
      “Sunset” : “21:37”,
      “result” : [
      {
      “AddjMulti” : 1.0,
      “AddjMulti2” : 1.0,
      “AddjValue” : 0.0,
      “AddjValue2” : 0.0,
      “BatteryLevel” : 255,
      “CustomImage” : 0,
      “Data” : “74.8 kg”,
      “Description” : “”,
      “Favorite” : 1,
      “HardwareID” : 2,
      “HardwareName” : “Dummy”,
      “HardwareType” : “Dummy (Does nothing, use for virtual switches only)”,
      “HardwareTypeVal” : 15,
      “HaveTimeout” : false,
      “ID” : “60”,
      “LastUpdate” : “2018-07-24 20:09:54”,
      “Name” : “Paul”,
      “Notifications” : “false”,
      “PlanID” : “0”,
      “PlanIDs” : [ 0 ],
      “Protected” : false,
      “ShowNotifications” : true,
      “SignalLevel” : “-“,
      “SubType” : “BWR102”,
      “Timers” : “false”,
      “Type” : “Weight”,
      “TypeImg” : “scale”,
      “Unit” : 4,
      “Used” : 1,
      “XOffset” : “0”,
      “YOffset” : “0”,
      “idx” : “29”
      }
      ],
      “status” : “OK”,
      “title” : “Devices”
      }

      I think you refer to the device ID in the ID column !
      So in your case you should refer to Idx =1 (for rid and did fields in both URL’s)

      I’m on Domoticz 3.8153 the latest stable AFAIK.
      I also notice that you are using https with the default port. On both URL’s ?
      FInally: As there is no basic authentication in the URL (http://user:pwd@ip:8080/etc) it is assumed that local users do not need authentication (in Domoticz in settings|System add 27.0.0.*;192.168.1.* to local networks).

      You mention also having problems with email. Whats the trouble there?

      When you have fixed the above you might run into trouble getting the Domoticz integration to work. It was reworked to auto create devices but i never tested that code myself.

      Hope to hear your progress soon!

      Like

  17. Meier says:

    Hi keptenkurk,

    thank you for your fast response.
    You were right about the first link I posted: Instead of rid=82001, it should have been 1, like this:
    https://192.168.178.20/json.htm?type=devices&rid=1
    Here is the response, (I just changed address to Germany in General (53.583500/9.973690):
    {
    “ActTime” : 1532517920,
    “AstrTwilightEnd” : “00:24”,
    “AstrTwilightStart” : “02:25”,
    “CivTwilightEnd” : “21:58”,
    “CivTwilightStart” : “04:52”,
    “DayLength” : “15:43”,
    “NautTwilightEnd” : “22:55”,
    “NautTwilightStart” : “03:54”,
    “ServerTime” : “2018-07-25 13:25:20”,
    “SunAtSouth” : “13:05”,
    “Sunrise” : “05:33”,
    “Sunset” : “21:16”,
    “app_version” : “4.9700”,
    “result” : [
    {
    “AddjMulti” : 1.0,
    “AddjMulti2” : 1.0,
    “AddjValue” : 0.0,
    “AddjValue2” : 0.0,
    “BatteryLevel” : 255,
    “CustomImage” : 0,
    “Data” : “0 kg”,
    “Description” : “”,
    “Favorite” : 0,
    “HardwareID” : 3,
    “HardwareName” : “Medisana”,
    “HardwareType” : “Dummy (Does nothing, use for virtual switches only)”,
    “HardwareTypeVal” : 15,
    “HaveTimeout” : false,
    “ID” : “82001”,
    “LastUpdate” : “2018-07-24 18:08:10”,
    “Name” : “Medisana”,
    “Notifications” : “false”,
    “PlanID” : “0”,
    “PlanIDs” : [ 0 ],
    “Protected” : false,
    “ShowNotifications” : true,
    “SignalLevel” : “-“,
    “SubType” : “BWR102”,
    “Timers” : “false”,
    “Type” : “Weight”,
    “TypeImg” : “scale”,
    “Unit” : 1,
    “Used” : 1,
    “XOffset” : “0”,
    “YOffset” : “0”,
    “idx” : “1”
    }
    ],
    “status” : “OK”,
    “title” : “Devices”
    }
    In the top part is a difference.

    It doesn’t matter if I change your did=60 in
    http://domoticzip:8080/json.htm?type=command&param=udevice&hid=2&did=60&dunit=4&dtype=93&dsubtype=1&nvalue=0&svalue=75.0
    to
    http://192.168.xxx.xxx:8080/json.htm?type=command&param=udevice&hid=2&did=1&dunit=4&dtype=93&dsubtype=1&nvalue=0&svalue=75.0
    or
    http://192.168.xxx.xxx:8080/json.htm?type=command&param=udevice&hid=2&did=82001&dunit=4&dtype=93&dsubtype=1&nvalue=0&svalue=75.0
    All I get is:
    {
    “status” : “ERR”
    }

    Any idea? 127.0.0.* and 192.168.178.*, separated by a semicolon are allowed to talk to the server without passwords

    Perhaps we should use pastebin for further json exchanges? https://paste.debian.net/

    Here some pictures:
    #####Devices:
    [img]http://up.picr.de/33329332vw.jpg[/img]


    #####Hardware:
    [img]http://up.picr.de/33329345uf.jpg[/img]

    Like

  18. keptenkurk says:

    Hans,
    Could you try this url : (where x is replaced with your actual domoticz IP)
    https://192.168.178.x/json.htm?type=command&param=udevice&hid=2&did=1&dunit=4&dtype=93&dsubtype=1&nvalue=0&svalue=75.0

    SInce on the other commands you use https (http with TLS) on default port 443. Not sure if http (without encryption) on port 8080 is still serving… guess not.

    Like

  19. keptenkurk says:

    Thanks for pointing that there finally is a new Domoticz stable again. So i need to upgrade (which also requires updating the OS to stretch which will be quite a hassle)

    Like

  20. Meier says:

    Hi keptenkurk,
    too bad – same output
    {
    “status” : “ERR”
    }
    How can i get access to the domoticz database? How do I use the restAPI?
    Thank you for your help!!

    Like

  21. keptenkurk says:

    I tested some more andyou are right: Writing the virtual sensor uses the ID (your 82001) and not the did (your 1) ! Which you tested already. Maybe the new Domoticz version has a different API ? (no sign about that on the forum).
    The database is sqlite but i don’t know about the restAPI…

    Like

  22. Sjoerd91 says:

    I actually wanted to leave a post on the Domoticz forum, but registering seems to be a b*tch.

    The Domoticz plugin wasn’t working at all for me. I edited the file and posted it to pastebin.com:
    https://pastebin.com/U9Yd9MKu

    This version is working for me.

    Liked by 1 person

  23. keptenkurk says:

    Thanks for fixing this Sjoerd! Merged the code on Github !

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s