Jump to content

  •  

CNers have asked about a donation box for Cloudy Nights over the years, so here you go. Donation is not required by any means, so please enjoy your stay.

Photo

NINA status dashboard in Home Assistant via. MQTT

  • Please log in to reply
144 replies to this topic

#1 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 04 December 2023 - 11:29 AM

Thanks to help on Discord from dghent, I was able to created dashboard for NINA status in Home Assistant. I am documenting it in case any one else wants to do the same.

 

Purpose:

1. When I step out of the house for an hour or two, I can check my phone to see the progress

2. Wanted to avoid RDPing to my imaging computer while in bed. I can leave this dashboard up on my tablet on the bedside a-la ASIAir

3. Because I wanted to see if I could make this work

 

Screenshots:

E0bjlDL.png

 

Prerequisites:

1. Home Assistant

2. MQTT broker (either Mosquitto that can be installed in HA or a separate MQTT broker)

3. dghent's Ground station plugin installed in NINA  and MQTT broker details populated and tested successfully

4. MQTT Sensor templates created in Home Assistant (I have provided mine as an example below)

 

MrzO8Tk.png

 

Home Assistant MQTT sensor template example:

 

Note. I use a dedicated MQTT sensor config file and that file is included in the main configuration.yaml like so:

mqtt: !include mqtt.yaml

Sensor template example:

sensor:
  - name: "NINA Target Start"
    state_topic: "Astro/NINA/target/start"
    unique_id: adsrfgbsdybsdsg

  - name: "NINA Sequence Status"
    state_topic: "Astro/NINA/sequencestatus"
    unique_id: jfgikmfuhgnghn

  - name: "NINA Flip Time"
    state_topic: "Astro/NINA/fliptime"
    unique_id: dyitunyjghnj7

  - name: "NINA Target"
    state_topic: "Astro/NINA/target/name"
    unique_id: y7ubrdyur6ub

  - name: "NINA Target RA"
    state_topic: "Astro/NINA/target/ra"
    unique_id: 65b7ubdybdyh

  - name: "NINA Target DEC"
    state_topic: "Astro/NINA/target/dec"
    unique_id: 970kyigouyhg

  - name: "NINA Current Filter"
    state_topic: "Astro/NINA/target/filter"
    unique_id: 3q4wf5rvxfg

  - name: "NINA Camera Temp"
    state_topic: "Astro/NINA/equipment/camtemp"
    unit_of_measurement: "°C"
    unique_id: w5csryju8

  - name: "NINA Camera"
    state_topic: "Astro/NINA/equipment/camera"
    unique_id: w5csryju8tseyhe6

Once this is setup, include the 'Publish to MQTT broker' instruction in advanced sequencer to your liking. I have attached my sequence as an example (rename the file to remove ".txt" extension and import into advanced sequencer.

 

4nJaTg7.png

Attached Files


  • theaberrator, dswtan, AstroGabe and 9 others like this

#2 dghent

dghent

    N.I.N.A. (& More)

  • *****
  • Freeware Developers
  • Posts: 2,241
  • Joined: 10 Jun 2007
  • Loc: Maryland, US

Posted 04 December 2023 - 08:12 PM

Nice job.

 

You can also chuck all the Send to MQTT instructions into a Parallel Instruction container so that they're all executed in parallel instead of serially, if that matters to you. It also puts them all into a single convenient package that you can save as a template and drop in anywhere with a single drag and drop.


Edited by dghent, 04 December 2023 - 08:13 PM.

  • AstroGabe, joshman, junktrunk and 1 other like this

#3 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 04 December 2023 - 08:23 PM

Nice job.

 

You can also chuck all the Send to MQTT instructions into a Parallel Instruction container so that they're all executed in parallel instead of serially, if that matters to you. It also puts them all into a single convenient package that you can save as a template and drop in anywhere with a single drag and drop.

Very good ideas! I will try both of those suggestions. I have been grouping my sequencer instructions into logical blocks for reuse so your suggestion dovetails perfectly into that stratergy.



#4 polslinux

polslinux

    Apollo

  • *****
  • Moderators
  • Posts: 1,008
  • Joined: 05 Jun 2020
  • Loc: Veneto, Italy

Posted 05 December 2023 - 08:07 AM

nice job, thanks for sharing this!



#5 ispybadguys

ispybadguys

    Viking 1

  • -----
  • Posts: 616
  • Joined: 31 Jan 2021
  • Loc: Albuquerque,NM

Posted 05 December 2023 - 08:16 AM

I am working on a similar idea

HomeAssistant.jpg

 

 This is a beginning attempt at a dashboard I have an Indi All-Sky Camera that posts data on my Mosquitto MQTT broker. I also have pulled weather data from my Tempest weather station and from Open Weather Map.  Tempest gives me wind and rain data for my observatory.  Open Weather gives me cloud cover when the roof is closed. I have a Pegasus Uranus that gives me SQM when the roof is open. I and running the HACS Mushroom dashboard. I have some Blink camera that required about 5 lines of YAML to get updates every 15 seconds from the cameras. I have an L350 mount that I get a huge amount of data using a simple REST call.

 

I am running NINA and I have switched entirely to Tom Palmer's Target Scheduler so I am unsure how if I can duplicate the approach here but I will give it a try. There is a very interesting option here https://github.com/mawinkler/astrolive that uses Alpaca to bring all the data available to ASCOM into HA. I tried to load this but I wasn't able to work thru the issues.

 

I was vaguely aware of Home Assistant but discovered that it would be a fantastic way to run and monitor my observatory. I have a few KASA switches and it magically reports the power consumption and can control the switches. Also I see a way to reach into my Pegasus power boxes and get  dew heater currents to monitor that.

 

I have a roof controller built on an M5STACK ESP32 that runs my Piertech Pier and ROR and another that runs a modified version of Robert's Browns mySQM Observing conditions monitor. I am hacking the ESP code to get its data via MQTT. Right now I am running HA on a VirtualBox VM. It will take you about 20 minutes to download and install both VirtualBox and Home Assistant and get it running.

 

I have a tiny bit of YAML code here 

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

#automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
logger:
  default: warning
  logs:
    homeassistant.components.mqtt: warning
    homeassistant.components.rest: warning

################################### MQTT SENSORS #####################################
mqtt:
  sensor:
    - name: "Mount Altitude"
      state_topic: "L350/mount.altitude_degs"
      unit_of_measurement: "°"
      unique_id: "mount_altitude_sensor"
      value_template: "{{ value | round(2) }}"
    
    - name: "Mount Azimuth"
      state_topic: "L350/mount.azimuth_degs"
      unit_of_measurement: "°"
      unique_id: "mount_azimuth_sensor" 
      value_template: "{{ value | round(2) }}"

    - name: "Mount Axis 0 Current"
      state_topic: "L350/mount.axis0.measured_current_amps"
      unit_of_measurement: "A"
      unique_id: "mount_axis0_current"
      value_template: "{{ value | round(2) }}"
    
    - name: "Mount Axis 1 Current"
      state_topic: "L350/mount.axis1.measured_current_amps"
      unit_of_measurement: "A"
      unique_id: "mount_axis1_current"
      value_template: "{{ value | round(2) }}"
    
    - name: "Mount Axis 0 RMS"
      state_topic: "L350/mount.axis0.rms_error_arcsec"
      unit_of_measurement: "\""
      unique_id: "mount_axis0_rms_error_arcsec"
      value_template: "{{ value | round(2) }}"

    - name: "Mount Axis 1 RMS"
      state_topic: "L350/mount.axis1.rms_error_arcsec"
      unit_of_measurement: "\""
      unique_id: "mount_axis1_rms_error_arcsec"
      value_template: "{{ value | round(3) }}"

    - name: "indi_allsky_stars"
      state_topic: "indi-allsky/stars"
      unique_id: "indi_allsky_stars" 
  
  camera:
    name: "Indi Allsky Latest"
    topic: "indi-allsky/latest"
    unique_id: "indi_allsky_latest_camera"
    encoding: "jpeg"

################################### URANUS SENSORS #####################################
sensor:
  - platform: rest
    name: "device_unique_key"
    resource: 'http://192.168.1.15:32000/Reporting/Device'
    method: GET
    json_attributes:
      - data
    value_template: "{{ value_json.data[0].uniqueKey }}"

  - platform: rest
    name: "uranus_report"
    resource_template: "http://192.168.1.15:32000/Driver/Uranus/Report?DriverUniqueKey={{ states('sensor.device_unique_key') }}"
    method: GET
    json_attributes:
      - data
    value_template: OK

  - platform: template
    sensors:
      uranus_temperature:
        friendly_name: "Uranus Temperature"
        unique_id: uranus_temperature
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['temperature']['temperature'] | float }}"
        unit_of_measurement: "°C"

      uranus_humidity:
        friendly_name: "Uranus Humidity"
        unique_id: uranus_humidity
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['relativeHumidity']['percentage'] }}"
        unit_of_measurement: "%"

      uranus_pressure:
        friendly_name: "Uranus Pressure"
        unique_id: uranus_pressure
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['absolutePressure']['hPa'] }}"
        unit_of_measurement: "hPa"

      uranus_dew_point:
        friendly_name: "Uranus Dew Point"
        unique_id: uranus_dew_point
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['dewPoint']['temperature'] }}"
        unit_of_measurement: "°C"

      uranus_relative_pressure:
        friendly_name: "Uranus Relative Pressure"
        unique_id: uranus_relative_pressure
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['relativePressure']['hPa'] }}"
        unit_of_measurement: "hPa"

      uranus_altitude:
        friendly_name: "Uranus Altitude"
        unique_id: uranus_altitude
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['barometricAltitude']['meters'] }}"
        unit_of_measurement: "m"

      uranus_sky_quality:
        friendly_name: "Uranus Sky Quality"
        unique_id: uranus_sky_quality
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['skyQuality']['mpsas'] }}"
        unit_of_measurement: "mpsas"

      uranus_nelm:
        friendly_name: "Uranus Naked Eye Limit Magnitude"
        unique_id: uranus_nelm
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['nelm']['vMag'] }}"

      uranus_illuminance:
        friendly_name: "Uranus Illuminance"
        unique_id: uranus_illuminance
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['illuminance']['lux'] }}"
        unit_of_measurement: "lux"

      uranus_temperature_difference:
        friendly_name: "Uranus Temperature Difference"
        unique_id: uranus_temperature_difference
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['temperatureDifference']['temperature'] }}"
        unit_of_measurement: "°C"

      uranus_cloud_coverage:
        friendly_name: "Uranus Cloud Coverage"
        unique_id: uranus_cloud_coverage
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['cloudCoverage']['percentage'] }}"
        unit_of_measurement: "%"

      uranus_sky_temperature:
        friendly_name: "Uranus Sky Temperature"
        unique_id: uranus_sky_temperature
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['skyTemperature']['temperature'] }}"
        unit_of_measurement: "°C"

      uranus_latitude:
        friendly_name: "Uranus Latitude"
        unique_id: uranus_latitude
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['latitude']['dd']['decimalDegree'] }}"
        unit_of_measurement: "°"

      uranus_longitude:
        friendly_name: "Uranus Longitude"
        unique_id: uranus_longitude
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['longitude']['dd']['decimalDegree'] }}"
        unit_of_measurement: "°"

      uranus_total_satellites:
        friendly_name: "Uranus Total Satellites"
        unique_id: uranus_total_satellites
        value_template: "{{ state_attr('sensor.uranus_report', 'data')['message']['totalSatellites'] }}"
############################# URANUS Automations #################################
automation:
  - id: 'periodic_uranus_report_update'
    alias: Periodic Update Uranus Report
    trigger:
      - platform: time_pattern
        seconds: "/10"  # Adjust this as needed for your desired interval
    action:
      - service: homeassistant.update_entity
        target:
          entity_id: sensor.device_unique_key
      - delay: '00:00:03'  # Adjust the delay time as needed   
      - service: homeassistant.update_entity
        target:
          entity_id: sensor.uranus_report
############################### Weatherflow #####################################          
  - id: 'aaacfb28-19ac-487b-bc57-d37096e402fe'
    alias: Publish Weatherflow to Observatory
    description: Publish Temperature to Observatory
    trigger:
      - platform: state
        entity_id: 
          - sensor.st_00012055_wind_gust
    action:
      - service: mqtt.publish
        data:
          qos: '1'
          retain: false
          topic: observatory
          payload_template: >-
            {{ {'temperature': states('sensor.st_00012055_temperature'),
                'wind_gust': states('sensor.st_00012055_wind_gust'),
                'illuminance': states('sensor.st_00012055_illuminance'),
                'wind_speed_average': states('sensor.st_00012055_wind_speed_average'),
                'lightning_average_distance': states('sensor.st_00012055_lightning_average_distance'),
                'lightning_count': states('sensor.st_00012055_lightning_count'),
                'rain_rate': states('sensor.st_00012055_precipitation_intensity'),
                'humidity': states('sensor.st_00012055_humidity'),
                'precipitation': states('sensor.st_00012055_precipitation'),
                'precipitation_type': states('sensor.sensor.st_00012055_precipitation_type'),
                'wind_direction': states('sensor.st_00012055_wind_direction'),
                'wind_speed': states('sensor.st_00012055_wind_speed')} | to_json }}
    mode: single

  - id: 'd379ba78-f4e4-4e9a-b46f-a07b95c609c8'
    alias: Publish Weatherflow to Observatory
    description: Publish Temperature to Observatory
    trigger:
      - platform: state
        entity_id: 
          - st_00012055_lightning_average_distance
          - sensor.st_00012055_lightning_count
    action:
      - service: mqtt.publish
        data:
          qos: '1'
          retain: false
          topic: observatory
          payload_template: >-
            {{ { 'lightning_average_distance': states('sensor.st_00012055_lightning_average_distance'),
                'lightning_count': states('sensor.st_00012055_lightning_count')} | to_json }}
    mode: single

  - id: 'f2ebf008-231f-48d9-80e2-2ed11d294359'
    alias: Publish Weatherflow to Observatory
    description: Publish Temperature to Observatory
    trigger:
      - platform: state
        entity_id: 
          - sensor.device_unique_key
          - sensor.openweathermap_cloud_coverage 
          - sensor.uranus_sky_quality
    action:     
      - service: mqtt.publish
        data:
          qos: '1'
          retain: false
          topic: observatory
          payload_template: >-
            {{ {'uranus_air_pressure': states('sensor.uranus_pressure'),
                'uranus_cloud_coverage': states('sensor.uranus_cloud_coverage'),
                'uranus_relative_pressure': states('sensor.uranus_relative_pressure'),
                'uranus_dew_point': states('sensor.uranus_dew_point'),
                'uranus_pressure': states('sensor.uranus_pressure'),
                'uranus_sky_temperature': states('sensor.uranus_sky_temperature'),
                'uranus_SQM': states('sensor.uranus_sky_quality'),
                'uranus_nelm': states('sensor.uranus_nelm'),
                'openweathermap_visibility': states('sensor.openweathermap_visibility'),
                'openweathermap_cloud_coverage': states('sensor.openweathermap_cloud_coverage')} | to_json }}
    mode: single          

  - alias: "Refresh Blink Observatory 2 Image"
    trigger:
      - platform: time_pattern
        seconds: "/15"  # Change this to your preferred refresh interval (every 15 seconds in this example)
    action:
      - service: blink.trigger_camera
        target:
          entity_id: camera.g8v1_9001_3076_5032  # Replace with your Blink camera entity ID
      - delay: '00:00:05'
      - service: blink.blink_update
      - service: camera.snapshot
        target:
          entity_id: camera.g8v1_9001_3076_5032  # Replace with your Blink camera entity ID
        data:
          filename: /tmp/observatory_image2.jpg
  - alias: "Refresh Blink Observatory 1 Image"
    trigger:
      - platform: time_pattern
        seconds: "/15"  # Change this to your preferred refresh interval (every 15 seconds in this example)
    action:
      - service: blink.trigger_camera
        target:
          entity_id: camera.g8v1_9001_3076_50kl  # Replace with your Blink camera entity ID
      - delay: '00:00:05'
      - service: blink.blink_update
      - service: camera.snapshot
        target:
          entity_id: camera.g8v1_9001_3076_50kl  # Replace with your Blink camera entity ID
        data:
          filename: /tmp/observatory_image1.jpg

This code gets data from  MQTT, Pegasus URANUS, Indi All-Sky and my Blink Cameras.

 

I would love to collaborate to improve this idea.

 

Kurt


Edited by ispybadguys, 05 December 2023 - 08:17 AM.

  • chvvkumar and marvyyk like this

#6 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 05 December 2023 - 09:10 AM

Very nice! Yes I have used Astrolive before but that is strictly ASCOM connected devices. I use NINA drivers for some of my equipment which prompted me to look for an alternate way.


Edited by chvvkumar, 05 December 2023 - 01:06 PM.


#7 dghent

dghent

    N.I.N.A. (& More)

  • *****
  • Freeware Developers
  • Posts: 2,241
  • Joined: 10 Jun 2007
  • Loc: Maryland, US

Posted 05 December 2023 - 01:15 PM

One of the plugins I have in the queue to finish is one that exports hardware metrics and image stats to influxDB. It doesn't require any sequencer stuff for now since it's always on and transmitting in the background, so this works even for people using the legacy sequencer. Once the info is in InfluxDB, you can use InfluQL or Flux to query stats from other systems, or use its own graphing (or Grafana) to visualize it and make whatever graphs you want.


Edited by dghent, 05 December 2023 - 01:15 PM.

  • joshman, junktrunk, chvvkumar and 2 others like this

#8 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 07 December 2023 - 02:59 PM

Added some more metrics and this is what it looks on my nightstand

 

PXL_20231207_052643108.jpg


  • dswtan, dghent, CharLakeAstro and 4 others like this

#9 junktrunk

junktrunk

    Explorer 1

  • -----
  • Posts: 87
  • Joined: 09 Nov 2019

Posted 07 December 2023 - 03:54 PM

This thread is so inspiring! I've been working on a supplement to what @chvvkumar began here and it's ready to share for feedback. In addition to the session data, we can also now pull auto-stretched thumbnails of the imaging session to your HA instance and display them in a dashboard card. I haven't mocked up the entire dashboard in a nice way yet but here's a basic view (my super simple version of chvvkumar's sensor data on the left with my image gallery on the right):

 

Screenshot 2023-12-07 144623.png

 

I'm working on the automation logic to use in HA to trigger the service to continuously run while the session is in progress, and will post an update once that's ready. After that I'm planning to work to make the image gallery a little nicer looking and to improve the efficiency of the image pull for continuous operation, but it's useable now if you want to give it a try. 

 

https://github.com/p...nina-image-data


Edited by junktrunk, 07 December 2023 - 03:58 PM.

  • chvvkumar likes this

#10 junktrunk

junktrunk

    Explorer 1

  • -----
  • Posts: 87
  • Joined: 09 Nov 2019

Posted 07 December 2023 - 05:26 PM

HA automation logic is now posted in the README for the repo I mentioned above. Seems to work well and can be easily tailored to match the MQTT data you wish to send. 

 

There's an issue I'm seeing with the index.html containing links to image files that don't exist. Working on a fix for that.



#11 ispybadguys

ispybadguys

    Viking 1

  • -----
  • Posts: 616
  • Joined: 31 Jan 2021
  • Loc: Albuquerque,NM

Posted 07 December 2023 - 06:07 PM

Added some more metrics and this is what it looks on my nightstand

 

attachicon.gif PXL_20231207_052643108.jpg

Now that is really nice. I started using Target Sequencer in October and not I won't be going back but I think I could adapt it to do what you are doing. You are using Ground Station MQTT right?

 

Kurt


  • chvvkumar likes this

#12 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 07 December 2023 - 08:11 PM

Now that is really nice. I started using Target Sequencer in October and not I won't be going back but I think I could adapt it to do what you are doing. You are using Ground Station MQTT right?

 

Kurt

I am using ground station for sending MQTT messages. I have my sequence template attached to the first post if you want to take a look at my MQTT topic schema and when I am sending updates during the sequence. I have made some changes since posting it but they are mostly about how I organize my templates.


  • ispybadguys likes this

#13 ispybadguys

ispybadguys

    Viking 1

  • -----
  • Posts: 616
  • Joined: 31 Jan 2021
  • Loc: Albuquerque,NM

Posted 07 December 2023 - 08:56 PM

I am using ground station for sending MQTT messages. I have my sequence template attached to the first post if you want to take a look at my MQTT topic schema and when I am sending updates during the sequence. I have made some changes since posting it but they are mostly about how I organize my templates.

I should have looked back. How did you build the Dashboard? Is the using mushroom cards? I am only a couple of days into doing anything with the Dashboard and yours looks great! My blink cameras are looking pretty good and were so easy to get added to that Dashboard.

Kurt



#14 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 07 December 2023 - 10:07 PM

I should have looked back. How did you build the Dashboard? Is the using mushroom cards? I am only a couple of days into doing anything with the Dashboard and yours looks great! My blink cameras are looking pretty good and were so easy to get added to that Dashboard.

Kurt

It's just straight HA lovelace elements like element card. Here's the YAML for my dashboard attached.

 

Attached File  hadashboard.yml.txt   96.02KB   67 downloads

 

And this is the weather provider on the right:

https://github.com/m...er/astroweather

 

and it's card:

https://github.com/m...troweather-card


Edited by chvvkumar, 07 December 2023 - 10:24 PM.


#15 Astrofather

Astrofather

    Lift Off

  • -----
  • Posts: 7
  • Joined: 12 Oct 2020
  • Loc: Madrid

Posted 08 December 2023 - 04:21 PM

I have been working in the last weeks on this same project with HA but to validate all the observatory automation (roof opening and closing, security systems based on different control parameters and remote test connection with an Asiair and router control from HA), What I have not tested yet is the option to send parameters from NINA by MQTT with the excellent Dale Ghent's plugin.

 

HA Main Dashboard
HA Asiair Router

 

I can not send a test message to the server (Mosquito Broker) that I have configured from NINA, although testing with MQTT Explorer I have succeeded, the user is well configured. I don't know if there is any parameter in the plugin configuration that I don't know. Thanks so much for this interesting thread.


Edited by Astrofather, 08 December 2023 - 04:22 PM.

  • marvyyk likes this

#16 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 08 December 2023 - 04:53 PM

I have been working in the last weeks on this same project with HA but to validate all the observatory automation (roof opening and closing, security systems based on different control parameters and remote test connection with an Asiair and router control from HA), What I have not tested yet is the option to send parameters from NINA by MQTT with the excellent Dale Ghent's plugin.

 

 
 

 

I can not send a test message to the server (Mosquito Broker) that I have configured from NINA, although testing with MQTT Explorer I have succeeded, the user is well configured. I don't know if there is any parameter in the plugin configuration that I don't know. Thanks so much for this interesting thread.

Can you post the MQTT topic, your payload string and HA MQTT sensor config?



#17 Astrofather

Astrofather

    Lift Off

  • -----
  • Posts: 7
  • Joined: 12 Oct 2020
  • Loc: Madrid

Posted 09 December 2023 - 07:25 AM

Thank you very much for your help. I share with you the information you ask for, the test from the plugin configuration gives me error and from the advanced sequencer too. The problem I detect is that the message does not go out from NINA.

 

MQTT Topic: Astro/NINAMGG/test

Payload string: $$CAMERA_SENSOR_TEMP$$

HA MQTT sensor config:

mqtt:
  sensor:
    - name: "Temperatura Camara"
      state_topic: "Astro/NINAMGG/test"
      unit_of_measurement: "C"
      unique_id: "2600MM_sensor"
      value_template: "{{ value | round(2) }}"


Edited by Astrofather, 09 December 2023 - 07:29 AM.


#18 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 09 December 2023 - 10:00 AM

Thank you very much for your help. I share with you the information you ask for, the test from the plugin configuration gives me error and from the advanced sequencer too. The problem I detect is that the message does not go out from NINA.

 

MQTT Topic: Astro/NINAMGG/test

Payload string: $$CAMERA_SENSOR_TEMP$$

HA MQTT sensor config:

mqtt:
  sensor:
    - name: "Temperatura Camara"
      state_topic: "Astro/NINAMGG/test"
      unit_of_measurement: "C"
      unique_id: "2600MM_sensor"
      value_template: "{{ value | round(2) }}"

That looks correct, you said you could not connect to the broker from the plugin, correct? Can you try with the following:

 

1. Disable 'Use TLS' in the plugin settings for ground station to rule out trust issues between the plugin and the broker

2. Disable user name and password on the MQTT broker and try it without a username/password to rule out authentication issues



#19 dghent

dghent

    N.I.N.A. (& More)

  • *****
  • Freeware Developers
  • Posts: 2,241
  • Joined: 10 Jun 2007
  • Loc: Maryland, US

Posted 09 December 2023 - 11:31 AM

So this sudden increase in interest in telemetry has me thinking of extending Ground Station some more in the MQTT department. Right now its MQTT implementation is mostly sequence-oriented, with an explicit publish instruction and a trigger that reports sequence failures. The Last Will & Testament stuff is of course independent of any sequence.

 

NINA periodically polls hardware every 2 seconds by default. There's a poll loop for each hardware type - camera, mount, focuser, etc. and a event handler can be registered so that it is ran each time this occurs. There are also events that fire for both stages for the image saving pipeline - once when an image is initially acquired, and later when stats have been computed for the image and it has been saved to disk. Obviously that second event can happen at a relatively random time, with stats computation taking a varying amount of time based on the CPU of the system doing it. My InfluxDB plugin (not released, I need to find more free time to touch it up) uses the above facilities to transmit hardware and image metrics to a given influxdb instance - there are no sequence instructions involved.

 

I'm thinking I can take that same scheme and set up similar event handlers in Ground Station's existing MQTT code in order to constantly transmit the same stats to a broker. I'd probably just make a simple JSON blob per hardware type and it would publish that blob to a per-device class topic on the broker - nina/mount, nina/camera, etc. I purposefully want to keep that part simple because I really don't like, and don't think it's necessary to implement a list of configuration knobs that's as long as my arm that covers every single little metric and a topic endpoint. Perhaps I can work on this over the coming holidays.


  • classpath, lurkingtaco, junktrunk and 4 others like this

#20 junktrunk

junktrunk

    Explorer 1

  • -----
  • Posts: 87
  • Joined: 09 Nov 2019

Posted 09 December 2023 - 11:56 AM

I'm thinking I can take that same scheme and set up similar event handlers in Ground Station's existing MQTT code in order to constantly transmit the same stats to a broker. I'd probably just make a simple JSON blob per hardware type and it would publish that blob to a per-device class topic on the broker - nina/mount, nina/camera, etc. I purposefully want to keep that part simple because I really don't like, and don't think it's necessary to implement a list of configuration knobs that's as long as my arm that covers every single little metric and a topic endpoint. Perhaps I can work on this over the coming holidays.

I would be curious if @chvvkumar has looked into this yet in terms of Home Assistant's ability to parse a JSON payload on an MQTT topic to route to individual HA sensors. @dghent I know you're not only considering this from the HA standpoint, so no worries there -- I just know HA is a bit limited in what it will and won't support without a bunch of customization. I'm thinking it should probably be possible to set up a JSON-level MQTT processing topic in HA which just listens for that device payload, then simply parses that payload and publishes new MQTT topics for each received data point, then uses the per-attribute sensors chvvkumar already set up to process each of those. I'm not sure if that would be HA-natively supported or require a script to do the processing, but I've at least figured out python scripting enough in HA now to contribute to that if it's needed.

 

Speaking of, I need to publish an update to the NINA image data pull repo to fix a few things. Will do that later today hopefully.


  • chvvkumar likes this

#21 junktrunk

junktrunk

    Explorer 1

  • -----
  • Posts: 87
  • Joined: 09 Nov 2019

Posted 09 December 2023 - 12:03 PM

I can not send a test message to the server (Mosquito Broker) that I have configured from NINA, although testing with MQTT Explorer I have succeeded, the user is well configured. I don't know if there is any parameter in the plugin configuration that I don't know. Thanks so much for this interesting thread.

Just to be sure I followed, you set up MQTT in HA and validated using MQTT Explorer that you're able to login with your publishing user account and publish successfully to a topic, right? And you configured Ground Station to use that same topic and user/pass? And your sequencer is using that same topic string? That's really all I did to set mine up and it all worked the first time honestly. Any chance the machine you're running NINA on can't communicate with the machine where HA is running (try installing MQTT Explorer on the NINA machine to validate)? 



#22 dghent

dghent

    N.I.N.A. (& More)

  • *****
  • Freeware Developers
  • Posts: 2,241
  • Joined: 10 Jun 2007
  • Loc: Maryland, US

Posted 09 December 2023 - 12:32 PM

I would be curious if @chvvkumar has looked into this yet in terms of Home Assistant's ability to parse a JSON payload on an MQTT topic to route to individual HA sensors. @dghent I know you're not only considering this from the HA standpoint, so no worries there -- I just know HA is a bit limited in what it will and won't support without a bunch of customization. I'm thinking it should probably be possible to set up a JSON-level MQTT processing topic in HA which just listens for that device payload, then simply parses that payload and publishes new MQTT topics for each received data point, then uses the per-attribute sensors chvvkumar already set up to process each of those. I'm not sure if that would be HA-natively supported or require a script to do the processing, but I've at least figured out python scripting enough in HA now to contribute to that if it's needed.

 

Speaking of, I need to publish an update to the NINA image data pull repo to fix a few things. Will do that later today hopefully.

I'm not considering it from *any* consumer's standpoint. JSON is JSON. It's the payload of the MQTT message. I would think that anything should be able to deal with that these days, even if it's just shoving the contents through jq(1)on a command-line pipe. I don't fancy the idea of making a single topic for each and every metric. For one, it would be burdensome to maintain that scheme, and it would be inefficient, as we would be publishing 10 messages for a device instead of 1. It would also violate a "blood-brain" barrier of design, where the application needs to know about the transport (the MQTT topic) to know the key for a value (the metric stat). Ideally the consuming app(s) would not need to know that context.


Edited by dghent, 09 December 2023 - 12:33 PM.

  • chvvkumar likes this

#23 chvvkumar

chvvkumar

    Surveyor 1

  • *****
  • topic starter
  • Posts: 1,821
  • Joined: 03 Aug 2020
  • Loc: Cottleville, MO

Posted 09 December 2023 - 12:44 PM

I would be curious if @chvvkumar has looked into this yet in terms of Home Assistant's ability to parse a JSON payload on an MQTT topic to route to individual HA sensors. @dghent I know you're not only considering this from the HA standpoint, so no worries there -- I just know HA is a bit limited in what it will and won't support without a bunch of customization. I'm thinking it should probably be possible to set up a JSON-level MQTT processing topic in HA which just listens for that device payload, then simply parses that payload and publishes new MQTT topics for each received data point, then uses the per-attribute sensors chvvkumar already set up to process each of those. I'm not sure if that would be HA-natively supported or require a script to do the processing, but I've at least figured out python scripting enough in HA now to contribute to that if it's needed.

 

Speaking of, I need to publish an update to the NINA image data pull repo to fix a few things. Will do that later today hopefully.

That was my original thought. I opened an issue on NINA's bitbucket page asking about whether there can be a JSON output that we can in turn parse in HA (or anything else for that matter) to consume the current status of NINA. I used MQTT because that is what is available right now but it is much simpler to directly parse JSON from a HTTP url that spits out the object (see below).

 

https://bitbucket.or...quipment-status

 

I'm not considering it from *any* consumer's standpoint. JSON is JSON. It's the payload of the MQTT message. I would think that anything should be able to deal with that these days, even if it's just shoving the contents through jq(1)on a command-line pipe. I don't fancy the idea of making a single topic for each and every metric. For one, it would be burdensome to maintain that scheme, and it would be inefficient, as we would be publishing 10 messages for a device instead of 1. It would also violate a "blood-brain" barrier of design, where the application needs to know about the transport (the MQTT topic) to know the key for a value (the metric stat). Ideally the consuming app(s) would not need to know that context.

I agree, sticking to a standard JSON schema should work with anything that follows the JSON standard.

 

As for Home Assistant specifically, it can directly grab JSON from an HTTP end point and parse it to create sensors directly, without even going through MQTT. I am doing this for some soil temperature data where I live. So an exposed JSON object is sufficient in this case like what the Web Session Viewer plugin does internally.

# -----------------------------------------------------------------------------------
# Soil temperature
# -----------------------------------------------------------------------------------
- platform: rest
  name: JSON soil
  json_attributes:
    - dt
    - t10
    - moisture
    - t0
  resource: https://api.agromonitoring.com/agro/1.0/soil?polyid=ID&appid=OTHER_ID
  value_template: "{{ value_json.soildata }}"

- platform: template
  sensors:
    soil_date:
      friendly_name: "Soil Date"
      value_template: "{{ state_attr('sensor.json_soil', 'dt') }}"
      unique_id: soil_date

    soil_10cm:
      friendly_name: "Soil at 10cm"
      value_template: "{{ (state_attr('sensor.json_soil', 't10') | float * 9/5 - 459.67) | round(2) }}"
      unique_id: soil_10cm_f
      unit_of_measurement: "F"

    soil_moisture:
      friendly_name: "Soil moisture"
      value_template: "{{ state_attr('sensor.json_soil', 'moisture') }}"
      unique_id: soil_moisture
      unit_of_measurement: "VWC"

    soil_surface:
      friendly_name: "Soil Surface"
      value_template: "{{ (state_attr('sensor.json_soil', 't0') | float * 9/5 - 459.67) | round(2) }}"
      unique_id: soil_surface_f
      unit_of_measurement: "F"


Edited by chvvkumar, 09 December 2023 - 12:52 PM.

  • junktrunk likes this

#24 dghent

dghent

    N.I.N.A. (& More)

  • *****
  • Freeware Developers
  • Posts: 2,241
  • Joined: 10 Jun 2007
  • Loc: Maryland, US

Posted 09 December 2023 - 12:54 PM

Sure you can make a plugin that implements a HTTP service that utters JSON blobs for a given URI and have HA poll that. It's a matter of push vs. pull. MQTT facilitates NINA pushing the information to a broken upon its creation, and clients would then pick that up and do with it what they may. A cursory google search shows this is possible with HA?


Edited by dghent, 09 December 2023 - 12:56 PM.


#25 Astrofather

Astrofather

    Lift Off

  • -----
  • Posts: 7
  • Joined: 12 Oct 2020
  • Loc: Madrid

Posted 09 December 2023 - 01:23 PM

Just to be sure I followed, you set up MQTT in HA and validated using MQTT Explorer that you're able to login with your publishing user account and publish successfully to a topic, right? And you configured Ground Station to use that same topic and user/pass? And your sequencer is using that same topic string? That's really all I did to set mine up and it all worked the first time honestly. Any chance the machine you're running NINA on can't communicate with the machine where HA is running (try installing MQTT Explorer on the NINA machine to validate)? 

Thanks for your response, yes MQTT Explorer is installed on the machine where NINA is installed, and HA is in the same network. I´ll try what @chvvkumar recommend me about TLS and user & password.


Edited by Astrofather, 09 December 2023 - 01:23 PM.



CNers have asked about a donation box for Cloudy Nights over the years, so here you go. Donation is not required by any means, so please enjoy your stay.


Recent Topics






Cloudy Nights LLC
Cloudy Nights Sponsor: Astronomics