Package: aps2mqtt
APS2MQTTAllows you to access yourAPsystemsEnergy Communication Unit (ECU) data by MQTT. This MQTT bridge queries the ECU directly at regular interval for new data, parse the returned data and publish them over MQTT.In this way you can integrate your APsystems devices with whatever smart home infrastructure you are using.:warning: It currently supports only one ECU.AcknowledgementsThis work is based on the awesomehomeassistant-apsystems_ecur (v1.2.30). This couldn't have been done without their hardwork.PrerequisitesSee full versionA compatible APSystems ECUECU-BECU-RECU-CSome invertersYC1000/QT2YC600/DS3/DS3-H/DS3-L/DS3DQS1/QS1AYour ECU needs to be fully configured by the EMA Manager and should have a fixed IP address. APS2MQTT should run on a machine in the same network (or in an accessible one) as the ECU.ECU-C and modern ECU-R (ID starting with 2162) can be automatically restarted in case of connection error. For older ECU-R and for ECU-B, the restart need to be done manually.Test your connectionSee full versionYou can test the connection between APS2MQTT and the ECU using Netcat. From your terminal, run the following command (assuming your ECU IP address is 192.168.1.42) to open the connectionnc-v192.168.1.428899ECU should response with an "open" message192.168.1.42(192.168.1.42:8899)openConnection is now established, the ECU is ready to receive commandsAPS1100160001ENDIf this command return with an APS message, you are ready to start APS2MQTT. If not, rebbot your ECU and try again.InstallBinaries are available in the release asset or onPyPI.
Using a virtual env is recommended for better insulation.# with PyPIpip3installaps2mqtt# manuallypip3installaps2mqtt-[version]-py3-none-any.whlStart itpython3-maps2mqtt-hRun as a serviceUsing systemd, APS2MQTT can be started automatically[Unit]Description=APS2MQTTAfter=multi-user.target[Service]Type=simpleUser=userRestart=on-failureExecStart=/path-to-your-venv/python3 -m aps2mqtt -c config.yaml[Install]WantedBy=multi-user.targetConfigurationAPS2MQTT configuration can be provided by a yaml config file or by environment variables (in a container context for example).MQTTKeyDescriptionExampleDefault valueMQTT_BROKER_HOSTHost of the MQTT broker"192.168.1.1", "broker.hivemq.com""127.0.0.1"MQTT_BROKER_PORTPort of the MQTT broker18831883MQTT_BROKER_USERUser login of the MQTT broker"john-doe"""MQTT_BROKER_PASSWDUser password of the MQTT broker"itsasecret"""MQTT_CLIENT_IDClient ID if the MQTT client"MyAwesomeClient""APS2MQTT"MQTT_TOPIC_PREFIXTopic prefix for publishing"my-personal-topic"""MQTT_BROKER_SECURED_CONNECTIONUse secure connection to MQTT brokerTrueFalseMQTT_BROKER_CACERTS_PATHPath to the cacerts file"/User/johndoe/.ssl/cacerts"NoneECUKeyDescriptionExampleDefault valueAPS_ECU_IPIP of the ECU"192.168.1.42"None, this field id mandatoryAPS_ECU_PORTCommunication port of the ECU88998899APS_ECU_TIMEZONETimezone of the ECU'Europe/Paris'None (use system timezone)APS_ECU_AUTO_RESTARTAutomatically restart ECU in case of errorTrueFalseAPS_ECU_WIFI_SSIDSSID of the ECU Wifi:information_source: Only used if automatic restart is enabled"My Wifi"""APS_ECU_WIFI_PASSWDPassword of the ECU Wifi:information_source: Only used if automatic restart is enabled"secret-key"""APS_ECU_STOP_AT_NIGHTStop ECU query during the nightTrueFalseAPS_ECU_POSITION_LATLatitude of the ECU, used to retrieve sunset and sunrise:information_source: Only used if stop at night is enabled51.4981948.864716 (Paris)APS_ECU_POSITION_LNGLongitude of the ECU, used to retrieve sunset and sunrise:information_source: Only used if stop at night is enabled-0.130872.349014 (Paris)TimezoneWithout any specific configuration, aps2mqtt use your system's timezone as a reference.If you use aps2mqtt as a python application, setting the ECU timezone is recommended by setting the configuration variable 'APS_ECU_TIMEZONE' for better processing.If you are using aps2mqtt as a Docker image, you can configure the timezone for the whole container using the environement variable 'TZ'ExampleUnsecured connectionecu:APS_ECU_IP:'192.168.1.42'APS_ECU_TIMEZONE:'Europe/Paris'APS_ECU_STOP_AT_NIGHT:TrueAPS_ECU_POSITION_LAT:47.206APS_ECU_POSITION_LNG:-1.5645mqtt:MQTT_BROKER_HOST:'192.168.1.12'MQTT_BROKER_PORT:1883MQTT_BROKER_USER:'johndoe'MQTT_BROKER_PASSWD:'itsasecret'Secured connectionecu:APS_ECU_IP:'192.168.1.42'APS_ECU_TIMEZONE:'Europe/Paris'APS_ECU_STOP_AT_NIGHT:TrueAPS_ECU_POSITION_LAT:47.206APS_ECU_POSITION_LNG:-1.5645mqtt:MQTT_BROKER_HOST:'broker.hivemq.com'MQTT_BROKER_PORT:8883MQTT_BROKER_SECURED_CONNECTION:TrueUsing Docker Composeservices:aps2mqtt:image:fligneul/aps2mqtt:latestrestart:alwaysenvironment:-TZ=Europe/Paris-DEBUG=True-APS_ECU_IP=192.168.1.42-APS_ECU_STOP_AT_NIGHT=True-APS_ECU_POSITION_LAT=47.206-APS_ECU_POSITION_LNG=-1.5645-MQTT_BROKER_HOST=broker.hivemq.com-MQTT_BROKER_PORT=8883-MQTT_BROKER_USER=johndoe-MQTT_BROKER_PASSWD=itsasecret-MQTT_BROKER_SECURED_CONNECTION=TrueMQTT topicsThe aps2mqtt retrieve from the whole PV array as a whole as well as each individual inverter in detail.ECU dataaps/[ECU_ID]/power - total amount of power (in W) being generated right nowaps/[ECU_ID]/energy/today - total amount of energy (in kWh) generated todayaps/[ECU_ID]/energy/lifetime - total amount of energy (in kWh) generated from the lifetime of the arrayInverter dataaps/[ECU_ID]/[INVERTER_ID]/online - True is the inverter is communicating with the ECU, False otherwiseaps/[ECU_ID]/[INVERTER_ID]/signal - the signal strength of the zigbee connectionaps/[ECU_ID]/[INVERTER_ID]/temperature - the temperature of the inverter in your local unit (C or F)aps/[ECU_ID]/[INVERTER_ID]/frequency - the AC power frequency (in Hz)aps/[ECU_ID]/[INVERTER_ID]/power - the current power generation (in W), sum of all panel poweraps/[ECU_ID]/[INVERTER_ID]/voltage - the AC voltage (in V)aps/[ECU_ID]/[INVERTER_ID]/[PANEL_ID]/power - the current power generation (in W) of the selected panel