Advertisement
jesserockz

Untitled

Jan 19th, 2021
1,034
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement