Skip to content

Commit

Permalink
device and entity naming, object coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinkler committed Oct 13, 2023
1 parent effd6a3 commit 850f6de
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [0.5](https://github.com/mawinkler/astrolive/compare/v0.4...v0.5) ()

### Features

- Adhere to Home Assistant 2023.9 device and entity naming conventions.
- Fixed object coordinates in camera file. Thanks to @zdesignstudio.

# [0.4](https://github.com/mawinkler/astrolive/compare/v0.3...v0.4) (2023-05-28)

### Features
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.10-slim-bullseye AS compile-image

WORKDIR /app

COPY requirements.txt .
ADD requirements.txt .

RUN pip3 install --no-cache-dir -r requirements.txt --user && \
pip list
Expand All @@ -14,8 +14,8 @@ COPY --from=compile-image /etc/ssl /etc/ssl

WORKDIR /app

COPY run.py .
COPY astrolive astrolive
ADD run.py .
ADD astrolive astrolive

ENV PATH=/root/local/bin:$PATH

Expand Down
12 changes: 6 additions & 6 deletions astrolive/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Constant Definitions for AstroLive."""

MANUFACTURER = "AstroLive 0.4"
MANUFACTURER = "AstroLive 0.5"
API_ENDPOINT = "http://localhost:11111/api/v1"
CLIENT_ID = 1

Expand Down Expand Up @@ -325,7 +325,7 @@
UNIT_OF_MEASUREMENT_NONE,
DEVICE_TYPE_CAMERA_FILE_ICON,
DEVICE_CLASS_TIMESTAMP,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_NONE,
],
[
TYPE_SENSOR,
Expand Down Expand Up @@ -364,16 +364,16 @@
"Pixel X axis size", # XPIXSZ
UNIT_OF_MEASUREMENT_MICROMETER,
DEVICE_TYPE_CAMERA_FILE_ICON,
DEVICE_CLASS_DISTANCE,
STATE_CLASS_MEASUREMENT,
DEVICE_CLASS_NONE,
STATE_CLASS_NONE,
],
[
TYPE_SENSOR,
"Pixel Y axis size", # YPIXSZ
UNIT_OF_MEASUREMENT_MICROMETER,
DEVICE_TYPE_CAMERA_FILE_ICON,
DEVICE_CLASS_DISTANCE,
STATE_CLASS_MEASUREMENT,
DEVICE_CLASS_NONE,
STATE_CLASS_NONE,
],
[
TYPE_SENSOR,
Expand Down
17 changes: 12 additions & 5 deletions astrolive/mqttdevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import cv2
import numpy as np
from astropy import units as u
from astropy.io import fits
from astropy.visualization import (
AsinhStretch,
Expand All @@ -22,6 +23,8 @@
SinhStretch,
SqrtStretch,
)
from astropy.coordinates import SkyCoord # High-level coordinates
from astropy.coordinates import Angle # Angles
from cv2 import imencode

from .const import (
Expand Down Expand Up @@ -146,7 +149,7 @@ async def create_mqtt_config(self, sys_id, device_type, device_friendly_name, de
+ "/"
)
config = {
"name": device_friendly_name_cap + " " + device_function_cap,
"name": device_function_cap,
"state_topic": "astrolive/" + device_type + "/" + sys_id_ + "/state",
"state_class": function[SENSOR_STATE_CLASS],
"device_class": function[SENSOR_DEVICE_CLASS],
Expand All @@ -160,7 +163,7 @@ async def create_mqtt_config(self, sys_id, device_type, device_friendly_name, de
"value_template": "{{ value_json." + device_function_low + " }}",
"device": {
"identifiers": [sys_id],
"name": device_friendly_name_cap,
"name": "AstroLive " + device_friendly_name_cap,
"model": device_friendly_name_cap,
"manufacturer": MANUFACTURER,
},
Expand Down Expand Up @@ -196,7 +199,7 @@ async def create_mqtt_config(self, sys_id, device_type, device_friendly_name, de
"unique_id": device_type + "_" + device_friendly_name_low + "_" + sys_id_,
"device": {
"identifiers": [sys_id],
"name": device_friendly_name_cap,
"name": "AstroLive " + device_friendly_name_cap,
"model": device_friendly_name_cap,
"manufacturer": MANUFACTURER,
},
Expand Down Expand Up @@ -630,6 +633,10 @@ async def _publish_camera_file(self, sys_id, device, device_type, execution_time
)
return

objctra_fits = hdul[0].header['OBJCTRA']
objctdec_fits = hdul[0].header['OBJCTDEC']
objct_coords = SkyCoord(objctra_fits, objctdec_fits, unit=(u.hour, u.deg))

topic = "astrolive/" + device_type + "/" + sys_id_ + "/"
try:
await self._publisher.publish_mqtt(topic + "lwt", "ON")
Expand Down Expand Up @@ -657,8 +664,8 @@ async def _publish_camera_file(self, sys_id, device, device_type, execution_time
"altitude_of_telescope": round(hdr.get("CENTALT", 0), 3),
"azimuth_of_telescope": round(hdr.get("CENTAZ", 0), 3),
"object_of_interest": hdr.get("OBJECT", "n/a"),
"ra_of_imaged_object": round(hdr.get("OBJCTRA", 0), 3),
"declination_of_imaged_object": round(hdr.get("OBJCTDEC", 0), 3),
"ra_of_imaged_object": objct_coords.ra.degree,
"declination_of_imaged_object": objct_coords.dec.degree,
"rotation_of_imaged_object": round(hdr.get("OBJCTROT", 0), 3),
"software": hdr.get("SWCREATE", "n/a"),
}
Expand Down

0 comments on commit 850f6de

Please sign in to comment.