Skip to content

Example Configuration File

This file (config_example.yaml) is available in the project root folder. You can use this as your starting point for the actual application configuration (config.yaml)

# General settings for the Power Controller application
General:
  Label: MyPower          # A label for this installation - used in the email subject and web viewer app
  PollingInterval: 30     # Number of seconds to sleep between each check of the run plan and possible changes to outputs. Recommended 30 seconds.
  # Some critical errors can trigger email notifications - for example the AmberAPI not responding. This is the time in minutes for an issue to 
  # persist before we send an email notification. Leave blank to disable.
  ReportCriticalErrorsDelay: 30
  DefaultPrice: 32.0      # A default price to use if the Amber API is not available and there is no schedule price defined  


# Settings for various log and state files
Files:
  SavedStateFile: system_state.json    # The name of the saved state file. This is used to store the state of the device between runs.
  LogfileName: logfile.log             # The name of the log file
  LogfileMaxLines: 10000               # The maximum number of lines to keep in the log file
  LogfileVerbosity: detailed           # How much information do we write to the log file. One of: none; error; warning; summary; detailed; debug; all
  ConsoleVerbosity: detailed           # How much information do we write to the console. One of: error; warning; summary; detailed; debug; all


# Enter your settings here if you want to be emailed when there's a critical error. Note that the SMTP username and password have been set in the .env file for security, but you can also set them here if you prefer.
Email:
  EnableEmail: True                         # Set to True to enable email notifications 
  SendEmailsTo: <Your email address here>   # The email address to send notifications to
  SMTPServer: <Your SMTP server here>       # The SMTP server to use to send the email
  SMTPPort: 587                             # The SMTP server port
  SubjectPrefix: "[My PowerController]: "   # A prefix to add to the email subject line


# Settings for the built-in web server that provides a web interface to view and control the power controller
Website:
  HostingIP: 0.0.0.0          # The IP address to host the web server on. Use 0.0.0.0 to listen on all interfaces
  Port: 8080                  # The port to host the web server on
  PageAutoRefresh: 30         # How often to refresh the web page (in seconds). Set to 0 to disable auto-refresh.
  AccessKey: <Your website API key here>   # An access key to secure the web interface. Alternatively, set the WEBAPP_ACCESS_KEY environment variable. Leave blank to disable access control.


# Settings for the Amber API integration
AmberAPI:
  Mode: Live    # Operating mode for the Amber API: Live (attempt to download prices), Offline (pretend Amber API is offline, use cached prices). Disabled (fall back to schedule)
  APIURL: https://api.amber.com.au/v1   # The base URL for the Amber API
  APIKey: <Your API key here>    # The API key for your account, get one at app.amber.com.au/developers. Alternatively, set the AMBER_API_KEY environment variable.
  RefreshInterval: 15       # How often to refresh the pricing data from Amber (in minutes) 
  UsageDataFile: amber_usage_data.csv   # Set to the name of a CSV file to log hourly energy usage and costs as reported by Amber.
  PricesCacheFile: logs/latest_prices.json  # The name of the file to cache Amber pricing data.


# Use this section to configure your Shelly devices
ShellyDevices:
  ResponseTimeout: 3            # How long to wait in seconds for a response from a Shelly device
  RetryCount: 1                 # Number of times to retry a request to a Shelly device if it fails
  RetryDelay: 2                 # Number of seconds to wait between retries
  MaxConcurrentErrors: 4        # Send an email notification if we get this number of concurrent errors
  Devices:                      # List of Shelly devices to control
    - Name: Shelly Pool 1        # A name for this device
      Model: Shelly2PMG3        # The model of Shelly device
      Hostname: 192.168.1.20   # The IP address or hostname of the Shelly device
      Inputs:                   # List of inputs on the Shelly device to monitor
        - Name: "Filter Pump Override"
        - Name: "Solar Pump Override"
      Outputs:                  # List of outputs on the Shelly device to control your devices
        - Name: "Filter Pump Power"
        - Name: "Solar Pump Power"
      Meters:                  # List of meters on the Shelly device to monitor energy usage
        - Name: "Filter Pump Energy"
        - Name: "Solar Pump Energy"
    - Name: Shelly Pool 2
      Model: Shelly2PMG3        
      Hostname: 192.168.1.21   
      Simulate: False           
      Outputs:                  
        - Name: "Solar Valve Actuator"
        - Name: "Shelly Pool 2 O2"
      TempProbes: 
        - Name: "Temp Pool Water"
          RequiresOutput: "Filter Pump Power"  # Only read this probe when the specified output is ON
        - Name: "Temp Solar Return"
          RequiresOutput: "Solar Pump Power"  # Only read this probe when the specified output is ON
        - Name: "Temp Roof"
    - Name: Spello Hot Water
      Model: Shelly2PMG3
      Hostname: 192.168.86.39
      ExpectOffline: True       # Expect that this device will sometimes be offline and so don't report warnings when it happens
      Outputs:
        - Name: "Hot Water O1"
        - Name: "Hot Water O2"
      Meters:
        - Name: "Hot Water M1"
        - Name: "Hot Water M2"
    - Name: Panel EM1
      Model: ShellyEMG3
      Hostname: 192.168.86.44
      ExpectOffline: True
      Meters:
        - Name: "Panel EM1.1"
        - Name: "Panel EM1.2"   
    - Name: Network Rack
      Model: Shelly2PMG3
      Hostname: 192.168.86.30
      Outputs:
        - Name: "Network Rack O1"
        - Name: "Network Rack O2"


# Configure each switched output that controls your devices and how they behave
Outputs:  
  - Name: Pool Pump                 # A name for this output - used in the web interface  
    Type: shelly                    # The type of output - shelly (default), teslamate or meter
    DeviceOutput: Filter Pump Power  # The Shelly device output that controls this device - must match a Name in the ShellyDevices: Devices: Outputs section
    Mode: BestPrice                 # Operating mode: BestPrice (run for target hours at best price), Schedule (run according to schedule only)
    Schedule: Pool Pump             # The operating schedule to use when in Schedule mode - must match a Name in the OperatingSchedules section
    ConstraintSchedule: Pool Heating  # An optional constraint schedule that limits when the output can run, even in BestPrice mode
    AmberChannel: general           # The Amber pricing channel to use for this device, typically general or controlledLoad
    DaysOfHistory: 7                # How many days of history to keep for this device
    MinHours: 2                     # Minimum number of hours to run each day
    MaxHours: 10                    # Maximum number of hours to run each day
    TargetHours: 7                  # Target number of hours to run each day. Set to -1 to run for all hours that fall within best price or the schedule
    MonthlyTargetHours:             # Override the TargetHours for a specific month of the year 
      January: 8
      February: 8
      June: 6
      July: 6
      August: 6
      December: 8     
    MaxShortfallHours: 4            # Maximum number of shortfall hours we can carry forward from previous days. Ignored if TargetHours is -1. Set to 0 to disable.
    MaxBestPrice: 23.0              # The maximum price to run at when in BestPrice mode. 
    MaxPriorityPrice: 35.0          # The maximum price to run when we haven't run for the minimum number of hours yet.
    DeviceMeter: Filter Pump Energy  # The Shelly device meter to use to track energy usage - must match a Name in the ShellyDevices: Devices: Meters section
    MaxDailyEnergyUse: 6000         # Maximum energy use expected in Wh per day. An email warning will be sent if this is exceeded.
    DeviceInput: Filter Pump Override   # Optional: The Shelly device input to used override the state of the output - must match a Name in the ShellyDevices: Devices: Inputs section
    DeviceInputMode: TurnOn         # If a DeviceInput is specified, this controls how is is used. Ignore: Ignore the state of the inputs. TurnOn: Turn output on if input is off. TurnOff: Turn output off if input is on.
    MinOnTime: 30                   # Minimum minutes to stay on once turned on
    MinOffTime: 10                  # Minimum minutes to stay off (prevent rapid cycling). Cannot be set if MaxffTime is set.
  - Name: Solar Heating
    Type: shelly
    DeviceOutput: Solar Pump Power
    Mode: Schedule
    Schedule: Pool Heating
    AmberChannel: general
    TargetHours: -1
    MaxBestPrice: 23.0
    MaxPriorityPrice: 35.0
    DeviceMeter: Solar Pump Energy
    ParentOutput: Pool Pump               # Optional: The name of a parent output that must be ON for this output to run
    TurnOnSequence: Turn On Solar Pump    # Optional: Name of the output sequence to run when turning on this output
    TurnOffSequence: Turn Off Solar Pump  # Optional: Name of the output sequence to run when turning off this output
    MaxAppOnTime: 60               # If we turned this output on via the app, revert to auto after this number of minutes. Set to 0 to disable.
    MaxAppOffTime: 60              # If we turned this output off via the app, revert to auto after this number of minutes. Set to 0 to disable.
    TempProbeConstraints:       # Optional list of temperature probe constraints that must be met for the output to run
      - TempProbe: Temp Roof
        Condition: GreaterThan
        Temperature: 32.0
      - TempProbe: Temp Pool Water
        Condition: LessThan
        Temperature: 30.0    
  - Name: Hot Water Heater
    Type: shelly
    DeviceOutput: Hot Water O1
    Mode: BestPrice
    Schedule: Hot Water
    AmberChannel: controlledLoad
    TargetHours: -1
    MaxBestPrice: 23.0
    MaxPriorityPrice: 30.0
    DeviceMeter: Hot Water M1
    HideFromWebApp: True      # If True, this output will not be shown in the built-in web app
    HideFromViewerApp: True  # If True, this output will not be shown in the PowerControllerViewer app
  - Name: Tesla
    Type: teslamate
    CarID: 1                   # The ID of the car in TeslaMate to control (this is usually 1 if you only have one car)
    DaysOfHistory: 14            # How many days of history to keep for this device in the system state file
    AmberChannel: general       # The Amber pricing channel to use for pricing this device, typically general or controlledLoad
    Schedule: General           # The operating schedule to use for pricing this device when not using Amber pricing - must match a Name in the OperatingSchedules section
  - Name: "EM1.1 Living & Beds"
    Type: meter
    DeviceMeter: Panel EM1.1
    Mode: BestPrice
    Schedule: General
    PowerOnThresholdWatts: 40
    PowerOffThresholdWatts: 10
    MinEnergyToLog: 20
    HideFromViewerApp: True
  - Name: "EM1.2 Kitchen & Laundry"
    Type: meter
    DeviceMeter: Panel EM1.2
    Mode: BestPrice
    Schedule: General
    PowerOnThresholdWatts: 40
    PowerOffThresholdWatts: 10
    MinEnergyToLog: 20
    HideFromViewerApp: True
  - Name: Network Rack
    DeviceOutput: Network Rack O1
    Mode: BestPrice
    Schedule: General
    AmberChannel: general
    TargetHours: -1
    MaxShortfallHours: 0
    MaxBestPrice: 60.0
    MaxPriorityPrice: 60.0
    UPSIntegration: 
      UPS: APC UPS
      ActionIfUnhealthy: TurnOn


# Define the operating schedules for your devices. These are used to determine when a device is allowed to run when not using the Amber pricing data.
OperatingSchedules:
  - Name: Pool Pump           # A name for this schedule - used in the Outputs section
    Windows:                  # List of time windows when the schedule is active
      - StartTime: "00:00"
        EndTime: "07:30"
        DaysOfWeek: All       # Days of the week this window applies to - Mon, Tue, Wed, Thu, Fri, Sat, Sun or All. Multiple days can be specified separated by commas
        Price: 20
      - StartTime: "07:30"
        EndTime: "09:00"
        DaysOfWeek: All
        Price: 16
      - StartTime: "09:00"
        EndTime: "15:00"
        DaysOfWeek: All
        Price: 13
      - StartTime: "15:00"
        EndTime: "17:00"
        DaysOfWeek: All
        Price: 33
      - StartTime: "17:00"
        EndTime: "21:00"
        DaysOfWeek: All
        Price: 51
      - StartTime: "21:00"
        EndTime: "23:59"
        DaysOfWeek: All
        Price: 22
  - Name: Pool Heating
    Windows: 
      - StartTime: "10:00"
        EndTime: "16:00"
        DaysOfWeek: All
      - StartTime: "22:00"
        EndTime: "23:59"
        DaysOfWeek: All
  - Name: Hot Water
    Windows: 
      - StartTime: "00:00"
        EndTime: "14:00"
        DaysOfWeek: All
        Price: 18
      - StartTime: "22:00"
        EndTime: "23:59"
        DaysOfWeek: All
        Price: 20


# Use this to define a sequence of actions to perform on outputs when turning On or off
OutputSequences:
  - Name: "Turn On Solar Pump"
    Description: "Turn on the actuator valve, wait for 1 minute then turn on the solar booster pump"
    Timeout: 90
    Steps:
      - Type: CHANGE_OUTPUT
        OutputIdentity: "Solar Valve Actuator"
        State: True
        Retries: 2
        RetryBackoff: 1.0
      - Type: SLEEP
        Seconds: 60.0
      - Type: CHANGE_OUTPUT
        OutputIdentity: "Solar Pump Power"
        State: True
        Retries: 2
        RetryBackoff: 1.0
  - Name: "Turn Off Solar Pump"
    Description: "Turn off the solar booster pump, wait for 10 seconds then turn off the actuator valve"
    Timeout: 30
    Steps:
      - Type: CHANGE_OUTPUT
        OutputIdentity: "Solar Pump Power"
        State: False
        Retries: 2
        RetryBackoff: 1.0
      - Type: SLEEP
        Seconds: 10.0
      - Type: CHANGE_OUTPUT
        OutputIdentity: "Solar Valve Actuator"
        State: False
        Retries: 2
        RetryBackoff: 1.0


# Use this section to configure integration with the PowerControllerViewer app - see https://github.com/NickElseySpelloC/PowerControllerViewer
ViewerWebsite:
  Enable: False                   # Set to True to enable integration with the PowerControllerViewer app
  BaseURL: http://localhost:8000  # The base URL of the PowerControllerViewer app
  AccessKey: <Your website API key here>  # The access key for the PowerControllerViewer app. Alternatively, set the VIEWER_ACCESS_KEY environment variable.
  APITimeout: 5                   # How long to wait in seconds for a response from the PowerControllerViewer app
  Frequency: 10                   # How often to post the state to the web viewer app (in seconds)


# Optionally use this section to enable a data API that can be used to get the current state of the system and recent history for integration with other applications or custom dashboards.
DataAPI:
  Enable: True
  HostingIP: 0.0.0.0
  Port: 8081
  RefreshInterval: 30  # Seconds between cache refresh. Set to 0 to refresh every polling interval.
  AccessKey:  # The access key for the API calls. Alternatively, set the DATAAPI_ACCESS_KEY environment variable.
  Outputs:
    - Name: Pool Pump
      DisplayName: Pool
    - Name: "EM1.1 Living & Beds"
      DisplayName: "Living & Beds"
    - Name: Tesla
  Meters:
    - Name: "Panel EM1.1"
      DisplayName: "Living & Beds"
    - Name: "Panel EM1.2"
      DisplayName: "Kitchen & Laundry"
  TempProbes:
    - Name: "Temp Pool Water"
      DisplayName: "Pool"
    - Name: "Temp Solar Return"
      DisplayName: "Solar Return"
    - Name: "Temp Roof"
      DisplayName: "Roof"
  TempProbeHistoryDays: 5 # Number of days of temp probe history data to include in the TempProbes API response. 
  EnergyPrices:
    AmberChannel: general
    IntervalTime: 30    # Interval for each forecast period in minutes (e.g. 30 for half-hourly prices, 60 for hourly prices)
    NumIntervals: 15    # Number of intervals to return in the forecast (e.g. 48 for 24 hours of half-hourly prices, 24 for 24 hours of hourly prices)
    WarningPrice: 46.0   # If the price exceeds this value, the API will include a warning in the response for this interval. Set to 0 to disable warnings.
    CriticalPrice: 50.0  # If the price exceeds this value, the API will include a critical warning in the response for this interval. Set to 0 to disable critical warnings.


# Optionally use this section to enable logging of output energy consumption data to CSV and the system state file
OutputMetering:
  Enable: True    # Set to True to enable logging of output energy consumption data
  DataFile: logs/output_consumption_data.csv     # Record to CSV data file. Required
  OutputsToLog:   # A list of outputs to log. These must have a meter associated with them (Outputs: [Item]: DeviceMeter field)
    - Output: Pool Pump
      DisplayName: Pool
    - Output: Solar Heating
      DisplayName: Solar
      HideFromViewerApp: True   # If True, exclude this output from the viewer app's metering display page
    - Output: Hot Water Heater
      DisplayName: Hot Water
    - Output: Tesla
    - Output: "EM1.1 Living & Beds"
      DisplayName: "Living & Beds"
    - Output: "EM1.2 Kitchen & Laundry"
      DisplayName: "Kitchen & Laundry"


# Optionally enable temperature probe logging. The temperature probes must be defined in the Shelly device configuration above.
TempProbeLogging:
    Enable: True
    Probes:   # A list of temp probes to monitor.
      - Name: Temp Pool Water
        DisplayName: Pool Water
        Colour: Blue  # Colour to use when charting this probe
      - Name: Temp Roof
      - Name: Temp Solar Return
        HideFromViewerApp: True      # If True, probe will be logged in CSV file but hidden from the PowerControllerViewer app
    LoggingInterval: 30  # Log temp probe readings every N minutes
    LastReadingWithinMinutes: 180  # Only log readings that have been updated within this number of minutes. 0 to disable.
    SavedStateFileMaxDays: 7  # Number of days to keep in the data in the system state file. Try to keep this as low as possible to reduce file size. 0 to disable.
    HistoryDataFile: temp_probe_history.csv  # Leave blank to disable logging to a CSV file.
    HistoryDataFileMaxDays: 90  # Maximum number of days to keep in the history data file.  0 to disable.
    Charting:   # This contains settings for generating temperature charts for the PowerControllerViewer website.
      Enable: True
      Charts:
        - Name: "Pool Temps"
          Probes:
            - Temp Pool Water
            - Temp Solar Return
          DaysToShow: 30
        - Name: "Roof Temp"
          Probes:
            - Temp Roof
          DaysToShow: 30


# Optionally use this section to configure integration with your UPS to monitor its runtime and battery charge levels. See README for more details.
UPSIntegration:
  - Name: APC UPS
    Script: shell_scripts/apc_ups_runtime.sh
    MinRuntimeWhenDischarging: 300   # Minimum runtime remaining in seconds to when UPS is discharging to consider the UPS as "healthy". 
    MinChargeWhenDischarging: 10   # Minimum charge remaining in percent when discharging to consider the UPS as "healthy".
    MinRuntimeWhenCharging:     # Minimum runtime remaining in seconds to when UPS is charging to consider the UPS as "healthy". 
    MinChargeWhenCharging: 80   # Minimum charge remaining in percent when charging to consider the UPS as "healthy".


# Optionally use this section to specify the geographic location and timezone of your installation. This is used to determine the dawn and dusk times for scheduled events.
Location:
  Timezone: Europe/London     # See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones


# Optionally use this sectionto configure integration with the TeslaMate database to import Tesla charging session data
TeslaMate:
  Enable: True           # Set to True to enable integration with the TeslaMate database
  RefreshInterval: 10     # How often to refresh the TeslaMate data (in minutes)
  Host: 127.0.0.1         # The host address of the TeslaMate database (or use the TESLAMATE_DB_HOST environment variable)
  Port: 5432              # The port number of the TeslaMate database (or use the TESLAMATE_DB_PORT environment variable)
  DatabaseName: teslamate # The name of the TeslaMate database (or use the TESLAMATE_DB_NAME environment variable)
  DBUsername: teslamate   # The username to connect to the TeslaMate database (or use the TESLAMATE_DB_USER environment variable)
  DBPassword: <Your password here>  # The password to connect to the TeslaMate database (or use the TESLAMATE_DB_PASSWORD environment variable)