# ----------------------------------------------------------------------------#
# Commissioning File
# ----------------------------------------------------------------------------#
# Copyright: Cybus GmbH (2020)
# Contact: support@cybus.io
# ----------------------------------------------------------------------------#
description: >
  Shdr sample commissioning file

metadata:
  name: Shdr simulator
  icon: https://www.cybus.io/wp-content/themes/cybus/img/product-slide-img.png
  provider: cybus
  homepage: https://www.cybus.io
  version: 1.0.0

parameters:
  IP_Address:
    type: string
    default: 192.168.0.1
  Port:
    type: integer
    default: 7878
  initialReconnectDelay:
    type: integer
    default: 1000
  maxReconnectDelay:
    type: integer
    default: 30000
  factorReconnectDelay:
    type: integer
    default: 2


definitions:
  MQTT_TOPIC_PREFIX: io/cybus/shdr

resources:
  shdrConnection:
    type: Cybus::Connection
    properties:
      protocol: Shdr
      connection:
        host: !ref IP_Address
        port: !ref Port
        connectionStrategy:
          initialDelay: !ref initialReconnectDelay
          maxDelay: !ref maxReconnectDelay
          incrementFactor: !ref factorReconnectDelay

  raw:
    type: Cybus::Endpoint
    properties:
      protocol: Shdr
      connection: !ref shdrConnection
      subscribe:
        key: raw
        type: sample

  xact:
    type: Cybus::Endpoint
    properties:
      protocol: Shdr
      connection: !ref shdrConnection
      subscribe:
        key: Xact
        type: sample

  temperature:
    type: Cybus::Endpoint
    properties:
      protocol: Shdr
      connection: !ref shdrConnection
      subscribe:
        key: temp_cond
        type: condition

  mapping:
    type: Cybus::Mapping
    properties:
      mappings:
        - subscribe:
            endpoint: !ref raw
          publish:
            topic: !sub '${MQTT_TOPIC_PREFIX}/raw'
        - subscribe:
            endpoint: !ref xact
          publish:
            topic: !sub '${MQTT_TOPIC_PREFIX}/xAct'
        - subscribe:
            endpoint: !ref temperature
          publish:
            topic: !sub '${MQTT_TOPIC_PREFIX}/tempCondition'
