dm_mac.views.machine module

Views related to machine endpoints.

async dm_mac.views.machine.locked_out(machine_name: str) Tuple[Response, int]

API method to set or un-set machine locked out state.

async dm_mac.views.machine.oops(machine_name: str) Tuple[Response, int]

API method to set or un-set machine Oops state.

async dm_mac.views.machine.update() Tuple[Response, int]

API method to update machine state.

Accepts POSTed JSON containing the following key/value pairs:

  • machine_name (string) - name of the machine sending the update

  • oops (boolean) - whether the oops button is pressed

  • rfid_value (string) - value of the RFID fob/card that is currently

    present in the machine, or empty string if none present. Note that ESPHome strips leading zeroes from this, so inside this method it is left-padded with zeroes to a length of 10 characters.

  • uptime (float) - uptime of the ESP32 (MCU).

  • wifi_signal_db (float) - WiFi signal strength in dB

  • wifi_signal_percent (float) - WiFi signal strength in percent

  • internal_temperature_c (float) - internal temperature of the ESP32 in

    °C.

  • amps (float; optional) - amperage value from the current clamp

    ammeter, if present, or 0.0 otherwise.

EXAMPLE Payloads for ESP without amperage sensor

Oops button pressed when no RFID present

{
    'machine_name': 'esp32test',
    'oops': True,
    'rfid_value': '',
    'uptime': 59.29299927,
    'wifi_signal_db': -58,
    'wifi_signal_percent': 84,
    'internal_temperature_c': 53.88888931
}

RFID inserted (tag 0014916441)

{
    'machine_name': 'esp32test',
    'oops': False,
    'rfid_value': '14916441',
    'uptime': 59.29299927,
    'wifi_signal_db': -58,
    'wifi_signal_percent': 84,
    'internal_temperature_c': 53.88888931
}

Oops button pressed when RFID present

{
    'machine_name': 'esp32test',
    'oops': True,
    'rfid_value': '14916441',
    'uptime': 59.29299927,
    'wifi_signal_db': -58,
    'wifi_signal_percent': 84,
    'internal_temperature_c': 53.88888931
}

RFID removed

{
    'machine_name': 'esp32test',
    'oops': False,
    'rfid_value': '',
    'uptime': 119.2929993,
    'wifi_signal_db': -54,
    'wifi_signal_percent': 92,
    'internal_temperature_c': 53.88888931
}