# frozen_string_literal: true module DjiMqttConnect module Thing::Product # { # "bid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", # "tid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", # "data": { # "live_capacity": { # "available_video_number": 3, # "coexist_video_number_max": 2, # "device_list": [ # { # "sn": "4BKBJ4R1010TGD", # "available_video_number": 1, # "coexist_video_number_max": 1, # "camera_list": [ # { # "camera_index": "165-0-7", # "available_video_number": 1, # "coexist_video_number_max": 1, # "video_list": [ # { # "video_index": "normal-0", # "video_type": "normal", # "switchable_video_types": [ # "normal" # ] # } # ] # } # ] # }, # { # "sn": "1581F4BND22180040075", # "available_video_number": 2, # "coexist_video_number_max": 2, # "camera_list": [ # { # "camera_index": "39-0-7", # "available_video_number": 1, # "coexist_video_number_max": 1, # "video_list": [ # { # "video_index": "normal-0", # "video_type": "normal", # "switchable_video_types": [ # "normal" # ] # } # ] # }, # { # "camera_index": "52-0-0", # "available_video_number": 1, # "coexist_video_number_max": 1, # "video_list": [ # { # "video_index": "normal-0", # "video_type": "wide", # "switchable_video_types": [ # "wide", # "zoom", # "ir" # ] # } # ] # } # ] # } # ] # } # }, # "timestamp:": 1654070968655, # "gateway": "4BKBJ4R1010TGD" # } class StateMessage < DjiMqttConnect::Message attribute :tid, Types::UUID attribute :bid, Types::UUID attribute :timestamp, Types::Timestamp # Can be determined from the topic, but included for convenience attribute :gateway, Types::SerialNumber attribute :_data, Types::Hash # NOTE: Included in some state messages, requires a reply on the state_reply topic if true attribute? :need_reply, Types::Integer.enum(0, 1) def need_reply? need_reply == 1 end attribute :data do attribute? :geo_caging_status do attribute :state, Types::Integer end attribute? :cameras, Types::Array do attribute :camera_mode, Types::Integer attribute :liveview_world_region do attribute :bottom, Types::JSON::Decimal attribute :left, Types::JSON::Decimal attribute :right, Types::JSON::Decimal attribute :top, Types::JSON::Decimal end attribute :payload_index, Types::String attribute :photo_state, Types::Integer attribute :record_time, Types::Integer attribute :recording_state, Types::Integer attribute :remain_photo_num, Types::Integer attribute :remain_record_duration, Types::Integer attribute :wide_calibrate_farthest_focus_value, Types::Integer attribute :wide_calibrate_nearest_focus_value, Types::Integer attribute :wide_exposure_mode, Types::Integer attribute :wide_exposure_value, Types::Integer attribute :wide_focus_mode, Types::Integer attribute :wide_focus_state, Types::Integer attribute :wide_focus_value, Types::Integer attribute :wide_iso, Types::Integer attribute :wide_max_focus_value, Types::Integer attribute :wide_min_focus_value, Types::Integer attribute :wide_shutter_speed, Types::Integer attribute :zoom_calibrate_farthest_focus_value, Types::Integer attribute :zoom_calibrate_nearest_focus_value, Types::Integer attribute :zoom_exposure_mode, Types::Integer attribute :zoom_exposure_value, Types::Integer attribute :zoom_factor, Types::JSON::Decimal attribute :zoom_focus_mode, Types::Integer attribute :zoom_focus_state, Types::Integer attribute :zoom_focus_value, Types::Integer attribute :zoom_iso, Types::Integer attribute :zoom_max_focus_value, Types::Integer attribute :zoom_min_focus_value, Types::Integer attribute :zoom_shutter_speed, Types::Integer end # Not all messages will have a live_capacity attribute attribute? :live_capacity do attribute :available_video_number, Types::Integer attribute :coexist_video_number_max, Types::Integer attribute :device_list, Types::Array do attribute :sn, Types::SerialNumber attribute :available_video_number, Types::Integer attribute :coexist_video_number_max, Types::Integer attribute :camera_list, Types::Array do attribute :camera_index, Types::String attribute :available_video_number, Types::Integer attribute :coexist_video_number_max, Types::Integer attribute :video_list, Types::Array do include Mixins::VideoType attribute :video_index, Types::String attribute :video_type, Types::VideoType attribute :switchable_video_types, Types::Array.of(Types::VideoType) end end end end attribute? :live_status, Types::Array do include Mixins::VideoType include Mixins::VideoQuality attribute :video_id, Types::String attribute :video_type, Types::VideoType attribute :video_quality, Types::VideoQuality attribute :status, Types::Integer attribute :error_status, Types::Integer end attribute? :payloads, Types::Array do attribute :control_source, Types::String attribute? :firmware_version, Types::String attribute :payload_index, Types::String attribute? :sn, Types::SerialNumber end attribute? :rtcm_info do attribute :host, Types::String attribute :mount_point, Types::String attribute :port, Types::String attribute :rtcm_device_type, Types::Integer attribute :source_type, Types::Integer end attribute? :wireless_link_topo do attribute :center_node do attribute :sdr_id, Types::Integer attribute :sn, Types::SerialNumber end attribute :leaf_nodes, Types::Array do attribute :control_source_index, Types::Integer attribute :sdr_id, Types::Integer attribute :sn, Types::SerialNumber attribute :valid, Types::Bool end attribute :secret_code, Types::Array.of(Types::Integer) end attribute? :ar_info_switch, Types::Integer attribute? :commander_flight_height, Types::Integer attribute? :commander_flight_mode, Types::Integer attribute? :commander_mode_lost_action, Types::Integer attribute? :control_source, Types::String attribute? :current_commander_flight_mode, Types::Integer attribute? :current_rth_mode, Types::Integer attribute? :flysafe_database_version, Types::String attribute? :home_latitude, Types::JSON::Decimal # These values are not standard lat/long coordinates attribute? :home_longitude, Types::JSON::Decimal # These values are not standard lat/long coordinates attribute? :locked, Types::Bool attribute? :mode_code_reason, Types::Integer attribute? :offline_map_enable, Types::Bool attribute? :rth_mode, Types::Integer attribute? :uom_real_name_state, Types::Integer attribute? :wpmz_version, Types::String attribute? :firmware_version, Types::String attribute? :compatible_status, Types::Integer attribute? :firmware_upgrade_status, Types::Integer attribute? :low_battery_warning_threshold, Types::Integer attribute? :serious_low_battery_warning_threshold, Types::Integer end def humanized_summary Translations.thing_product_state_summary(**humanized_summary_interpolation) end def humanized_summary_interpolation data.to_h.merge( # Provides a list of all keys that are not nil or empty topics: data.to_h.compact.keys.sort.join(", ").presence || "-" ) end end end end