jesserockz

Untitled

Jan 19th, 2021
930
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void CrowAlarmPanel::send_message_to_ha_(uint8_t type, std::vector<uint8_t> data) {
  2.   api::HomeassistantServiceResponse resp;
  3.   resp.service = "esphome.alarm_panel_message";
  4.   resp.is_event = true;
  5.  
  6.   char buf[64];
  7.   sprintf(buf, "0x%02x", type);
  8.  
  9.   api::HomeassistantServiceMap type_map;
  10.   type_map.key = "type";
  11.   type_map.value = buf;
  12.   resp.data.push_back(type_map);
  13.  
  14.   api::HomeassistantServiceMap data_map;
  15.   data_map.key = "data";
  16.   data_map.value = hexencode(data);
  17.   resp.data.push_back(data_map);
  18.  
  19.   api::global_api_server->send_homeassistant_service_call(resp);
  20. }
  21.  
RAW Paste Data