# -------------------------------- UPSCALE HOME ASSISTANT ------------------------------ # ------------- UP-SCALES.COM SCALE <-> HOME ASSISTANT (CONFIGURATION EXAMPLE) ---------- # -------------------------------------------------------------------------------------- # TWO WAYS BETWEEN AN UP↑SCALE SCALE IN YOUR WIFI NETWORK AND HOME ASSISTANT: # A) ROOM VALUES TO THE SCALE: HOME ASSISTANT PUBLISHES TEMPERATURE, HUMIDITY AND AIR # PRESSURE OF YOUR SENSORS TO AN MQTT TOPIC - THE SCALE READS THEM (ROOM LIMITS, AIR # BUOYANCY CORRECTION, THE "env" OF ITS RECORDS). # B) THE WEIGHT TO HOME ASSISTANT: A REST SENSOR READS GET /api/weight OF THE SCALE # (AND ITS STATUS PAGE FOR THE ROOM VALUES THE SCALE HAS). # -------------------------------------------------------------------------------------- # ^^^ A WORKING EXAMPLE - COPY IT AND CHANGE IT AS NEEDED! # -------------------------------------------------------------------------------------- # SENSORS OF THE SCALE (MQTT): https://up-scales.com/manual.html#WiFiSensors # WEIGHT STREAMS (GET /api/weight): https://up-scales.com/manual.html#WiFiStreams # ALL EXAMPLES FOR YOUR IT: https://up-scales.com/hardware/integration-lims-webhook-api-examples.html#examples # -------------------------------------------------------------------------------------- # (C) Johann Anderson, 2025-2026 http://farm23.es # -------------------------------------------------------------------------------------- # MIT License - Copyright (c) 2025-2026 Johann Anderson # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to the following # conditions: The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -------------------------------------------------------------------------------------- # # 1st: What you need: # # A) Home Assistant with the MQTT integration and a broker (e.g. the Mosquitto add-on). # In the app (ENTERPRISE, the scale in your WiFi network): LINK -> # 🌡 Sensors of the scale -> Broker mqtt://:1883 with the user and # password of the broker -> a source of the kind MQTT, topic "lab/room", the values # temperature + humidity + pressure ticked, the JSON paths empty (= these names). # Optional per value: room limits; "Keeps the air buoyancy correction up to date". # B) In the app: LINK -> 🔗 Webhook & JSON API -> 🔌 JSON API & weight streams -> "GET /api/weight # without the secret" ON (FREE; plain on purpose: anyone in your network can read it). # # Put the parts into your configuration.yaml (or the automation into automations.yaml), # change the entity ids and the address of the scale (fixed address in your router, or # upscale-.local), then: Developer tools -> YAML -> check and restart. # The syntax is the one of Home Assistant 2024.10 and newer (triggers: / actions:). # -------------------------------------------------------------------------------------- # ---------- A) room values to the scale over MQTT ---------- automation: - alias: "UP-SCALE: room values to the scale" id: upscale_room_values mode: queued triggers: # on every change of one of your sensors ... - trigger: state entity_id: - sensor.lab_temperature - sensor.lab_humidity - sensor.lab_pressure # ... and every 5 minutes (the scale counts a value only for the time set at the source) - trigger: time_pattern minutes: "/5" conditions: # (no value while a sensor is "unavailable" - a 0 would be a wrong room value) - condition: template value_template: >- {{ states('sensor.lab_temperature') | is_number and states('sensor.lab_humidity') | is_number and states('sensor.lab_pressure') | is_number }} actions: - action: mqtt.publish data: topic: lab/room # retained: the scale gets the last value at once when it connects retain: true # °C, % RH, hPa (a sensor in another unit: convert it here, e.g. | float * 33.8639 for inHg) payload: >- {"temperature": {{ states('sensor.lab_temperature') | float | round(2) }}, "humidity": {{ states('sensor.lab_humidity') | float | round(1) }}, "pressure": {{ states('sensor.lab_pressure') | float | round(1) }}} # ---------- B) the weight (and the room values of the scale) to Home Assistant ---------- rest: - resource: http://192.168.1.50/api/weight # {"ok":true,"grams":12.34,"stable":true,"unit":"g","time":,"page":0} scan_interval: 5 timeout: 5 sensor: - name: "UP-SCALE weight" unique_id: upscale_weight value_template: "{{ value_json.grams }}" unit_of_measurement: "g" device_class: weight state_class: measurement binary_sensor: - name: "UP-SCALE stable" unique_id: upscale_stable value_template: "{{ value_json.stable }}" - resource: http://192.168.1.50/status.json # the status page of the scale (always open in the WiFi network): "sensors" = the sources of the scale, # [{"src":1,"kind":4,"state":2,"age":3,"v0":21.4,"v1":45.2,...}] - v0 °C, v1 % RH, v2 hPa, v3 / v4 your own scan_interval: 60 sensor: - name: "UP-SCALE room temperature" unique_id: upscale_room_temperature # (the first source of the scale; another one: sensors[1], ...) value_template: "{{ value_json.sensors[0].v0 if value_json.sensors else none }}" unit_of_measurement: "°C" device_class: temperature - name: "UP-SCALE free memory" unique_id: upscale_heap value_template: "{{ value_json.heap }}" unit_of_measurement: "B" entity_category: diagnostic # A faster weight (every change, up to 20 a second): the UDP broadcast or the WebSocket # stream of the scale (upscale-udp.py / upscale-stream.py next to this file) - e.g. through # Node-RED into Home Assistant. Every 5 s with the REST sensor is enough for a display.