econet.cr

Crystal Lang interface to the EcoNet API

EcoNet for Crystal

A Crystal port of pyeconet v0.3.1 for the unofficial Rheem EcoNet API. It discovers water heaters, thermostats, and thermostat zones over HTTPS and uses crystal-mqtt for live state updates and device commands.

Install

Add the shard to your application's shard.yml, then run shards install. Requires Crystal 1.20 or later.

dependencies:
  econet:
    github: stakach/econet.cr

Discover equipment

require "econet"

client = EcoNet::Client.login(ENV["ECONET_EMAIL"], ENV["ECONET_PASSWORD"])

client.get_equipment.each do |equipment|
  puts "#{equipment.device_name} (#{equipment.type})"
  case equipment
  when EcoNet::WaterHeater
    puts "Target temperature: #{equipment.set_point_celsius} °C"
    if usage = equipment.get_energy_usage
      puts "Today's usage: #{usage.values.sum} #{equipment.energy_type}"
    end
  when EcoNet::Thermostat
    puts "Mode: #{equipment.mode}"
  end
end

Call refresh_equipment to fetch fresh state while keeping existing equipment objects and their callbacks. Devices expose supported modes and capabilities, such as away mode, schedule status, fan controls, and leak or shutoff valve information. Availability depends on the model. Water heaters also expose water and historical energy usage where the service provides it.

Subscribe and send commands

heater = client.get_equipment.find { |item| item.is_a?(EcoNet::WaterHeater) }
if heater.is_a?(EcoNet::WaterHeater)
  heater.on_update do
    puts "Updated water-heater set point: #{heater.set_point_celsius} °C"
  end

  if client.subscribe
    begin
      heater.set_point_celsius = 58
      sleep 5.seconds
    ensure
      client.unsubscribe
    end
  end
end

subscribe waits for the broker and starts processing updates in the background. It returns false if equipment has yet to be discovered or none is available. While the subscription is open, the MQTT client reconnects after a dropped connection.

Equipment Assignment setters
Water heater set_point= (native units), set_point_celsius=, mode=
Thermostat heat_set_point=, cool_set_point=, mode=, fan_speed=, fan_mode=, dehumidifier_set_point=
Both away=

The Celsius setter converts to the water heater's native unit and rounds to its reported precision. Assignment setters raise ArgumentError for invalid values or unsupported settings. Read back the reported state to confirm the device applied a command.

The thermostat checks heating and cooling targets against its current mode and reported limits. In auto mode, use thermostat.set_set_point(target_temp_cool: 76, target_temp_heat: 68) to send both targets in native units. The set_* command methods return true when they send a command and false when the request is invalid or unsupported.

schedule_status returns EcoNet::ScheduleStatus::Following, Overridden, or Unknown, with nil when the device supplies no status. Use schedule_status_text for the original device label.

The EcoNet cloud endpoints are unofficial and can change independently of this shard.

Development

shards install
crystal spec
shards build ameba
bin/ameba

The specs exercise REST and MQTT behavior against local servers with fixture data.

Repository

econet.cr

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 2
  • about 2 hours ago
  • November 19, 2026
License

MIT License

Links
Synced at

Thu, 19 Nov 2026 06:51:20 GMT

Languages