This tool will publish JuiceBox data by using a Man in the Middle UDP proxy to MQTT that is auto-discoverable by HomeAssistant. The Enel X Way
app will continue to function.
It can also publish the IP of the proxy to the JuiceBox directly to avoid using custom local DNS servers using the update_udpc
and juicebox_host
command line parameters.
Builds upon work by lovely folks in this issue: https://github.com/home-assistant/core/issues/86588
Hopefully we won't need this if EnelX fixes their API!
juicepassproxy
on have internal, static IPs on your intranet.If JUICEBOX_HOST
is defined, it will run a telnet script to get the EnelX Server and Port as well as the JuiceBox ID.
If ENELX_IP
is not defined, it will use the CloudFlare DNS (1.1.1.1) to get the IP address of the EnelX Server and avoid a DNS lookup loop.
If LOCAL_IP
is not defined, it will lookup the Local IP address of the Docker.
If UPDATE_UDPC
is true, JuicePass Proxy will continually update the JuiceBox via telnet to send its data to JuicePass Proxy. Use this if you are not able to change your DNS to route the JuiceBox traffic to JuicePass Proxy.
Pick One Option:
A. Configure your DNS server running on your network (like Pi-hole or your router) to route all UDP traffic from your JuiceBox to the machine running this proxy. Instructions for how to do this will vary by router. See Getting EnelX Server IPs for instructions on what EnelX Server you need to override.
B. Set these Docker Environment Variables in your Docker Compose file:
UPDATE_UDPC=true
JUICEBOX_HOST=<IP address of your JuiceBox>
JPP_HOST=<IP address of the machine that the JuicePass Proxy Docker Container is running on>
C. Use your router to redirect traffic from JuiceBox to JuicePass Proxy
Check the port that your JuiceBox is using to communicate. See Getting EnelX Server IPs
Create a redirect rule on your router redirect UDP traffic coming from JuiceBox to the IP:PORT where you are running JuicePass Proxy
Create a masquerade rule on router to masquerade the traffic that goes to JuicePass Proxy IP:PORT (hairpin nat)
Depending of your forward rules, you may need to create an extra rule to allow that forwarding traffic
Sample MikroTik rules for reference (10.1.12.230 = JuiceBox, 10.1.0.22 = JuicePass Proxy)
add action=dst-nat chain=dstnat comment=juicebox dst-port=8042 protocol=udp src-address=10.1.12.230 to-addresses=10.1.0.22 to-ports=8042
#
add action=masquerade chain=srcnat comment=juicebox dst-address=10.1.0.22 dst-port=8042 protocol=udp src-address=10.1.12.230
Add the juicepassproxy
container to your Docker Compose file.
A. Set ports:
to the port listed in the UDCP line, likely 8047
(see Getting EnelX Server IPs).
B. Define the applicable environment variables (see Docker Environment Variables).
C. Specify the location for the config and optionally the logs folder
Start the Docker container.
networks:
default:
driver: bridge
ipam:
config:
- subnet: 172.16.100.0/24
services:
juicepassproxy:
image: ghcr.io/snicker/juicepassproxy:latest
hostname: juicepassproxy
container_name: juicepassproxy
restart: unless-stopped
logging:
driver: json-file
ports:
- 8047:8047/udp
environment:
- JUICEBOX_HOST=10.100.50.30
- UPDATE_UDPC=true
- JPP_HOST=10.100.200.50
- MQTT_HOST=10.100.200.5
- MQTT_USER=mosquitto
- MQTT_PASS=***
volumes:
- /etc/localtime:/etc/localtime:ro
- ./config:/config
- ./log:/log #Optional
Variable | Required | Description & Default |
---|---|---|
JUICEBOX_HOST | RecommendedRequired if Update UDPC is True. | If defined, will attempt to get the EnelX Server Name, IP, and Port using telnet. |
UPDATE_UDPC | No | Default: false. If true, will continually update the JuiceBox via telnet to point to JuicePass Proxy. |
TELNET_TIMEOUT | No | Default: 30. Timeout in seconds for telnet operations. |
JPP_HOST | Required if Update UDPC is True | This is the IP or Hostname of the machine where JuicePass Proxy is running (not the IP of the Docker Container) |
MQTT_HOST | No | 127.0.0.1 |
MQTT_PORT | No | 1883 |
MQTT_USER | No | |
MQTT_PASS | No | |
MQTT_DISCOVERY_PREFIX | No | homeassistant |
To get the destination IP:Port of the EnelX server, telnet into your JuiceBox device:
$ telnet 192.168.x.x 2000
and type the list
command:
list
! # Type Info
# 0 FILE webapp/index.html-1.4.0.24 (1995, 0)
# 1 UDPC juicenet-udp-prod3-usa.enelx.com:8047 (26674)
The address is in the UDPC
line. Run, ping
, nslookup
, or similar command to determine the IP.
As of November, 2023: juicenet-udp-prod3-usa.enelx.com
= 54.161.185.130
.