[ { "id": "ee_read_envoy_battery", "result": { "structured": "TRIGGER: When Home Assistant starts OR When the automation entity itself [this.entity_id] is on AND remains on for 1 second. CONDITIONS: None. ACTIONS: Repeat the following sequence 60 times: 1. Set variable request_time to the current time. 2. Execute the rest command read envoy batteries rest command [rest_command.read_envoy_batteries], storing the response in variable response, and continue on error. 3. Set variable response_time to the current time and calculate latency as the difference between response_time and request_time. 4. If a debug condition is met, send a persistent notification [notify.persistent_notification] with the response (this action is disabled). 5. Check a condition on the response: IF (response is undefined OR response.status equals 'timeout' OR response.status as integer equals 200) THEN send a persistent notification [notify.persistent_notification] with a timestamp and status, then stop the automation with an error (this stop action is disabled), then delay for 1 minute. ELSE parse the response content to extract battery data, then set EE observed charge [input_number.ee_observed_charge] to the average state of charge, set EE observed batteries [input_text.ee_observed_batteries] to the battery details list, set EE envoy battery reporting time [input_datetime.ee_envoy_battery_reporting_time] to the current time, set EE observed envoy read battery latency [input_number.ee_observed_envoy_read_battery_latency] to the calculated latency in milliseconds, then delay for 2 seconds. After the repeat loop, turn off the automation entity itself [this.entity_id], then turn it back on.", "natural_language": { "trigger": "The automation runs either when Home Assistant first starts up, or when the automation itself is turned on and remains in the 'on' state for at least one second.", "conditions": "There are no conditions that must be met for the actions to proceed.", "action": "The automation performs a loop 60 times. In each loop, it records the start time, calls a REST command to read battery data from an Envoy device, and records the end time to calculate the request latency. If the REST command fails or times out, it sends a notification and stops the automation (though this stop is currently disabled). If the command succeeds, it processes the battery data: it calculates the average state of charge and updates the EE observed charge input, stores the raw battery details in EE observed batteries, records the current time in EE envoy battery reporting time, and logs the request latency in EE observed envoy read battery latency. After each successful loop iteration, it waits for two seconds. After completing all 60 loops, the automation turns itself off and then immediately turns itself back on." }, "human_like": "This automation reads battery data from an Envoy device 60 times in a row, updates several sensor values with the results, and then resets itself.", "complexity": "high" } }, { "id": "ee_read_envoy_livedata", "result": { "structured": "TRIGGER: When Home Assistant starts OR When the automation entity [this.entity_id] is on AND remains on for 1 second. CONDITIONS: None. ACTIONS: Repeat the following sequence 60 times: 1. Set variable 'request_time' to the current time. 2. Execute the rest command read envoy livedata status [rest_command.read_envoy_livedata_status] and store the response. 3. Set variable 'response_time' to the current time, 'just_now' to the formatted time, and 'latency' to the difference between request_time and response_time. 4. If the response is undefined, has status 'timeout', or has a status code of 200, then send a persistent notification [notify.persistent_notification] with a failure message and stop the repeat loop with an error. Otherwise, parse the response content. 5. If the stream connection status 'sc_stream' is 'enabled', then execute the rest command envoy enable livedata stream [rest_command.envoy_enable_livedata_stream], send a notification, and delay for 1 minute. 6. If the stream connection status 'sc_stream' is not 'enabled', then extract solar production, net consumption, battery flow, and home load values from the response, calculate total consumption, and update the following input numbers: EE observed battery flow [input_number.ee_observed_battery_flow], EE observed solar production [input_number.ee_observed_solar_production], EE observed net consumption [input_number.ee_observed_net_consumption], EE observed total consumption [input_number.ee_observed_total_consumption], EE observed home load [input_number.ee_observed_home_load]. Also update the datetime EE envoy pc reporting time [input_datetime.ee_envoy_pc_reporting_time] with the 'just_now' time and the latency number EE observed envoy read livedata latency [input_number.ee_observed_envoy_read_livedata_latency] with the calculated latency. Then delay for 1 second. After the repeat loop, turn off the automation entity [this.entity_id] and then turn it back on.", "natural_language": { "trigger": "The automation starts either when Home Assistant itself starts up, or when the automation's own entity is switched on and remains on for at least one second.", "conditions": "There are no conditions that must be met for the automation to proceed.", "action": "The automation performs a loop 60 times. In each loop, it attempts to read live data from an Envoy device by calling a REST command. It records the start time, makes the request, and records the end time to calculate latency. If the request fails (is undefined, times out, or returns a 200 status code, which appears to be a logic error for failure), it sends a persistent notification with an error message and stops the loop. If the request succeeds, it checks if the data stream from the Envoy is enabled. If the stream is enabled, it sends a command to enable the stream (which seems redundant), sends a notification, and waits one minute before the next loop iteration. If the stream is not enabled, it extracts solar production, net grid consumption, battery power flow, and home load data from the response. It calculates the total home consumption and updates several input_number helper entities with these values. It also records the time of the report and the request latency. It then waits one second before the next loop iteration. After completing all 60 loops, the automation turns itself off and then immediately turns itself back on." }, "human_like": "This automation periodically fetches live solar and energy data from an Envoy device, updates dashboard sensors with the latest values, and handles errors or stream enabling if needed.", "complexity": "high" } }, { "id": "ee_read_envoy_relay", "result": { "structured": "TRIGGER: Every minute (time pattern: minutes divisible by 1). CONDITIONS: None. ACTIONS: Execute the REST command read envoy relay [rest_command.read_envoy_relay] and store the response. Extract the 'mains_oper_state' value from the response content. Set the value of EE observed grid status [input_text.ee_observed_grid_status] to the extracted grid status.", "natural_language": { "trigger": "The automation runs every minute.", "conditions": "There are no conditions that must be met.", "action": "It calls a REST command named read envoy relay [rest_command.read_envoy_relay] to fetch data. From the response, it extracts the current mains operating state. It then updates the text field EE observed grid status [input_text.ee_observed_grid_status] with this extracted value." }, "human_like": "Checks the grid status from an Envoy device every minute and updates a text field with the result.", "complexity": "low" } }, { "id": "ee_read_envoy_tariff", "result": { "structured": "TRIGGER: Every minute (time pattern minutes: /1). CONDITIONS: None. ACTIONS: Execute read envoy tariff rest command [rest_command.read_envoy_tariff] and then execute ee decode tariff script [script.ee_decode_tariff] with the response from the previous command.", "natural_language": { "trigger": "The automation runs every minute.", "conditions": "There are no conditions; it runs every time the trigger occurs.", "action": "It first calls the 'read envoy tariff' REST command [rest_command.read_envoy_tariff] and stores its response. Then, it runs the 'ee decode tariff' script [script.ee_decode_tariff], passing the stored response to it." }, "human_like": "Checks the Envoy tariff information every minute and processes the data.", "complexity": "low" } }, { "id": "ee_read_envoy_xml_info", "result": { "structured": "TRIGGER: When the time pattern matches every 12 hours (i.e., at 0 and 12 hours). CONDITIONS: None. ACTIONS: Execute the rest command read envoy relay rest command [rest_command.read_envoy_relay] and store the response in variable 'envoy_ivp_ensemble_relay'. Set variable 'content' to the response content and variable 'grid' to a boolean indicating if the mains_oper_state is 'closed'. Execute the rest command read envoy xml info rest command [rest_command.read_envoy_xml_info] and store the response in variable 'envoy_info_xml'. Set variable 'xml_text' to the response content, extract the