Remove 'type' field from discovery payload per HA spec
The type field is not required in the discovery payload JSON. The entity type is determined by the discovery topic itself: - homeassistant/sensor/.../config indicates a sensor - homeassistant/switch/.../config indicates a switch This aligns with the official Home Assistant MQTT discovery documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,8 +19,6 @@ struct DeviceInfo {
|
||||
#[derive(Serialize)]
|
||||
struct EntityConfig<'a> {
|
||||
name: &'a str,
|
||||
#[serde(rename = "type")]
|
||||
entity_type: &'a str,
|
||||
unique_id: String,
|
||||
state_topic: String,
|
||||
availability_topic: String,
|
||||
@@ -69,7 +67,6 @@ pub async fn publish_all(client: &AsyncClient, cfg: &Config) -> Result<()> {
|
||||
let entity_name = format!("{}_{}", key, cfg.device.name);
|
||||
let entity = EntityConfig {
|
||||
name: &entity_name,
|
||||
entity_type: "sensor",
|
||||
unique_id: format!("{}_{}", cfg.device.name, key),
|
||||
state_topic: format!("{}/{}", base, key),
|
||||
availability_topic: format!("{}/{}/available", base, key),
|
||||
@@ -98,7 +95,6 @@ pub async fn publish_all(client: &AsyncClient, cfg: &Config) -> Result<()> {
|
||||
let entity_name = format!("{}_{}", key, cfg.device.name);
|
||||
let entity = EntityConfig {
|
||||
name: &entity_name,
|
||||
entity_type: "switch",
|
||||
unique_id: format!("{}_{}", cfg.device.name, key),
|
||||
state_topic: format!("{}/{}/state", base, key),
|
||||
availability_topic: format!("{}/{}/available", base, key),
|
||||
|
||||
Reference in New Issue
Block a user