Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: improvements and simplification of python and docker packaging #104

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3-alpine

ARG BUILD_VERSION

# Create config volume
VOLUME /config

# Create Working Directory
WORKDIR /app

# Install enoceanmqtt and requirements
RUN apk add --no-cache git
RUN python3 -m pip install --upgrade pip && \
pip3 install pyyaml==6.0.1 && \
pip3 install tinydb==4.7.1 && \
pip3 install paho-mqtt==1.6.1 && \
pip3 install git+https://github.com/mak-gitdev/enocean.git && \
pip3 install git+https://github.com/embyt/enocean-mqtt.git

COPY HA_enoceanmqtt HA_enoceanmqtt/

# Set entrypoint
ENTRYPOINT [ "python", "-m", "HA_enoceanmqtt.main", "/config/enoceanmqtt.conf" ]
File renamed without changes.
45 changes: 45 additions & 0 deletions HA_enoceanmqtt/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import logging
import traceback

from enoceanmqtt.communicator import Communicator
from enoceanmqtt.enoceanmqtt import conf, parse_args, setup_logging, load_config_file


def main():
"""entry point if called as an executable"""
# logging.getLogger().setLevel(logging.DEBUG)
# Parse command line arguments
conf.update(parse_args())

# setup logger
setup_logging(conf['logfile'], logging.DEBUG if conf['debug'] else logging.INFO)

# load config file
sensors, global_config = load_config_file(conf['config'])
conf.update(global_config)

# Select the overlay
if str(global_config.get('overlay')).lower() == "ha":
try:
from enoceanmqtt.overlays.homeassistant.ha_communicator import HACommunicator
except ImportError:
logging.error("Unable to import Home Assistant overlay")
return
logging.info("Selected overlay : Home Assistant")
com = HACommunicator(conf, sensors)
else:
logging.info("Selected overlay : None")
com = Communicator(conf, sensors)

# start working
try:
com.run()

# catch all possible exceptions
except: # pylint: disable=broad-except,bare-except
logging.error(traceback.format_exc())


# check for execution
if __name__ == "__main__":
main()
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

import enocean.utils
from enoceanmqtt.communicator import Communicator
from enoceanmqtt.overlays.homeassistant.device_manager import DeviceManager

from HA_enoceanmqtt.overlays.homeassistant.device_manager import DeviceManager


class HACommunicator(Communicator):
'''Home Assistant-oriented Communicator subclass for enoceanmqtt'''
Expand Down
39 changes: 0 additions & 39 deletions docker/Dockerfile

This file was deleted.

Loading