Category: Domotica

  • Victron MQTT configurations

    Add the following code to your mqtt.yaml file:

    sensor:
      # Grid meter power
      - state_topic: "venus-home/N/c0619xxxxxx/grid/30/Ac/Power"
        name: "Grid power"
        unique_id: "grid_meter_power"
        device_class: power
        value_template: '{{ value_json.value | round(0) }}'
        unit_of_measurement: "W"
        icon: mdi:TransmissionTower
    
      # Victron alarms
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/CellImbalance"
        name: "Alarm cell imbalance"
        unique_id: "alarm_battery_cell_imbalance"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
          
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/ChargeBlocked"
        name: "Alarm Charge blocked"
        unique_id: "alarm_battery_charge_blocked"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
          
    
          
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/DischargeBlocked"
        name: "Alarm Discharge blocked"
        unique_id: "alarm_battery_discharge_blocked"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighChargeCurrent"
        name: "Alarm high charge current"
        unique_id: "alarm_battery_high_charge_current"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighChargeTemperature"
        name: "Alarm high charge temperature"
        unique_id: "alarm_battery_high_charge_temperature"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighDischargeCurrent"
        name: "Alarm high discharge current"
        unique_id: "alarm_battery_high_discharge_current"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
          
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighTemperature"
        name: "Alarm high temperature"
        unique_id: "alarm_battery_high_temperature"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/HighVoltage"
        name: "Alarm high voltage"
        unique_id: "alarm_battery_high_voltage"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/InternalFailure"
        name: "Alarm internal failure"
        unique_id: "alarm_battery_internal_failure"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/LowChargeTemperature"
        name: "Alarm low charge temperature"
        unique_id: "alarm_battery_low_charge_temp"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/LowTemperature"
        name: "Alarm low temperature"
        unique_id: "alarm_battery_low_temp"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Alarms/LowVoltage"
        name: "Alarm low voltage"
        unique_id: "alarm_battery_low_voltage"
        value_template: >
          {% if value_json.value == 0 %}
            OK
          {% elif value_json.value == 1 %}
            Warning
          {% elif value_json.value == 2 %}
            Alarm
          {% endif %}
    
      # Victron Cerbo GX Serial number
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Serial"
        name: "Cerbo GX Serial number"
        unique_id: "victron_cerbo_serial"
        value_template: '{{ value_json.value }}'
    
      # Active SoC limit  
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Control/ActiveSocLimit"
        name: "Active SoC limit"
        unique_id: "active_soc_limit"
        device_class: battery
        unit_of_measurement: "%"
        value_template: '{{ value_json.value | round(0)}}'
        icon: mdi:battery-low
    
      # AC ActiveIN L1 Current
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/ActiveIn/L1/Current"
        name: "AC ActiveIn L1 Current"
        unique_id: "victron_activein_L1_current"
        device_class: current
        value_template: '{{ value_json.value |float(0)|round(2) }}'
        unit_of_measurement: "A"
        icon: mdi:power-socket-eu   
    
      # AC ActiveIN L1 Current
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/ActiveIn/L2/Current"
        name: "AC ActiveIn L2 Current"
        unique_id: "victron_activein_L2_current"
        device_class: current
        value_template: '{{ value_json.value |float(0)|round(2) }}'
        unit_of_measurement: "A"
        icon: mdi:power-socket-eu  
    
      # AC ActiveIN L1 Current
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/ActiveIn/L3/Current"
        name: "AC ActiveIn L3 Current"
        unique_id: "victron_activein_L3_current"
        device_class: current
        value_template: '{{ value_json.value |float(0)|round(2) }}'
        unit_of_measurement: "A"
        icon: mdi:power-socket-eu  
    
      # Grid Lost Status
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Alarms/GridLost"
        name: "Grid Lost Status"
        unique_id: "victron_grid_lost_status"
        value_template: > 
          {% if value_json.value == 0 %}
            Grid Connected
          {% elif value_json.value == 2 %}
            Grid Lost
          {% endif %}
    
      # Current Grid Setpoint
      - state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/AcPowerSetPoint"
        name: "Current grid setpoint"
        unique_id: "current_grid_setpoint"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
    
        # Battery percentage
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Soc"
        name: "Battery Percent"
        unique_id: "battery_percent"
        device_class: battery
        value_template: '{{ value_json.value | round(1) }}'
        unit_of_measurement: "%"
      
        # Battery percentage
      - state_topic: "venus-home/N/c0619xxxxxx/battery/512/Soh"
        name: "Battery Health"
        unique_id: "battery_health"
        device_class: battery
        value_template: '{{ value_json.value | round(1) }}'
        unit_of_measurement: "%"
    
      # AC Loads
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/P"
        name: "AC Loads"
        unique_id: "ac_loads"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu
     
      # L1 Load
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L1/P"
        name: "L1 Load"
        unique_id: "L1_load"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu
     
      # L1 Output Voltage
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L1/V"
        name: "L1 Output Voltage"
        unique_id: "L1_Output_Voltage"
        device_class: voltage
        value_template: '{{ value_json.value|round(1) }}'
        unit_of_measurement: "V"
        icon: mdi:power-socket-eu
    
      # L1 Output frequency
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L1/F"
        name: "L1 output frequency"
        unique_id: "L1_output_frequency"
        device_class: frequency
        value_template: '{{ value_json.value|round(1) }}'
        unit_of_measurement: "Hz"
        icon: mdi:sine-wave    
    
      # L2 Load
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L2/P"
        name: "L2 Load"
        unique_id: "L2_load"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu    
    
      # L2 Output Voltage
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L2/V"
        name: "L2 Output Voltage"
        unique_id: "L2_Output_Voltage"
        device_class: voltage
        value_template: '{{ value_json.value|round(1) }}'
        unit_of_measurement: "V"
        icon: mdi:power-socket-eu
    
      # L2 Output frequency
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L2/F"
        name: "L2 output frequency"
        unique_id: "L2_output_frequency"
        device_class: frequency
        value_template: '{{ value_json.value|round(1) }}'
        unit_of_measurement: "Hz"
        icon: mdi:sine-wave    
    
      # L3 Load
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L3/P"
        name: "L3 Load"
        unique_id: "L3_load"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu    
    
      # L3 Output Voltage
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L3/V"
        name: "L3 Output Voltage"
        unique_id: "L3_Output_Voltage"
        device_class: voltage
        value_template: '{{ value_json.value|round(1) }}'
        unit_of_measurement: "V"
        icon: mdi:power-socket-eu
    
      # L3 Output frequency
      - state_topic: "venus-home/N/c0619xxxxxx/vebus/276/Ac/Out/L3/F"
        name: "L3 output frequency"
        unique_id: "L3_output_frequency"
        device_class: frequency
        value_template: '{{ value_json.value|round(1) }}'
        unit_of_measurement: "Hz"
        icon: mdi:sine-wave
    
      # L1 Grid
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/Grid/L1/Power"
        name: "L1 Grid"
        unique_id: "L1_grid"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu 
        
      # L2 Grid
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/Grid/L2/Power"
        name: "L2 Grid"
        unique_id: "L2_grid"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu 
    
      # L3 Grid
      - state_topic: "venus-home/N/c0619xxxxxx/system/0/Ac/Grid/L3/Power"
        name: "L3 Grid"
        unique_id: "L3_grid"
        device_class: power
        value_template: '{{ value_json.value }}'
        unit_of_measurement: "W"
        icon: mdi:power-socket-eu 
    
      # DC Loads
      - name: "DC Loads"
        device_class: power
        unique_id: "dc_loads"
        state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/System/Power"
        value_template: '{{ value_json.value|float(0)|round(0) }}'
        unit_of_measurement: "W"
        icon: mdi:power
        
      # Net Solar Production
      - name: "Current Solar Production"
        unique_id: "net_solar_production"
        device_class: power
        state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Pv/Power"
        value_template: '{{ value_json.value|float(0)|round(0) }}'
        unit_of_measurement: "W"
        icon: mdi:solar-power
      
      # Battery Voltage
      - name: "Battery Voltage"
        unique_id: "battery_voltage"
        device_class: voltage
        state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Battery/Voltage"
        value_template: '{{ value_json.value|float(0)|round(1) }}'
        unit_of_measurement: "V"
    
      # Battery Temp (If you have a temp sensor)
      - name: "Battery Temp"
        device_class: temperature
        unique_id: "battery_temperature"
        state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Battery/Temperature"
        value_template: '{{ ((value_json.value * 9/5) + 32) | round(0) }}'
        unit_of_measurement: "°F"
    
      # Net load going in/out of your battery
      - name: "Battery Load"
        unique_id: "battery_load"
        device_class: power
        state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Vebus/Power"
        value_template: '{{ value_json.value |float(0)|round(0) }}'
        unit_of_measurement: "W"
        
      # Net current going in/out of your battery
      - name: "Battery Current"
        unique_id: "battery_current"
        device_class: current
        state_topic: "venus-home/N/c0619xxxxxx/system/0/Dc/Vebus/Current"
        value_template: '{{ value_json.value |float(0)|round(0) }}'
        unit_of_measurement: "A"
    
      # Temperature Multiplus II - Phase 1
      - name: "Temperature MPII #1"
        unique_id: "temp_mpII_1"
        device_class: temperature
        state_topic: "venus-home/N/c0619xxxxxx/temperature/25/Temperature"
        value_template: '{{ value_json.value |float(0)|round(0) }}'
        unit_of_measurement: "°C"
    
      # Temperature Multiplus II - Phase 2
      - name: "Temperature MPII #2"
        unique_id: "temp_mpII_2"
        device_class: temperature
        state_topic: "venus-home/N/c0619xxxxxx/temperature/26/Temperature"
        value_template: '{{ value_json.value |float(0)|round(0) }}'
        unit_of_measurement: "°C"
    
      # Temperature Multiplus II - Phase 3
      - name: "Temperature MPII #3"
        unique_id: "temp_mpII_3"
        device_class: temperature
        state_topic: "venus-home/N/c0619xxxxxx/temperature/27/Temperature"
        value_template: '{{ value_json.value |float(0)|round(0) }}'
        unit_of_measurement: "°C"
    
      # Temperature Multiplus II - Phase 3
      - name: "Pylontech battery power"
        unique_id: "pylontech_batt_power"
        device_class: power
        state_topic: "venus-home/N/c0619xxxxxx/battery/512/Dc/0/Power"
        value_template: '{{ value_json.value |round(0) }}'
        unit_of_measurement: "W"
    
      # Current State of your Inverter
      - name: "Inverter State"
        unique_id: "inverter_state"
        state_topic: "venus-home/N/c0619xxxxxx/system/0/SystemState/State"
        value_template: >
          {% if value_json.value == 0 %}
            Off
          {% elif value_json.value == 1 %}
            Low power
          {% elif value_json.value == 2 %}
            VE.Bus Fault condition
          {% elif value_json.value == 3 %}
            Bulk charging
          {% elif value_json.value == 4 %}
            Absorption charging
          {% elif value_json.value == 5 %}
            Float charging
          {% elif value_json.value == 6 %}
            Storage mode
          {% elif value_json.value == 7 %}
            Equalize
          {% elif value_json.value == 8 %}
            Passthru
          {% elif value_json.value == 9 %}
            Inverting
          {% elif value_json.value == 10 %}
            Assisting
          {% elif value_json.value == 252 %}
            External control
          {% elif value_json.value == 256 %}
            Discharging
          {% elif value_json.value == 257 %}
            Sustain
          {% elif value_json.value == 258 %}
            Recharging
          {% elif value_json.value == 259 %}
            Scheduled recharging
          {% else %}
            Error - No Data
          {% endif %}
      
      # Current state of your charge controller
      - name: "Solar Charger State"
        unique_id: "solar_charger_state"
        state_topic: "venus-home/N/c0619xxxxxx/solarcharger/289/State"
        value_template: >
          {% if value_json.value == 0 %}
            Off
          {% elif value_json.value == 2 %}
            Fault
          {% elif value_json.value == 3 %}
            Bulk
          {% elif value_json.value == 4 %}
            Absorption
          {% elif value_json.value == 5 %}
            Float
          {% elif value_json.value == 6 %}
            Storage
          {% elif value_json.value == 7 %}
            Equalize
          {% else %}
            Error - No Data
          {% endif %}
    
    switch:
      #Multiplus Entladeleistung Begrenzen !Number
      - unique_id: multiplus_switch_discharge_power
        name: Inverter Power 
        command_topic: "venus-home/W/c0619xxxxxx/settings/0/Settings/CGwacs/MaxDischargePower"
        payload_on: '{"value": 1000}'
        payload_off: '{"value": -1}'
        state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/MaxDischargePower"
        value_template: >
          {% if value_json.value | int == -1 %}
            {% set state_limit = 'OFF' %}
          {% else %}
            {% set state_limit = 'ON' %}
          {% endif %}
          {{ state_limit }}
        state_on: 'ON'
        state_off: 'OFF'
        
        device: {
          identifiers: [
            "Victron Cerbo GX"
          ],
          manufacturer: "Victron Energy",
          model: "Cerbo GX",
          name: "Cerbo GX"}
    
      #Multiplus AC PV-Überschuss einspeisen
      - unique_id: multiplus_allow_ac_feed_in
        name: Multiplus allow AC feed in
        command_topic: "venus-home/W/c0619xxxxxx/settings/0/Settings/CGwacs/PreventFeedback"
        payload_on: '{"value": 0}'
        payload_off: '{"value": 1}'
        state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/PreventFeedback"
        value_template: "{{ value_json.value | int }}"
        state_on: '0'
        state_off: '1'
        
        device: {
          identifiers: [
            "Victron Cerbo GX"
          ],
          manufacturer: "Victron Energy",
          model: "Cerbo GX",
          name: "Cerbo GX"}
    
      #Multiplus DC PV-Überschuss einspeisen
      - unique_id: multiplus_allow_dc_feed_in
        name: Multiplus allow DC feed in
        command_topic: "venus-home/W/c0619xxxxxx/settings/0/Settings/CGwacs/OvervoltageFeedIn"
        payload_on: '{"value": 1}'
        payload_off: '{"value": 0}'
        state_topic: "venus-home/N/c0619xxxxxx/settings/0/Settings/CGwacs/OvervoltageFeedIn"
        value_template: "{{ value_json.value | int }}"
        state_on: '1'
        state_off: '0'
        
        device: {
          identifiers: [
            "Victron Cerbo GX"
          ],
          manufacturer: "Victron Energy",
          model: "Cerbo GX",
          name: "Cerbo GX"}
    
  • Ping network devices

    - platform: ping
      host: 192.168.178.1
      name: ping Fritzbox
      count: 2
      scan_interval: 30
    
  • Create sensor for remaining battery time

    In this example the home battery system has a capacity of 300Ah (15kWh / 48V).
    As a safe minimal value is 15% capacity left is chosen. When grid is failing, there is still 2.5kWh left. When charging occurs, this will be shown instead of the remaining time.

    You can use the created sensor ‘sensor.template_time_left_on_battery_min_soc’ to display on your dashboard.

      - sensor:
          - unique_id: time_left_on_battery_min_soc
        #   unit_of_measurement: "Hours"
            icon: mdi:sort-clock-ascending
            state: >
              {% set battery_current = states('sensor.battery_current')|float %}
              {% set battery_soc = states('sensor.battery_percent')|float %}
              {% set loads_current = states('sensor.ac_loads')|float/states('sensor.battery_voltage')|float %}
              {% set battery_min_soc = 15 %}
              {% set battery_max_capacity = 300 %}
              {% if (battery_soc-battery_min_soc) < 0 %}
                {{ 0 }}
              {% elif (loads_current) < 0 %}
                {{ 'Charging' }}
              {% else %}
                {{ ((((battery_soc-battery_min_soc)*battery_max_capacity)/100)/loads_current | float ) | round(2) }}
              {% endif %}
    
    
  • Convert value ‘unavailable’ to 0

    template:
      # Solar production - Prevent showing unavailable instead of 0
      - sensor:
          - name: "Solar Current Power"
            unit_of_measurement: "W"
            state: "{{ 0 if states('sensor.on_grid_l1_power') == 'unavailable' else states('sensor.on_grid_l1_power' ) }}"
    
    
  • SSL in Home Assistant

    Place your fullchain.pem and privkey.pem in folder /ssl

    Apply SSL to your HA Instance by adding the following code to your configuration.yaml

    # SSL Certificate
    http:
      ssl_certificate: /ssl/fullchain.pem
      ssl_key: /ssl/privkey.pem
    
  • OTGW iSense Calenta Return water temperature

    OTGW iSense Calenta Return water temperature

    Is your OTGW (Opentherm Gateway) not returning the return water temperature?
    Issue the following command:

    AA=28
    


    Check in the list of devices. The actual temperature should now be reported.

  • Daily backup to external hdd

    Daily backup to external hdd

    Goal

    Domoticz has a built in feature to automatically create hourly, daily and monthly database backups in the /home/pi/domoticz/backups/ directory. You just need to tick the Enable Automatic Backup option in System setup.
    However in the case the SD-card crashes and is no longer accessible, a lot of work still could be lost.
    This page will provide you several backupscripts, each with other functions.

    Preparation

    Search the folder on your Network Attached Storage (NAS) where you want the backups to be stored. Check that FTP is enabled and have login credentials available.

    Make sure that if you have enabled website protection, e.g. if your Domoticz webpage is password protected, that you enable Local Networks (no username/password)in your settings. Fill in your local network IP-address (192.168.1.* for example), otherwise the backup will fail.

    Place the script below in:/home/pi/domoticz/scripts and change the parameters to reflect to your settings. (more…)

  • Install Domoticz in docker

    Install Domoticz in docker

    Just run the following command!

    docker run -d -p 8080:8080 --name=domoticz -v /home/pi/domoticz-config:/config -v /etc/localtime:/etc/localtime:ro -v /dev/bus/usb:/dev/bus/usb sdesbure/domoticz

    More information about this project at:
    https://hub.docker.com/r/sdesbure/domoticz/