Using json commands in combination with an username and password
Posted: Friday 22 June 2018 0:41
I'm trying to update an uservariable or counter with a json command, but there is a problem I'm getting an error. The goal is reading serial data from an other device trough USB and sending this data to Domoticz. And all of this using one python script.
First things first, I'm using a RaspberryPi 3 with Domoticz version 3.8153. And Raspbian version: 4.14.34-v7.
This is my server.
I'm sending from another Pi same type en Raspian version.
Using this script:
The problem is that I am using a username and password to login on Domoticz so it does not work.
I have tried the suggestion on the wiki.
http://<username:password@>domoticz-ip<:port>/json.htm?api-call
http://<username:password@>domoticz-ip<:port>/json.htm?api-call (username and password encoded using base64)
http://domoticz-ip<:port>/json.htm?username=MkE=&password=OVM=&api-call (username and password encoded using base64)
Not one of these work for me. Most of them give the error 401 Unauthorized. I tried using the curl command and pasting the url in my webbrowser google chrome.
Help would be appreciated.
Edit:
I think that I found the problem with the json commands. I made a separate user for sending the json commands, that was the problem. Apparently you have to use the credentials that are in the settings menu under website protection (see picture).

First things first, I'm using a RaspberryPi 3 with Domoticz version 3.8153. And Raspbian version: 4.14.34-v7.
This is my server.
I'm sending from another Pi same type en Raspian version.
Using this script:
Code: Select all
#!/usr/bin/python
import serial
import urllib2
ser = serial.Serial('/dev/ttyACM0',9600)
read_serial=ser.readline()
serverIP = "10.0.0.8:8080"
deviceId = 126
try:
urllib2.urlopen("http://" + serverIP + "/json.htm?type=command¶m=udevice&idx=" + str(deviceId) + "&svalue=" + str(read_serial), timeout=1)
print "Data sent!"
except:
print "Error"
I have tried the suggestion on the wiki.
http://<username:password@>domoticz-ip<:port>/json.htm?api-call
http://<username:password@>domoticz-ip<:port>/json.htm?api-call (username and password encoded using base64)
http://domoticz-ip<:port>/json.htm?username=MkE=&password=OVM=&api-call (username and password encoded using base64)
Not one of these work for me. Most of them give the error 401 Unauthorized. I tried using the curl command and pasting the url in my webbrowser google chrome.
Help would be appreciated.

Edit:
I think that I found the problem with the json commands. I made a separate user for sending the json commands, that was the problem. Apparently you have to use the credentials that are in the settings menu under website protection (see picture).
