problem using json in container

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Post Reply
BartSr
Posts: 489
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

problem using json in container

Post by BartSr »

Hi! I am facing problems when I try to use json
Domoticz in docker.

Code: Select all

services:
  domoticz:
    image: domoticz/domoticz:stable
    container_name: domoticz
    restart: unless-stopped
    # Pass devices to container
    devices:
      - "/dev/serial/by-id/usb-RFXCOM_RFXtrx433_A1BFAMG-if00-port0:/dev/ttyUSB0"
    ports:
      - "8080:8080"
    volumes:
      - ./config:/opt/domoticz/userdata/
      # regel toegevoegd om extra schermen (custom) te bereiken
      - ./custom:/opt/domoticz/www/custom
    environment:
      - TZ=Europe/Amsterdam
      #- LOG_PATH=/opt/domoticz/userdata/domoticz.log
This does not work (404 error) (input from browser IP# and port are correct)

Code: Select all

http://192.168.2.100:8080/domoticz/json.htm?type=devices
Chatgpt says

Code: Select all

🔹 Important Point

In the Domoticz Docker image domoticz/domoticz:stable from version 2025.2:

The old /json.htm API is not available in this container build.

This image is mainly intended for GUI + plugins.

Any scripts that try to fetch data via /json.htm will always return 404.

So, regardless of roomplan or idx, you cannot use this API.
any idea? chatgpt propose to downgrade to older container which I don't think being a real solution

any suggestions?
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: problem using json in container

Post by jvdz »

Is localhost and/or. 127.0.0.1 part of the trusted networks in domoticz setup?
BartSr
Posts: 489
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

Re: problem using json in container

Post by BartSr »

In trusted networks:
192.168.2.*;127.0.0.*
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
User avatar
RonkA
Posts: 126
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: problem using json in container

Post by RonkA »

In my Docker setup inside my nas i can see under network it says bridge.
If i expand this line it reads that the gateway uses 127.17.0.1, so internal this is the first IP-adres used.
The second internal IP-adres is 127.17.0.2 and that is the IP-adres used for Domoticz inside the Docker-container in my setup..
This IP-adres i set into trusted networks and all worked for me..
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
BartSr
Posts: 489
Joined: Sunday 03 July 2016 16:16
Target OS: Raspberry Pi / ODroid
Domoticz version: V2024.7
Location: Netherlands
Contact:

Re: problem using json in container

Post by BartSr »

RonkA, thanks for your message. Are you using the official domoticz container? Is the bridge something being part of Nas network?
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: problem using json in container

Post by waltervl »

Chatgpt is partly right, you use an old API call. But the new one will work....
You have to use

Code: Select all

/json.htm?type=command&param=getdevices
See also wiki https://wiki.domoticz.com/Domoticz_API/ ... and_newer)

You probably used an example based on old API calls
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
RonkA
Posts: 126
Joined: Tuesday 14 June 2022 12:57
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Harlingen
Contact:

Re: problem using json in container

Post by RonkA »

I use the official container docker:latest on my Synology Nas, this is what i see:
docker1.PNG
docker1.PNG (45.55 KiB) Viewed 30 times
so for usage of json in scripts i use for example:

Code: Select all

-- Clear the log of the textdevice
        domoticz.openURL('http://127.17.0.2:80/json.htm?type=command&param=clearlightlog&idx=337') 
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest